DCL 4.0
Loading...
Searching...
No Matches
SQL.inl
Go to the documentation of this file.
1#ifndef __DCL_SQL_H__
2 #error "Never use <dcl/core/SQL.inl> directly; include <dcl/core/SQL.h> instead."
3#endif
4#ifndef __DCL_SQL_INL__
5#define __DCL_SQL_INL__
6
7#if __DCL_DEBUG
8static const wchar_t* __pszSQL_inl__ = __T("dcl/SQL.inl");
9#undef __THIS_FILE__
10#define __THIS_FILE__ __pszSQL_inl__
11#endif
12
13inline SQL::Field* SQLField::handle() const
14{
15 return __handle;
16}
17
18inline const wchar_t* SQLField::dataTypeName() const
19{
20 return SQL::dataTypeName(dataType());
21}
22
23inline size_t SQLField::dataSize() __DCL_THROWS1(SQLException*)
24{
25 return getDataSize(false);
26}
27
28inline size_t SQLField::dataSizeMax() __DCL_THROWS1(SQLException*)
29{
30 return getDataSize(true);
31}
32
33inline int SQLField::asInteger() __DCL_THROWS1(SQLException*)
34{
35
36 switch (sizeof(int)) {
37 case 4 : return asInt32();
38 case 8 : return (int)asInt64();
39 default : {
40 __DCL_ASSERT(false);
41 }
42 }
43 return 0; // not reached
44}
45
46#if defined(_MSC_VER) && _MSC_VER <= 1200
47inline void SQLParam::setValue(int value) __DCL_THROWS1(SQLException*)
48{
49 switch (sizeof(int)) {
50 case 4 :
51 setValue((int32_t)value);
52 break;
53 case 8 :
54 setValue((int64_t)value);
55 break;
56 default : {
57 __DCL_ASSERT(false);
58 }
59 }
60}
61
62inline void SQLParam::setValue(unsigned int value) __DCL_THROWS1(SQLException*)
63{
64 switch (sizeof(unsigned int)) {
65 case 4 :
66 setValue((uint32_t)value);
67 break;
68 case 8 :
69 setValue((uint64_t)value);
70 break;
71 default : {
72 __DCL_ASSERT(false);
73 }
74 }
75}
76#endif
77
79inline _CONST SQLField& SQLFields::at(size_t _index) const
80{
81 __DCL_ASSERT_PARAM(_index >= 0);
82 __DCL_ASSERT_PARAM(_index < __count);
83 return __fields[_index];
84}
85
86inline _CONST SQLField& SQLFields::operator[](size_t _index) const
87{
88 __DCL_ASSERT_PARAM(_index >= 0);
89 __DCL_ASSERT_PARAM(_index < __count);
90 return __fields[_index];
91}
92
93inline size_t SQLFields::count() const
94{
95 return __count;
96}
97
98inline bool SQLFields::isEmpty() const
99{
100 return __count == 0;
101}
102
104inline SQLParam& SQLParams::at(size_t _index) const
105{
106 __DCL_ASSERT_PARAM(_index >= 0);
107 __DCL_ASSERT_PARAM(_index < __count);
108 return __params[_index];
109}
110
111inline SQLParam& SQLParams::operator[](size_t _index) const
112{
113 __DCL_ASSERT_PARAM(_index >= 0);
114 __DCL_ASSERT_PARAM(_index < __count);
115 return __params[_index];
116}
117
118inline size_t SQLParams::count() const
119{
120 return __count;
121}
122
123inline bool SQLParams::isEmpty() const
124{
125 return __count == 0;
126}
127
128// SQLQuery
129inline bool SQLQuery::eof() const
130{
131 return __handle->eof();
132}
133
134inline int64_t SQLQuery::affectedRows() const
135{
136 return __handle->affectedRows();
137}
138
140{
141 return __fields;
142}
143
145{
146 return __params;
147}
148
150{
151 return __handle;
152}
153
155{
156 return __connection;
157}
158
159// SQLConnection
161{
162 return __handle;
163}
164
166{
167 return __driver;
168}
169
170inline bool SQLConnection::connected() const
171{
172 return __connected;
173}
174
175// SQLConnectionPool
176inline size_t SQLConnectionPool::count() const
177{
178 return __allConns.size();
179}
180
181inline size_t SQLConnectionPool::idleCount() const
182{
183 return __idleConns.size();
184}
185
186#if __DCL_DEBUG
187#undef __THIS_FILE__
188#define __THIS_FILE__ __T(__FILE__)
189#endif
190
191#endif // __DCL_SQL_INL__
#define _CONST
Definition Config.h:353
#define __DCL_THROWS1(e)
Definition Config.h:167
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:384
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
void CharsetConvertException * setValue(UTF8Encoder::encode(_value), _assignType)
SQLDriver * __driver
Definition SQL.h:340
bool __connected
Definition SQL.h:341
SQLDriver * driver() const
Definition SQL.inl:165
bool connected() const
Definition SQL.inl:170
SQL::Connection * handle() const
Definition SQL.inl:160
SQL::Connection * __handle
Definition SQL.h:339
PointerList __idleConns
Definition SQL.h:371
PointerArray __allConns
Definition SQL.h:372
Definition SQL.h:48
SQL::Field * __handle
Definition SQL.h:117
_CONST SQLField & at(size_t _index) const
Definition SQL.inl:79
size_t count() const
Definition SQL.inl:93
_CONST SQLField & operator[](size_t _index) const
Definition SQL.inl:86
bool isEmpty() const
Definition SQL.inl:98
static const wchar_t * dataTypeName(DataType _dataType)
Definition SQLCore.cpp:108
size_t count() const
Definition SQL.inl:118
SQLParam & operator[](size_t _index) const
Definition SQL.inl:111
SQLParam & at(size_t _index) const
Definition SQL.inl:104
bool isEmpty() const
Definition SQL.inl:123
SQL::Query * __handle
Definition SQL.h:294
_CONST SQLParams & params() _CONST
Definition SQL.inl:144
_CONST SQLFields & fields() _CONST
Definition SQL.inl:139
SQLParams __params
Definition SQL.h:297
int64_t affectedRows() const
Definition SQL.inl:134
bool eof() const
Definition SQL.inl:129
SQLConnection * connection() const
Definition SQL.inl:154
SQL::Query * handle() const
Definition SQL.inl:149
SQLFields __fields
Definition SQL.h:296
SQLConnection * __connection
Definition SQL.h:295