Version: 1.0.0
mysql_param.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_MYSQL
4 
5 // ctor
7 {
9 }
10 
11 wxMysqlParameter::wxMysqlParameter(const wxString& strValue)
12 {
14  m_strValue = strValue;
16  if (wxT("") == strValue)
17  {
18  m_nBufferLength = 0;
19  }
20  else
21  {
23  }
24 }
25 
27 {
29  m_nValue = nValue;
30  //m_strValue = wxString::Format(_("%d"), nValue);
31 }
32 
34 {
36  m_dblValue = dblValue;
37  //m_strValue = wxString::Format(_("%f"), dblValue);
38 }
39 
41 {
43  m_bValue = bValue;
44 }
45 
46 wxMysqlParameter::wxMysqlParameter(const wxDateTime& dateValue)
47 {
49 
50  m_pDate = new MYSQL_TIME();
51 
52  memset(m_pDate, 0, sizeof(MYSQL_TIME));
53 
54  m_pDate->year = dateValue.GetYear();
55  m_pDate->month = dateValue.GetMonth()+1;
56  m_pDate->day = dateValue.GetDay();
57  m_pDate->hour = dateValue.GetHour();
58  m_pDate->minute = dateValue.GetMinute();
59  m_pDate->second = dateValue.GetSecond();
60  m_pDate->neg = 0;
61 
62  m_nBufferLength = sizeof(MYSQL_TIME);
63 }
64 
65 wxMysqlParameter::wxMysqlParameter(const void* pData, long nDataLength)
66 {
68  void* pBuffer = m_BufferValue.GetWriteBuf(nDataLength);
69  memcpy(pBuffer, pData, nDataLength);
70  m_nBufferLength = nDataLength;
71 }
72 
74 {
76  {
77  delete m_pDate;
78  m_pDate = NULL;
79  }
80 }
81 
82 long unsigned int wxMysqlParameter::GetDataLength()
83 {
84  return m_nBufferLength;
85 }
86 
87 long unsigned int* wxMysqlParameter::GetDataLengthPtr()
88 {
89  return &m_nBufferLength;
90 }
91 
92 const void* wxMysqlParameter::GetDataPtr()
93 {
94  const void *pReturn = NULL;
95 
96  switch (m_nParameterType)
97  {
99  pReturn = m_CharBufferValue;
100  break;
102  pReturn = &m_nValue;
103  break;
105  pReturn = &m_dblValue;
106  break;
108  pReturn = m_pDate;
109  break;
111  pReturn = &m_bValue;
112  break;
114  pReturn = m_BufferValue.GetData();
115  break;
117  pReturn = NULL;
118  break;
119  default:
120  pReturn = NULL;
121  break;
122  };
123  return pReturn;
124 }
125 
127 {
128  return m_nParameterType;
129 }
130 
131 enum_field_types wxMysqlParameter::GetBufferType()
132 {
133  enum_field_types returnType = MYSQL_TYPE_NULL;
134 
135  switch (m_nParameterType)
136  {
138  returnType = MYSQL_TYPE_VAR_STRING;
139  break;
141  returnType = MYSQL_TYPE_LONG;
142  break;
144  returnType = MYSQL_TYPE_DOUBLE;
145  break;
147  returnType = MYSQL_TYPE_TIMESTAMP;
148  break;
150  returnType = MYSQL_TYPE_TINY;
151  break;
153  returnType = MYSQL_TYPE_LONG_BLOB;
154  break;
156  returnType = MYSQL_TYPE_NULL;
157  break;
158  default:
159  returnType = MYSQL_TYPE_NULL;
160  break;
161  };
162 
163  return returnType;
164 }
165 
166 #endif//wxUSE_DATABASE_MYSQL
MYSQL_TIME * m_pDate
Definition: mysql_param.h:46
const void * GetDataPtr()
long unsigned int * GetDataLengthPtr()
virtual ~wxMysqlParameter()
long unsigned int GetDataLength()
wxMemoryBuffer m_BufferValue
Definition: mysql_param.h:48
long unsigned int m_nBufferLength
Definition: mysql_param.h:50
virtual size_t GetEncodedStreamLength(const wxString &inputString)
enum_field_types GetBufferType()
wxCharBuffer m_CharBufferValue
Definition: mysql_param.h:49
virtual const wxCharBuffer ConvertToUnicodeStream(const wxString &inputString)
wxString m_strValue
Definition: mysql_param.h:43