00001 /* 00002 Datasource.h 00003 00004 Qore Programming Language 00005 00006 Copyright 2003 - 2009 David Nichols 00007 00008 The Datasource class provides the low-level interface to Qore DBI drivers. 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00023 */ 00024 00025 #ifndef _QORE_DATASOURCE_H 00026 00027 #define _QORE_DATASOURCE_H 00028 00029 #include <qore/QoreThreadLock.h> 00030 00031 class DBIDriver; 00032 00034 00042 class Datasource { 00043 private: 00044 struct qore_ds_private *priv; // private implementation 00045 00047 DLLLOCAL Datasource(const Datasource&); 00048 00050 DLLLOCAL Datasource& operator=(const Datasource&); 00051 00052 protected: 00054 DLLEXPORT void freeConnectionValues(); 00055 00057 DLLEXPORT void setConnectionValues(); 00058 00060 DLLEXPORT void setTransactionStatus(bool); 00061 00063 DLLEXPORT void setPendingConnectionValues(const Datasource *other); 00064 00066 DLLEXPORT int beginImplicitTransaction(ExceptionSink *xsink); 00067 00068 public: 00070 00073 DLLEXPORT Datasource(DBIDriver *driver); 00074 00076 DLLEXPORT virtual ~Datasource(); 00077 00079 00082 DLLEXPORT bool getAutoCommit() const; 00083 00085 00088 DLLEXPORT const char *getUsername() const; 00089 00091 00094 DLLEXPORT const char *getPassword() const; 00095 00097 00100 DLLEXPORT const char *getDBName() const; 00101 00103 00106 DLLEXPORT const char *getDBEncoding() const; 00107 00109 00112 DLLEXPORT const char *getOSEncoding() const; 00113 00115 00118 DLLEXPORT const char *getHostName() const; 00119 00121 00124 DLLEXPORT int getPort() const; 00125 00127 DLLEXPORT void *getPrivateData() const; 00128 00130 00133 DLLEXPORT void setPrivateData(void *data); 00134 00136 00139 DLLEXPORT void setDBEncoding(const char *name); 00140 00142 DLLEXPORT const QoreEncoding *getQoreEncoding() const; 00143 00145 00148 DLLEXPORT void setQoreEncoding(const QoreEncoding *enc); 00149 00151 00154 DLLEXPORT void setQoreEncoding(const char *name); 00155 00157 00160 DLLEXPORT void setPendingUsername(const char *u); 00161 00163 00166 DLLEXPORT void setPendingPassword(const char *p); 00167 00169 00172 DLLEXPORT void setPendingDBName(const char *d); 00173 00175 00178 DLLEXPORT void setPendingDBEncoding(const char *c); 00179 00181 00184 DLLEXPORT void setPendingHostName(const char *h); 00185 00187 00190 DLLEXPORT void setPendingPort(int port); 00191 00192 DLLEXPORT void setAutoCommit(bool ac); 00193 00195 00198 DLLEXPORT int open(ExceptionSink *xsink); 00199 00201 00206 DLLEXPORT AbstractQoreNode *select(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink); 00207 00209 00214 DLLEXPORT AbstractQoreNode *selectRows(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink); 00215 00217 00224 DLLEXPORT AbstractQoreNode *exec(const QoreString *query_str, const QoreListNode *args, ExceptionSink *xsink); 00225 00227 00231 DLLEXPORT int commit(ExceptionSink *xsink); 00232 00234 00238 DLLEXPORT int rollback(ExceptionSink *xsink); 00239 00241 DLLEXPORT int close(); 00242 00244 DLLEXPORT void reset(ExceptionSink *xsink); 00245 00247 00250 DLLEXPORT QoreListNode *getCapabilityList() const; 00251 00253 00256 DLLEXPORT int getCapabilities() const; 00257 00259 00261 DLLEXPORT QoreStringNode *getPendingUsername() const; 00262 00264 00266 DLLEXPORT QoreStringNode *getPendingPassword() const; 00267 00269 00271 DLLEXPORT QoreStringNode *getPendingDBName() const; 00272 00274 00276 DLLEXPORT QoreStringNode *getPendingDBEncoding() const; 00277 00279 00282 DLLEXPORT QoreStringNode *getPendingHostName() const; 00283 00285 00288 DLLEXPORT int getPendingPort() const; 00289 00290 00296 DLLEXPORT int beginTransaction(ExceptionSink *xsink); 00297 00299 00302 DLLEXPORT bool isInTransaction() const; 00303 00305 00308 DLLEXPORT bool isOpen() const; 00309 00311 00314 DLLEXPORT Datasource *copy() const; 00315 00317 DLLEXPORT const char *getDriverName() const; 00318 00320 00324 DLLEXPORT AbstractQoreNode *getServerVersion(ExceptionSink *xsink); 00325 00327 00330 DLLEXPORT AbstractQoreNode *getClientVersion(ExceptionSink *xsink) const; 00331 00333 00336 DLLEXPORT const DBIDriver *getDriver() const; 00337 00339 00343 DLLEXPORT void connectionAborted(); 00344 00346 00348 DLLEXPORT bool wasConnectionAborted() const; 00349 }; 00350 00351 #endif // _QORE_DATASOURCE_H