Version: 1.0.0
postgresql_preparedstatement_parameter_collection.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_POSTGRESQL
4 
5 #include "wx/arrimpl.cpp"
6 WX_DEFINE_OBJARRAY(ArrayOfPostgresParameters);
7 
9 {
10  m_Parameters.Clear();
11 }
12 
14 {
15  return m_Parameters.size();
16 }
17 
19 {
20  char** paramValues = new char*[m_Parameters.size()];
21 
22  for (unsigned int i=0; i<m_Parameters.size(); i++)
23  {
24  // Get a pointer to the appropriate data member variable for this parameter
25  paramValues[i] = (char*)(m_Parameters[i].GetDataPtr());
26  }
27 
28  return paramValues;
29 }
30 
32 {
33  int* paramLengths = new int[m_Parameters.size()];
34 
35  for (unsigned int i=0; i<m_Parameters.size(); i++)
36  {
37  // Get a pointer to the m_nBufferLength member variable for this parameter
38  paramLengths[i] = m_Parameters[i].GetDataLength();
39  }
40 
41  return paramLengths;
42 }
43 
45 {
46  int* paramFormats = new int[m_Parameters.size()];
47 
48  for (unsigned int i=0; i<m_Parameters.size(); i++)
49  {
50  paramFormats[i] = (m_Parameters[i].IsBinary()) ? 1 : 0;
51  }
52 
53  return paramFormats;
54 }
55 
57 {
58  wxPostgresParameter Parameter(nValue);
59  SetParam(nPosition, Parameter);
60 }
61 
62 void wxPostgresPreparedStatementParameterCollection::SetParam(int nPosition, double dblValue)
63 {
64  wxPostgresParameter Parameter(dblValue);
65  SetParam(nPosition, Parameter);
66 }
67 
68 void wxPostgresPreparedStatementParameterCollection::SetParam(int nPosition, const wxString& strValue)
69 {
70  wxPostgresParameter Parameter(strValue);
71  SetParam(nPosition, Parameter);
72 }
73 
75 {
76  wxPostgresParameter Parameter;
77  SetParam(nPosition, Parameter);
78 }
79 
80 void wxPostgresPreparedStatementParameterCollection::SetParam(int nPosition, const void* pData, long nDataLength)
81 {
82  wxPostgresParameter Parameter(pData, nDataLength);
83  SetParam(nPosition, Parameter);
84 }
85 
86 void wxPostgresPreparedStatementParameterCollection::SetParam(int nPosition, const wxDateTime& dateValue)
87 {
88  wxPostgresParameter Parameter(dateValue);
89  SetParam(nPosition, Parameter);
90 }
91 
92 void wxPostgresPreparedStatementParameterCollection::SetParam(int nPosition, bool bValue)
93 {
94  wxPostgresParameter Parameter(bValue);
95  SetParam(nPosition, Parameter);
96 }
97 
99 {
100  // First make sure that there are enough elements in the collection
101  while (m_Parameters.size() < (unsigned int)(nPosition))
102  {
103  wxPostgresParameter EmptyParameter;
104  m_Parameters.push_back(EmptyParameter);
105  }
106  m_Parameters[nPosition-1] = Parameter;
107 }
108 
109 #endif//wxUSE_DATABASE_POSTGRESQL
void SetParam(int nPosition, int nValue)