Version: 1.0.0
src
database
postgresql
postgresql_param.cpp
Go to the documentation of this file.
1
#include "
wx/database/wxprec.h
"
2
3
#if wxUSE_DATABASE_POSTGRESQL
4
5
// ctor
6
wxPostgresParameter::wxPostgresParameter
()
7
{
8
m_nParameterType
=
wxPostgresParameter::PARAM_NULL
;
9
}
10
11
wxPostgresParameter::wxPostgresParameter
(
const
wxString& strValue)
12
{
13
m_nParameterType
=
wxPostgresParameter::PARAM_STRING
;
14
m_strValue
= strValue;
15
m_nBufferLength
=
m_strValue
.Length();
16
}
17
18
wxPostgresParameter::wxPostgresParameter
(
int
nValue)
19
{
20
m_nParameterType
=
wxPostgresParameter::PARAM_INT
;
21
//m_nValue = nValue;
22
m_strValue
= wxString::Format(_(
"%d"
), nValue);
23
}
24
25
wxPostgresParameter::wxPostgresParameter
(
double
dblValue)
26
{
27
m_nParameterType
=
wxPostgresParameter::PARAM_DOUBLE
;
28
//m_dblValue = dblValue;
29
m_strValue
= wxString::Format(_(
"%f"
), dblValue);
30
}
31
32
wxPostgresParameter::wxPostgresParameter
(
bool
bValue)
33
{
34
m_nParameterType
=
wxPostgresParameter::PARAM_BOOL
;
35
m_bValue
= bValue;
36
}
37
38
wxPostgresParameter::wxPostgresParameter
(
const
wxDateTime& dateValue)
39
{
40
m_nParameterType
=
wxPostgresParameter::PARAM_DATETIME
;
41
m_strDateValue
= dateValue.Format(_(
"%Y-%m-%d %H:%M:%S"
));
42
m_nBufferLength
=
m_strDateValue
.Length();
43
}
44
45
wxPostgresParameter::wxPostgresParameter
(
const
void
* pData,
long
nDataLength)
46
{
47
m_nParameterType
=
wxPostgresParameter::PARAM_BLOB
;
48
void
* pBuffer =
m_BufferValue
.GetWriteBuf(nDataLength);
49
memcpy(pBuffer, pData, nDataLength);
50
m_nBufferLength
= nDataLength;
51
}
52
53
54
long
wxPostgresParameter::GetDataLength
()
55
{
56
return
m_nBufferLength
;
57
}
58
59
long
*
wxPostgresParameter::GetDataLengthPointer
()
60
{
61
return
&
m_nBufferLength
;
62
}
63
64
const
void
*
wxPostgresParameter::GetDataPtr
()
65
{
66
const
void
*pReturn = NULL;
67
68
switch
(
m_nParameterType
)
69
{
70
case
wxPostgresParameter::PARAM_STRING
:
71
m_CharBufferValue
=
ConvertToUnicodeStream
(
m_strValue
);
72
pReturn =
m_CharBufferValue
;
73
break
;
74
case
wxPostgresParameter::PARAM_INT
:
75
//pReturn = &m_nValue;
76
m_CharBufferValue
=
ConvertToUnicodeStream
(
m_strValue
);
77
pReturn =
m_CharBufferValue
;
78
break
;
79
case
wxPostgresParameter::PARAM_DOUBLE
:
80
//pReturn = &m_dblValue;
81
m_CharBufferValue
=
ConvertToUnicodeStream
(
m_strValue
);
82
pReturn =
m_CharBufferValue
;
83
break
;
84
case
wxPostgresParameter::PARAM_DATETIME
:
85
m_CharBufferValue
=
ConvertToUnicodeStream
(
m_strDateValue
);
86
pReturn =
m_CharBufferValue
;
87
break
;
88
case
wxPostgresParameter::PARAM_BOOL
:
89
pReturn = &
m_bValue
;
90
break
;
91
case
wxPostgresParameter::PARAM_BLOB
:
92
pReturn =
m_BufferValue
.GetData();
93
break
;
94
case
wxPostgresParameter::PARAM_NULL
:
95
pReturn = NULL;
96
break
;
97
default
:
98
pReturn = NULL;
99
break
;
100
};
101
return
pReturn;
102
}
103
104
int
wxPostgresParameter::GetParameterType
()
105
{
106
return
m_nParameterType
;
107
}
108
109
bool
wxPostgresParameter::IsBinary
()
110
{
111
return
(
wxPostgresParameter::PARAM_BLOB
==
m_nParameterType
);
112
}
113
114
#endif//wxUSE_DATABASE_POSTGRESQL
wxprec.h
wxPostgresParameter::PARAM_BOOL
Definition:
postgresql_param.h:26
wxPostgresParameter::PARAM_NULL
Definition:
postgresql_param.h:28
wxPostgresParameter::GetParameterType
int GetParameterType()
wxPostgresParameter::IsBinary
bool IsBinary()
wxPostgresParameter::m_bValue
bool m_bValue
Definition:
postgresql_param.h:47
wxPostgresParameter::m_nBufferLength
long m_nBufferLength
Definition:
postgresql_param.h:50
wxPostgresParameter::GetDataPtr
const void * GetDataPtr()
wxPostgresParameter::m_strValue
wxString m_strValue
Definition:
postgresql_param.h:43
wxPostgresParameter::m_nParameterType
int m_nParameterType
Definition:
postgresql_param.h:40
wxPostgresParameter::m_strDateValue
wxString m_strDateValue
Definition:
postgresql_param.h:46
wxPostgresParameter::PARAM_BLOB
Definition:
postgresql_param.h:27
wxPostgresParameter::PARAM_INT
Definition:
postgresql_param.h:23
wxPostgresParameter::PARAM_DATETIME
Definition:
postgresql_param.h:25
wxPostgresParameter::wxPostgresParameter
wxPostgresParameter()
wxPostgresParameter::m_CharBufferValue
wxCharBuffer m_CharBufferValue
Definition:
postgresql_param.h:49
wxPostgresParameter::GetDataLengthPointer
long * GetDataLengthPointer()
wxPostgresParameter::GetDataLength
long GetDataLength()
wxPostgresParameter::m_BufferValue
wxMemoryBuffer m_BufferValue
Definition:
postgresql_param.h:48
wxDatabaseStringConverter::ConvertToUnicodeStream
virtual const wxCharBuffer ConvertToUnicodeStream(const wxString &inputString)
Definition:
string_converter.cpp:24
wxPostgresParameter::PARAM_DOUBLE
Definition:
postgresql_param.h:24
wxPostgresParameter::PARAM_STRING
Definition:
postgresql_param.h:22
Generated on Mon Aug 19 2019 16:14:36 for wxDatabase by
Doxygen
1.8.15