Version: 1.0.0
resultset.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 // ctor()
6 {
7 }
8 
9 // dtor()
11 {
12  //wxPrintf(_("~wxDatabaseResultSet()\n"));
13  CloseMetaData();
14 }
15 
16 int wxDatabaseResultSet::GetResultInt(const wxString& strField)
17 {
18  int nIndex = LookupField(strField);
19  if (nIndex != -1)
20  {
21  return GetResultInt(nIndex);
22  }
23  return -1;
24 }
25 
26 wxString wxDatabaseResultSet::GetResultString(const wxString& strField)
27 {
28  int nIndex = LookupField(strField);
29  if (nIndex != -1)
30  {
31  return GetResultString(nIndex);
32  }
33  return wxEmptyString;
34 }
35 
36 long wxDatabaseResultSet::GetResultLong(const wxString& strField)
37 {
38  int nIndex = LookupField(strField);
39  if (nIndex != -1)
40  {
41  return GetResultLong(nIndex);
42  }
43  return -1;
44 }
45 
46 bool wxDatabaseResultSet::GetResultBool(const wxString& strField)
47 {
48  int nIndex = LookupField(strField);
49  if (nIndex != -1)
50  {
51  return GetResultBool(nIndex);
52  }
53  return false;
54 }
55 
56 wxDateTime wxDatabaseResultSet::GetResultDate(const wxString& strField)
57 {
58  int nIndex = LookupField(strField);
59  if (nIndex != -1)
60  {
61  return GetResultDate(nIndex);
62  }
63  return wxInvalidDateTime;
64 }
65 
66 void* wxDatabaseResultSet::GetResultBlob(const wxString& strField, wxMemoryBuffer& Buffer)
67 {
68  int nIndex = LookupField(strField);
69  if (nIndex != -1)
70  {
71  return GetResultBlob(nIndex, Buffer);
72  }
73  return NULL;
74 }
75 
76 double wxDatabaseResultSet::GetResultDouble(const wxString& strField)
77 {
78  int nIndex = LookupField(strField);
79  if (nIndex != -1)
80  {
81  return GetResultDouble(nIndex);
82  }
83  return -1;
84 }
85 
86 bool wxDatabaseResultSet::IsFieldNull(const wxString& strField)
87 {
88  int nIndex = LookupField(strField);
89  if (nIndex != -1)
90  {
91  return IsFieldNull(nIndex);
92  }
93  return true;
94 }
95 
97 {
98  // Iterate through all of the meta data and close them all
99  wxMetaDataHashSet::iterator start = m_MetaData.begin();
100  wxMetaDataHashSet::iterator stop = m_MetaData.end();
101  while (start != stop)
102  {
103  delete (*start);
104  start++;
105  }
106  m_MetaData.clear();
107 }
108 
110 {
111  if (pMetaData != NULL)
112  {
113  // Check if we have this meta data in our list
114  if (m_MetaData.find(pMetaData) != m_MetaData.end())
115  {
116  // Remove the meta data pointer from the list and delete the pointer
117  delete pMetaData;
118  m_MetaData.erase(pMetaData);
119  return true;
120  }
121 
122  // Delete the pointer
123  delete pMetaData;
124  return true;
125  }
126  else
127  {
128  // Return false on NULL pointer
129  return false;
130  }
131 }
132 
virtual double GetResultDouble(int nField)=0
Retrieve a double from the result set by the 1-based field index.
virtual ~wxDatabaseResultSet()
Destructor.
Definition: resultset.cpp:10
wxDatabaseResultSet()
Constructor.
Definition: resultset.cpp:4
virtual bool IsFieldNull(int nField)=0
Check if a field in the current result set record is NULL.
virtual wxString GetResultString(int nField)=0
Retrieve a wxString from the result set by the 1-based field index.
virtual int LookupField(const wxString &strField)=0
wxMetaDataHashSet m_MetaData
Definition: resultset.h:73
virtual int GetResultInt(int nField)=0
Retrieve an integer from the result set by the 1-based field index.
virtual long GetResultLong(int nField)=0
Retrieve a long from the result set by the 1-based field index.
void CloseMetaData()
Close all meta data objects that have been generated but not yet closed.
Definition: resultset.cpp:96
virtual wxDateTime GetResultDate(int nField)=0
Retrieve a wxDateTime from the result set by the 1-based field index.
virtual void * GetResultBlob(int nField, wxMemoryBuffer &Buffer)=0
Retrieve a BLOB from the result set by the 1-based field index.
virtual bool GetResultBool(int nField)=0
Retrieve a boolean from the result set by the 1-based field index.