00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _QORE_DATASOURCE_H
00027
00028 #define _QORE_DATASOURCE_H
00029
00030 #include <qore/QoreThreadLock.h>
00031
00032 #include <string>
00033
00034 class DBIDriver;
00035
00037
00045 class Datasource {
00046 private:
00047 struct qore_ds_private *priv;
00048
00050 DLLLOCAL Datasource(const Datasource&);
00051
00053 DLLLOCAL Datasource& operator=(const Datasource&);
00054
00056 DLLLOCAL AbstractQoreNode * exec_internal(bool doBind, const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink);
00057
00058 protected:
00060 DLLEXPORT void freeConnectionValues();
00061
00063 DLLEXPORT void setConnectionValues();
00064
00066 DLLEXPORT void setTransactionStatus(bool);
00067
00069 DLLEXPORT void setPendingConnectionValues(const Datasource *other);
00070
00072 DLLEXPORT int beginImplicitTransaction(ExceptionSink *xsink);
00073
00074 public:
00076
00079 DLLEXPORT Datasource(DBIDriver *driver);
00080
00082 DLLEXPORT virtual ~Datasource();
00083
00085
00088 DLLEXPORT bool getAutoCommit() const;
00089
00091
00094 DLLEXPORT const char *getUsername() const;
00095
00097
00100 DLLEXPORT const char *getPassword() const;
00101
00103
00106 DLLEXPORT const char *getDBName() const;
00107
00109
00112 DLLEXPORT const char *getDBEncoding() const;
00113
00115
00118 DLLEXPORT const char *getOSEncoding() const;
00119
00121
00124 DLLEXPORT const char *getHostName() const;
00125
00127
00130 DLLEXPORT int getPort() const;
00131
00133
00136 DLLEXPORT const std::string &getUsernameStr() const;
00137
00139
00142 DLLEXPORT const std::string &getPasswordStr() const;
00143
00145
00148 DLLEXPORT const std::string &getDBNameStr() const;
00149
00151
00154 DLLEXPORT const std::string &getDBEncodingStr() const;
00155
00157
00160 DLLEXPORT const std::string &getHostNameStr() const;
00161
00163 DLLEXPORT void *getPrivateData() const;
00164
00166
00169 DLLEXPORT void setPrivateData(void *data);
00170
00172
00175 DLLEXPORT void setDBEncoding(const char *name);
00176
00178 DLLEXPORT const QoreEncoding *getQoreEncoding() const;
00179
00181
00184 DLLEXPORT void setQoreEncoding(const QoreEncoding *enc);
00185
00187
00190 DLLEXPORT void setQoreEncoding(const char *name);
00191
00193
00196 DLLEXPORT void setPendingUsername(const char *u);
00197
00199
00202 DLLEXPORT void setPendingPassword(const char *p);
00203
00205
00208 DLLEXPORT void setPendingDBName(const char *d);
00209
00211
00214 DLLEXPORT void setPendingDBEncoding(const char *c);
00215
00217
00220 DLLEXPORT void setPendingHostName(const char *h);
00221
00223
00226 DLLEXPORT void setPendingPort(int port);
00227
00228 DLLEXPORT void setAutoCommit(bool ac);
00229
00231
00234 DLLEXPORT int open(ExceptionSink *xsink);
00235
00237
00242 DLLEXPORT AbstractQoreNode *select(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink);
00243
00245
00250 DLLEXPORT AbstractQoreNode *selectRows(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink);
00251
00253
00260 DLLEXPORT AbstractQoreNode *exec(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink);
00261
00263
00269 DLLEXPORT AbstractQoreNode *execRaw(const QoreString *query_str, ExceptionSink *xsink);
00270
00272
00276 DLLEXPORT int commit(ExceptionSink *xsink);
00277
00279
00283 DLLEXPORT int rollback(ExceptionSink *xsink);
00284
00286 DLLEXPORT int close();
00287
00289 DLLEXPORT void reset(ExceptionSink *xsink);
00290
00292
00295 DLLEXPORT QoreListNode *getCapabilityList() const;
00296
00298
00301 DLLEXPORT int getCapabilities() const;
00302
00304
00306 DLLEXPORT QoreStringNode *getPendingUsername() const;
00307
00309
00311 DLLEXPORT QoreStringNode *getPendingPassword() const;
00312
00314
00316 DLLEXPORT QoreStringNode *getPendingDBName() const;
00317
00319
00321 DLLEXPORT QoreStringNode *getPendingDBEncoding() const;
00322
00324
00327 DLLEXPORT QoreStringNode *getPendingHostName() const;
00328
00330
00333 DLLEXPORT int getPendingPort() const;
00334
00340 DLLEXPORT int beginTransaction(ExceptionSink *xsink);
00341
00343
00346 DLLEXPORT bool isInTransaction() const;
00347
00349
00352 DLLEXPORT bool isOpen() const;
00353
00355
00358 DLLEXPORT Datasource *copy() const;
00359
00361 DLLEXPORT const char *getDriverName() const;
00362
00364
00368 DLLEXPORT AbstractQoreNode *getServerVersion(ExceptionSink *xsink);
00369
00371
00374 DLLEXPORT AbstractQoreNode *getClientVersion(ExceptionSink *xsink) const;
00375
00377
00380 DLLEXPORT const DBIDriver *getDriver() const;
00381
00383
00387 DLLEXPORT void connectionAborted();
00388
00390
00392 DLLEXPORT bool wasConnectionAborted() const;
00393 };
00394
00395 #endif // _QORE_DATASOURCE_H
00396