Qore Programming Language
0.8.7
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
qore
Datasource.h
1
/* -*- mode: c++; indent-tabs-mode: nil -*- */
2
/*
3
Datasource.h
4
5
Qore Programming Language
6
7
Copyright 2003 - 2013 David Nichols
8
9
The Datasource class provides the low-level interface to Qore DBI drivers.
10
11
This library is free software; you can redistribute it and/or
12
modify it under the terms of the GNU Lesser General Public
13
License as published by the Free Software Foundation; either
14
version 2.1 of the License, or (at your option) any later version.
15
16
This library is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
Lesser General Public License for more details.
20
21
You should have received a copy of the GNU Lesser General Public
22
License along with this library; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
*/
25
26
#ifndef _QORE_DATASOURCE_H
27
28
#define _QORE_DATASOURCE_H
29
30
#include <qore/QoreThreadLock.h>
31
32
#include <string>
33
34
class
DBIDriver
;
35
37
45
class
Datasource
{
46
friend
class
QoreSQLStatement;
47
48
private
:
49
struct
qore_ds_private *priv;
// private implementation
50
52
DLLLOCAL
Datasource
& operator=(
const
Datasource
&);
53
55
DLLLOCAL
AbstractQoreNode
* exec_internal(
bool
doBind,
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
56
57
protected
:
59
DLLEXPORT
void
freeConnectionValues
();
60
62
DLLEXPORT
void
setConnectionValues
();
63
65
DLLEXPORT
void
setTransactionStatus
(
bool
);
66
68
DLLEXPORT
void
setPendingConnectionValues
(
const
Datasource
* other);
69
71
DLLEXPORT
int
beginImplicitTransaction
(
ExceptionSink
* xsink);
72
73
public
:
75
78
DLLEXPORT
Datasource
(
DBIDriver
* driver);
79
81
DLLEXPORT
Datasource
(
const
Datasource& old);
82
84
DLLEXPORT
virtual
~Datasource
();
85
87
90
DLLEXPORT
bool
getAutoCommit
()
const
;
91
93
96
DLLEXPORT
const
char
*
getUsername
()
const
;
97
99
102
DLLEXPORT
const
char
*
getPassword
()
const
;
103
105
108
DLLEXPORT
const
char
*
getDBName
()
const
;
109
111
114
DLLEXPORT
const
char
*
getDBEncoding
()
const
;
115
117
120
DLLEXPORT
const
char
*
getOSEncoding
()
const
;
121
123
126
DLLEXPORT
const
char
*
getHostName
()
const
;
127
129
132
DLLEXPORT
int
getPort
()
const
;
133
135
138
DLLEXPORT
const
std::string&
getUsernameStr
()
const
;
139
141
144
DLLEXPORT
const
std::string&
getPasswordStr
()
const
;
145
147
150
DLLEXPORT
const
std::string&
getDBNameStr
()
const
;
151
153
156
DLLEXPORT
const
std::string&
getDBEncodingStr
()
const
;
157
159
162
DLLEXPORT
const
std::string&
getHostNameStr
()
const
;
163
165
DLLEXPORT
void
*
getPrivateData
()
const
;
166
168
template
<
typename
T>
169
DLLLOCAL T*
getPrivateData
()
const
{
170
return
reinterpret_cast<
T*
>
(
getPrivateData
());
171
}
172
174
template
<
typename
T>
175
DLLLOCAL T&
getPrivateDataRef
()
const
{
176
return
*getPrivateData<T>();
177
}
178
180
183
DLLEXPORT
void
setPrivateData
(
void
* data);
184
186
189
DLLEXPORT
void
setDBEncoding
(
const
char
* name);
190
192
DLLEXPORT
const
QoreEncoding
*
getQoreEncoding
()
const
;
193
195
198
DLLEXPORT
void
setQoreEncoding
(
const
QoreEncoding
* enc);
199
201
204
DLLEXPORT
void
setQoreEncoding
(
const
char
* name);
205
207
210
DLLEXPORT
void
setPendingUsername
(
const
char
* u);
211
213
216
DLLEXPORT
void
setPendingPassword
(
const
char
* p);
217
219
222
DLLEXPORT
void
setPendingDBName
(
const
char
* d);
223
225
228
DLLEXPORT
void
setPendingDBEncoding
(
const
char
* c);
229
231
234
DLLEXPORT
void
setPendingHostName
(
const
char
* h);
235
237
240
DLLEXPORT
void
setPendingPort
(
int
port);
241
242
DLLEXPORT
void
setAutoCommit(
bool
ac);
243
245
248
DLLEXPORT
int
open
(
ExceptionSink
* xsink);
249
251
256
DLLEXPORT
AbstractQoreNode
*
select
(
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
257
259
264
DLLEXPORT
AbstractQoreNode
*
selectRows
(
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
265
267
274
DLLEXPORT
QoreHashNode
*
selectRow
(
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
275
277
284
DLLEXPORT
AbstractQoreNode
*
exec
(
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
285
287
297
DLLEXPORT
AbstractQoreNode
*
execRaw
(
const
QoreString
* query_str,
const
QoreListNode
* args,
ExceptionSink
* xsink);
298
300
307
DLLEXPORT
AbstractQoreNode
*
execRaw
(
const
QoreString
* query_str,
ExceptionSink
* xsink);
308
310
314
DLLEXPORT
int
commit
(
ExceptionSink
* xsink);
315
317
321
DLLEXPORT
int
rollback
(
ExceptionSink
* xsink);
322
324
DLLEXPORT
int
close
();
325
327
DLLEXPORT
void
reset
(
ExceptionSink
* xsink);
328
330
333
DLLEXPORT
QoreListNode
*
getCapabilityList
()
const
;
334
336
339
DLLEXPORT
int
getCapabilities
()
const
;
340
342
344
DLLEXPORT
QoreStringNode
*
getPendingUsername
()
const
;
345
347
349
DLLEXPORT
QoreStringNode
*
getPendingPassword
()
const
;
350
352
354
DLLEXPORT
QoreStringNode
*
getPendingDBName
()
const
;
355
357
359
DLLEXPORT
QoreStringNode
*
getPendingDBEncoding
()
const
;
360
362
365
DLLEXPORT
QoreStringNode
*
getPendingHostName
()
const
;
366
368
371
DLLEXPORT
int
getPendingPort
()
const
;
372
378
DLLEXPORT
int
beginTransaction
(
ExceptionSink
* xsink);
379
381
384
DLLEXPORT
bool
isInTransaction
()
const
;
385
387
391
DLLEXPORT
bool
activeTransaction
()
const
;
392
394
397
DLLEXPORT
bool
isOpen
()
const
;
398
400
403
DLLEXPORT Datasource*
copy
()
const
;
404
406
DLLEXPORT
const
char
*
getDriverName
()
const
;
407
409
413
DLLEXPORT
AbstractQoreNode
*
getServerVersion
(
ExceptionSink
* xsink);
414
416
419
DLLEXPORT
AbstractQoreNode
*
getClientVersion
(
ExceptionSink
* xsink)
const
;
420
422
425
DLLEXPORT
const
DBIDriver
*
getDriver
()
const
;
426
428
432
DLLEXPORT
void
connectionAborted
();
433
435
437
DLLEXPORT
bool
wasConnectionAborted
()
const
;
438
440
444
DLLEXPORT
int
autoCommit
(
ExceptionSink
* xsink);
445
447
454
DLLEXPORT
QoreHashNode
*
getOptionHash
()
const
;
455
457
463
DLLEXPORT
int
setOption
(
const
char
* opt,
const
AbstractQoreNode
* val,
ExceptionSink
* xsink);
464
466
473
DLLEXPORT
AbstractQoreNode
*
getOption
(
const
char
* opt,
ExceptionSink
* xsink);
474
476
484
DLLEXPORT
const
QoreHashNode
*
getConnectOptions
()
const
;
485
};
486
487
#endif // _QORE_DATASOURCE_H
488