All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Datasource.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
Datasource.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
The Datasource class provides the low-level interface to Qore DBI drivers.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_DATASOURCE_H
#define _QORE_DATASOURCE_H
#include <qore/QoreThreadLock.h>
#include <string>
class DBIDriver;
class Datasource {
friend class QoreSQLStatement;
private:
struct qore_ds_private *priv; // private implementation
DLLLOCAL Datasource& operator=(const Datasource&);
DLLLOCAL AbstractQoreNode* exec_internal(bool doBind, const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
protected:
DLLEXPORT void freeConnectionValues();
DLLEXPORT void setConnectionValues();
DLLEXPORT void setTransactionStatus(bool);
DLLEXPORT void setPendingConnectionValues(const Datasource* other);
DLLEXPORT int beginImplicitTransaction(ExceptionSink* xsink);
public:
DLLEXPORT Datasource(DBIDriver* driver);
DLLEXPORT Datasource(const Datasource& old);
DLLEXPORT virtual ~Datasource();
DLLEXPORT bool getAutoCommit() const;
DLLEXPORT const char* getUsername() const;
DLLEXPORT const char* getPassword() const;
DLLEXPORT const char* getDBName() const;
DLLEXPORT const char* getDBEncoding() const;
DLLEXPORT const char* getOSEncoding() const;
DLLEXPORT const char* getHostName() const;
DLLEXPORT int getPort() const;
DLLEXPORT const std::string& getUsernameStr() const;
DLLEXPORT const std::string& getPasswordStr() const;
DLLEXPORT const std::string& getDBNameStr() const;
DLLEXPORT const std::string& getDBEncodingStr() const;
DLLEXPORT const std::string& getHostNameStr() const;
DLLEXPORT void* getPrivateData() const;
template <typename T>
DLLLOCAL T* getPrivateData() const {
return reinterpret_cast<T*>(getPrivateData());
}
template <typename T>
DLLLOCAL T& getPrivateDataRef() const {
return *getPrivateData<T>();
}
DLLEXPORT void setPrivateData(void* data);
DLLEXPORT void setDBEncoding(const char* name);
DLLEXPORT const QoreEncoding* getQoreEncoding() const;
DLLEXPORT void setQoreEncoding(const QoreEncoding* enc);
DLLEXPORT void setQoreEncoding(const char* name);
DLLEXPORT void setPendingUsername(const char* u);
DLLEXPORT void setPendingPassword(const char* p);
DLLEXPORT void setPendingDBName(const char* d);
DLLEXPORT void setPendingDBEncoding(const char* c);
DLLEXPORT void setPendingHostName(const char* h);
DLLEXPORT void setPendingPort(int port);
DLLEXPORT void setAutoCommit(bool ac);
DLLEXPORT int open(ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* select(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* selectRows(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT QoreHashNode* selectRow(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* exec(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* execRaw(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* execRaw(const QoreString* query_str, ExceptionSink* xsink);
DLLEXPORT int commit(ExceptionSink* xsink);
DLLEXPORT int rollback(ExceptionSink* xsink);
DLLEXPORT int close();
DLLEXPORT void reset(ExceptionSink* xsink);
DLLEXPORT QoreListNode* getCapabilityList() const;
DLLEXPORT int getCapabilities() const;
DLLEXPORT QoreStringNode* getPendingUsername() const;
DLLEXPORT QoreStringNode* getPendingPassword() const;
DLLEXPORT QoreStringNode* getPendingDBName() const;
DLLEXPORT QoreStringNode* getPendingDBEncoding() const;
DLLEXPORT QoreStringNode* getPendingHostName() const;
DLLEXPORT int getPendingPort() const;
DLLEXPORT int beginTransaction(ExceptionSink* xsink);
DLLEXPORT bool isInTransaction() const;
DLLEXPORT bool activeTransaction() const;
DLLEXPORT bool isOpen() const;
DLLEXPORT Datasource* copy() const;
DLLEXPORT const char* getDriverName() const;
DLLEXPORT AbstractQoreNode* getServerVersion(ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* getClientVersion(ExceptionSink* xsink) const;
DLLEXPORT const DBIDriver* getDriver() const;
DLLEXPORT void connectionAborted();
DLLEXPORT bool wasConnectionAborted() const;
DLLEXPORT int autoCommit(ExceptionSink* xsink);
DLLEXPORT QoreHashNode* getOptionHash() const;
DLLEXPORT int setOption(const char* opt, const AbstractQoreNode* val, ExceptionSink* xsink);
DLLEXPORT AbstractQoreNode* getOption(const char* opt, ExceptionSink* xsink);
DLLEXPORT const QoreHashNode* getConnectOptions() const;
};
#endif // _QORE_DATASOURCE_H