+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////\r
-//\r
-// File : $Id: _ibpp.h,v 1.2 2007/05/17 08:37:05 faust Exp $\r
-// Subject : IBPP internal declarations\r
-//\r
-///////////////////////////////////////////////////////////////////////////////\r
-//\r
-// (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org)\r
-//\r
-// The contents of this file are subject to the IBPP License (the "License");\r
-// you may not use this file except in compliance with the License. You may\r
-// obtain a copy of the License at http://www.ibpp.org or in the 'license.txt'\r
-// file which must have been distributed along with this file.\r
-//\r
-// This software, distributed under the License, is distributed on an "AS IS"\r
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\r
-// License for the specific language governing rights and limitations\r
-// under the License.\r
-//\r
-///////////////////////////////////////////////////////////////////////////////\r
-//\r
-// COMMENTS\r
-//\r
-// * 'Internal declarations' means everything used to implement ibpp. This\r
-// file and its contents is NOT needed by users of the library. All those\r
-// declarations are wrapped in a namespace : 'ibpp_internals'.\r
-// * Tabulations should be set every four characters when editing this file.\r
-//\r
-///////////////////////////////////////////////////////////////////////////////\r
-\r
-#ifndef __INTERNAL_IBPP_H__\r
-#define __INTERNAL_IBPP_H__\r
-\r
-#include "stg/ibpp.h"\r
-\r
-#if defined(__BCPLUSPLUS__) || defined(_MSC_VER) || defined(__DMC__)\r
-#define HAS_HDRSTOP\r
-#endif\r
-\r
-#if (defined(__GNUC__) && defined(IBPP_WINDOWS))\r
-// Setting flags for ibase.h -- using GCC/Cygwin/MinGW on Win32\r
-#ifndef _MSC_VER\r
-#define _MSC_VER 1299\r
-#endif\r
-#ifndef _WIN32\r
-#define _WIN32 1\r
-#endif\r
-#endif\r
-\r
-#include "ibase.h" // From Firebird 1.x or InterBase 6.x installation\r
-\r
-#if (defined(__GNUC__) && defined(IBPP_WINDOWS))\r
-// UNSETTING flags used above for ibase.h -- Huge conflicts with libstdc++ !\r
-#undef _MSC_VER\r
-#undef _WIN32\r
-#endif\r
-\r
-#ifdef IBPP_WINDOWS\r
-#include <windows.h>\r
-#endif\r
-\r
-//#include <limits>\r
-#include <string>\r
-#include <vector>\r
-#include <sstream>\r
-#include <cstdarg>\r
-\r
-#ifdef _DEBUG\r
-#define ASSERTION(x) {if (!(x)) {throw LogicExceptionImpl("ASSERTION", \\r
- "'"#x"' is not verified at %s, line %d", \\r
- __FILE__, __LINE__);}}\r
-#else\r
-#define ASSERTION(x) /* x */\r
-#endif\r
-\r
-// Fix to famous MSVC 6 variable scope bug\r
-#if defined(_MSC_VER) && (_MSC_VER < 1300) // MSVC 6 should be < 1300\r
-#define for if(true)for\r
-#endif\r
-\r
-namespace ibpp_internals\r
-{\r
-\r
-enum flush_debug_stream_type {fds};\r
-\r
-#ifdef _DEBUG\r
-\r
-struct DebugStream : public std::stringstream\r
-{\r
- // next two operators fix some g++ and vc++ related problems\r
- std::ostream& operator<< (const char* p)\r
- { static_cast<std::stringstream&>(*this)<< p; return *this; }\r
-\r
- std::ostream& operator<< (const std::string& p)\r
- { static_cast<std::stringstream&>(*this)<< p; return *this; }\r
-\r
- DebugStream& operator=(const DebugStream&) {return *this;}\r
- DebugStream(const DebugStream&) {}\r
- DebugStream() {}\r
-};\r
-std::ostream& operator<< (std::ostream& a, flush_debug_stream_type);\r
-\r
-#else\r
-\r
-struct DebugStream\r
-{\r
- template<class T> DebugStream& operator<< (const T&) { return *this; }\r
- // for manipulators\r
- DebugStream& operator<< (std::ostream&(*)(std::ostream&)) { return *this; }\r
-};\r
-\r
-#endif // _DEBUG\r
-\r
-class DatabaseImpl;\r
-class TransactionImpl;\r
-class StatementImpl;\r
-class BlobImpl;\r
-class ArrayImpl;\r
-class EventsImpl;\r
-\r
-// Native data types\r
-typedef enum {ivArray, ivBlob, ivDate, ivTime, ivTimestamp, ivString,\r
- ivInt16, ivInt32, ivInt64, ivFloat, ivDouble,\r
- ivBool, ivDBKey, ivByte} IITYPE;\r
-\r
-//\r
-// Those are the Interbase C API prototypes that we use\r
-// Taken 'asis' from IBASE.H, prefix 'isc_' replaced with 'proto_',\r
-// and 'typedef' preprended...\r
-//\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_create_database (ISC_STATUS *,\r
- short,\r
- char *,\r
- isc_db_handle *,\r
- short,\r
- char *,\r
- short);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_attach_database (ISC_STATUS *,\r
- short,\r
- char *,\r
- isc_db_handle *,\r
- short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_detach_database (ISC_STATUS *,\r
- isc_db_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_drop_database (ISC_STATUS *,\r
- isc_db_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_database_info (ISC_STATUS *,\r
- isc_db_handle *,\r
- short,\r
- char *,\r
- short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_execute_immediate (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- unsigned short,\r
- char *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_open_blob2 (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- isc_blob_handle *,\r
- ISC_QUAD *,\r
- short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_create_blob2 (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- isc_blob_handle *,\r
- ISC_QUAD *,\r
- short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_close_blob (ISC_STATUS *,\r
- isc_blob_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_cancel_blob (ISC_STATUS *,\r
- isc_blob_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_get_segment (ISC_STATUS *,\r
- isc_blob_handle *,\r
- unsigned short *,\r
- unsigned short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_put_segment (ISC_STATUS *,\r
- isc_blob_handle *,\r
- unsigned short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_blob_info (ISC_STATUS *,\r
- isc_blob_handle *,\r
- short,\r
- char *,\r
- short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_array_lookup_bounds (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- char *,\r
- char *,\r
- ISC_ARRAY_DESC *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_array_get_slice (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- ISC_QUAD *,\r
- ISC_ARRAY_DESC *,\r
- void *,\r
- ISC_LONG *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_array_put_slice (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_tr_handle *,\r
- ISC_QUAD *,\r
- ISC_ARRAY_DESC *,\r
- void *,\r
- ISC_LONG *);\r
-\r
-typedef ISC_LONG ISC_EXPORT proto_vax_integer (char *,\r
- short);\r
-\r
-typedef ISC_LONG ISC_EXPORT proto_sqlcode (ISC_STATUS *);\r
-\r
-typedef void ISC_EXPORT proto_sql_interprete (short,\r
- char *,\r
- short);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_interprete (char *,\r
- ISC_STATUS * *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_que_events (ISC_STATUS *,\r
- isc_db_handle *,\r
- ISC_LONG *,\r
- short,\r
- char *,\r
- isc_callback,\r
- void *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_cancel_events (ISC_STATUS *,\r
- isc_db_handle *,\r
- ISC_LONG *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_start_multiple (ISC_STATUS *,\r
- isc_tr_handle *,\r
- short,\r
- void *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_commit_transaction (ISC_STATUS *,\r
- isc_tr_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_commit_retaining (ISC_STATUS *,\r
- isc_tr_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_rollback_transaction (ISC_STATUS *,\r
- isc_tr_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_rollback_retaining (ISC_STATUS *,\r
- isc_tr_handle *);\r
-\r
-///////////\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_allocate_statement (ISC_STATUS *,\r
- isc_db_handle *,\r
- isc_stmt_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_describe (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_describe_bind (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_execute (ISC_STATUS *,\r
- isc_tr_handle *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_execute2 (ISC_STATUS *,\r
- isc_tr_handle *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- XSQLDA *,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_fetch (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_free_statement (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- unsigned short);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_prepare (ISC_STATUS *,\r
- isc_tr_handle *,\r
- isc_stmt_handle *,\r
- unsigned short,\r
- char *,\r
- unsigned short,\r
- XSQLDA *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_set_cursor_name (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- char *,\r
- unsigned short);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_dsql_sql_info (ISC_STATUS *,\r
- isc_stmt_handle *,\r
- short,\r
- char *,\r
- short,\r
- char *);\r
-\r
-typedef void ISC_EXPORT proto_decode_date (ISC_QUAD *,\r
- void *);\r
-\r
-typedef void ISC_EXPORT proto_encode_date (void *,\r
- ISC_QUAD *);\r
-\r
-typedef int ISC_EXPORT proto_add_user (ISC_STATUS *, USER_SEC_DATA *);\r
-typedef int ISC_EXPORT proto_delete_user (ISC_STATUS *, USER_SEC_DATA *);\r
-typedef int ISC_EXPORT proto_modify_user (ISC_STATUS *, USER_SEC_DATA *);\r
-\r
-//\r
-// Those API are only available in versions 6.x of the GDS32.DLL\r
-//\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_service_attach (ISC_STATUS *,\r
- unsigned short,\r
- char *,\r
- isc_svc_handle *,\r
- unsigned short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_service_detach (ISC_STATUS *,\r
- isc_svc_handle *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_service_query (ISC_STATUS *,\r
- isc_svc_handle *,\r
- isc_resv_handle *,\r
- unsigned short,\r
- char *,\r
- unsigned short,\r
- char *,\r
- unsigned short,\r
- char *);\r
-\r
-typedef ISC_STATUS ISC_EXPORT proto_service_start (ISC_STATUS *,\r
- isc_svc_handle *,\r
- isc_resv_handle *,\r
- unsigned short,\r
- char*);\r
-\r
-typedef void ISC_EXPORT proto_decode_sql_date (ISC_DATE *,\r
- void *);\r
-\r
-typedef void ISC_EXPORT proto_decode_sql_time (ISC_TIME *,\r
- void *);\r
-\r
-typedef void ISC_EXPORT proto_decode_timestamp (ISC_TIMESTAMP *,\r
- void *);\r
-\r
-typedef void ISC_EXPORT proto_encode_sql_date (void *,\r
- ISC_DATE *);\r
-\r
-typedef void ISC_EXPORT proto_encode_sql_time (void *,\r
- ISC_TIME *);\r
-\r
-typedef void ISC_EXPORT proto_encode_timestamp (void *,\r
- ISC_TIMESTAMP *);\r
-\r
-//\r
-// Internal binding structure to the GDS32 DLL\r
-//\r
-\r
-struct GDS\r
-{\r
- // Attributes\r
- bool mReady;\r
- int mGDSVersion; // Version of the GDS32.DLL (50 for 5.0, 60 for 6.0)\r
-\r
-#ifdef IBPP_WINDOWS\r
- HMODULE mHandle; // The GDS32.DLL HMODULE\r
- std::string mSearchPaths; // Optional additional search paths\r
-#endif\r
-\r
- GDS* Call();\r
-\r
- // GDS32 Entry Points\r
- proto_create_database* m_create_database;\r
- proto_attach_database* m_attach_database;\r
- proto_detach_database* m_detach_database;\r
- proto_drop_database* m_drop_database;\r
- proto_database_info* m_database_info;\r
- proto_dsql_execute_immediate* m_dsql_execute_immediate;\r
- proto_open_blob2* m_open_blob2;\r
- proto_create_blob2* m_create_blob2;\r
- proto_close_blob* m_close_blob;\r
- proto_cancel_blob* m_cancel_blob;\r
- proto_get_segment* m_get_segment;\r
- proto_put_segment* m_put_segment;\r
- proto_blob_info* m_blob_info;\r
- proto_array_lookup_bounds* m_array_lookup_bounds;\r
- proto_array_get_slice* m_array_get_slice;\r
- proto_array_put_slice* m_array_put_slice;\r
-\r
- proto_vax_integer* m_vax_integer;\r
- proto_sqlcode* m_sqlcode;\r
- proto_sql_interprete* m_sql_interprete;\r
- proto_interprete* m_interprete;\r
- proto_que_events* m_que_events;\r
- proto_cancel_events* m_cancel_events;\r
- proto_start_multiple* m_start_multiple;\r
- proto_commit_transaction* m_commit_transaction;\r
- proto_commit_retaining* m_commit_retaining;\r
- proto_rollback_transaction* m_rollback_transaction;\r
- proto_rollback_retaining* m_rollback_retaining;\r
- proto_dsql_allocate_statement* m_dsql_allocate_statement;\r
- proto_dsql_describe* m_dsql_describe;\r
- proto_dsql_describe_bind* m_dsql_describe_bind;\r
- proto_dsql_prepare* m_dsql_prepare;\r
- proto_dsql_execute* m_dsql_execute;\r
- proto_dsql_execute2* m_dsql_execute2;\r
- proto_dsql_fetch* m_dsql_fetch;\r
- proto_dsql_free_statement* m_dsql_free_statement;\r
- proto_dsql_set_cursor_name* m_dsql_set_cursor_name;\r
- proto_dsql_sql_info* m_dsql_sql_info;\r
- //proto_decode_date* m_decode_date;\r
- //proto_encode_date* m_encode_date;\r
- //proto_add_user* m_add_user;\r
- //proto_delete_user* m_delete_user;\r
- //proto_modify_user* m_modify_user;\r
-\r
- proto_service_attach* m_service_attach;\r
- proto_service_detach* m_service_detach;\r
- proto_service_start* m_service_start;\r
- proto_service_query* m_service_query;\r
- //proto_decode_sql_date* m_decode_sql_date;\r
- //proto_decode_sql_time* m_decode_sql_time;\r
- //proto_decode_timestamp* m_decode_timestamp;\r
- //proto_encode_sql_date* m_encode_sql_date;\r
- //proto_encode_sql_time* m_encode_sql_time;\r
- //proto_encode_timestamp* m_encode_timestamp;\r
-\r
- // Constructor (No need for a specific destructor)\r
- GDS()\r
- {\r
- mReady = false;\r
- mGDSVersion = 0;\r
-#ifdef IBPP_WINDOWS\r
- mHandle = 0;\r
-#endif\r
- }\r
-};\r
-\r
-extern GDS gds;\r
-\r
-//\r
-// Service Parameter Block (used to define a service)\r
-//\r
-\r
-class SPB\r
-{\r
- static const int BUFFERINCR;\r
-\r
- char* mBuffer; // Dynamically allocated SPB structure\r
- int mSize; // Its used size in bytes\r
- int mAlloc; // Its allocated size in bytes\r
-\r
- void Grow(int needed); // Alloc or grow the mBuffer\r
-\r
-public:\r
- void Insert(char); // Insert a single byte code\r
- void InsertString(char, int, const char*); // Insert a string, len can be defined as 1 or 2 bytes\r
- void InsertByte(char type, char data);\r
- void InsertQuad(char type, int32_t data);\r
- void Reset(); // Clears the SPB\r
- char* Self() { return mBuffer; }\r
- short Size() { return (short)mSize; }\r
-\r
- SPB() : mBuffer(0), mSize(0), mAlloc(0) { }\r
- ~SPB() { Reset(); }\r
-};\r
-\r
-//\r
-// Database Parameter Block (used to define a database)\r
-//\r
-\r
-class DPB\r
-{\r
- static const int BUFFERINCR;\r
-\r
- char* mBuffer; // Dynamically allocated DPB structure\r
- int mSize; // Its used size in bytes\r
- int mAlloc; // Its allocated size in bytes\r
-\r
- void Grow(int needed); // Allocate or grow the mBuffer, so that\r
- // 'needed' bytes can be written (at least)\r
-\r
-public:\r
- void Insert(char, const char*); // Insert a new char* 'cluster'\r
- void Insert(char, int16_t); // Insert a new int16_t 'cluster'\r
- void Insert(char, bool); // Insert a new bool 'cluster'\r
- void Insert(char, char); // Insert a new byte 'cluster'\r
- void Reset(); // Clears the DPB\r
- char* Self() { return mBuffer; }\r
- short Size() { return (short)mSize; }\r
-\r
- DPB() : mBuffer(0), mSize(0), mAlloc(0) { }\r
- ~DPB() { Reset(); }\r
-};\r
-\r
-//\r
-// Transaction Parameter Block (used to define a transaction)\r
-//\r
-\r
-class TPB\r
-{\r
- static const int BUFFERINCR;\r
-\r
- char* mBuffer; // Dynamically allocated TPB structure\r
- int mSize; // Its used size in bytes\r
- int mAlloc; // Its allocated size\r
-\r
- void Grow(int needed); // Alloc or re-alloc the mBuffer\r
-\r
-public:\r
- void Insert(char); // Insert a flag item\r
- void Insert(const std::string& data); // Insert a string (typically table name)\r
- void Reset(); // Clears the TPB\r
- char* Self() { return mBuffer; }\r
- int Size() { return mSize; }\r
-\r
- TPB() : mBuffer(0), mSize(0), mAlloc(0) { }\r
- ~TPB() { Reset(); }\r
-};\r
-\r
-//\r
-// Used to receive (and process) a results buffer in various API calls\r
-//\r
-\r
-class RB\r
-{\r
- char* mBuffer;\r
- int mSize;\r
-\r
- char* FindToken(char token);\r
- char* FindToken(char token, char subtoken);\r
-\r
-public:\r
- void Reset();\r
- int GetValue(char token);\r
- int GetCountValue(char token);\r
- int GetValue(char token, char subtoken);\r
- bool GetBool(char token);\r
- int GetString(char token, std::string& data);\r
-\r
- char* Self() { return mBuffer; }\r
- short Size() { return (short)mSize; }\r
-\r
- RB();\r
- RB(int Size);\r
- ~RB();\r
-};\r
-\r
-//\r
-// Used to receive status info from API calls\r
-//\r
-\r
-class IBS\r
-{\r
- mutable ISC_STATUS mVector[20];\r
- mutable std::string mMessage;\r
-\r
-public:\r
- ISC_STATUS* Self() { return mVector; }\r
- bool Errors() { return (mVector[0] == 1 && mVector[1] > 0) ? true : false; }\r
- const char* ErrorMessage() const;\r
- int SqlCode() const;\r
- int EngineCode() const { return (mVector[0] == 1) ? (int)mVector[1] : 0; }\r
- void Reset();\r
-\r
- IBS();\r
- IBS(IBS&); // Copy Constructor\r
- ~IBS();\r
-};\r
-\r
-///////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Implementation of the "hidden" classes associated with their public\r
-// counterparts. Their private data and methods can freely change without\r
-// breaking the compatibility of the DLL. If they receive new public methods,\r
-// and those methods are reflected in the public class, then the compatibility\r
-// is broken.\r
-//\r
-///////////////////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Hidden implementation of Exception classes.\r
-//\r
-\r
-/*\r
- std::exception\r
- |\r
- IBPP::Exception\r
- / \\r
- / \\r
- IBPP::LogicException ExceptionBase IBPP::SQLException\r
- | \ / | \ /\r
- | LogicExceptionImpl | SQLExceptionImpl\r
- | |\r
- IBPP::WrongType |\r
- \ |\r
- IBPP::WrongTypeImpl\r
-*/\r
-\r
-class ExceptionBase\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-protected:\r
- std::string mContext; // Exception context ("IDatabase::Drop")\r
- std::string mWhat; // Full formatted message\r
-\r
- void buildErrorMessage(const char* message);\r
- void raise(const std::string& context, const char* message, va_list argptr);\r
-\r
-public:\r
- // The following constructors are small and could be inlined, but for object\r
- // code compacity of the library it is much better to have them non-inlined.\r
- // The amount of code generated by compilers for a throw is well-enough.\r
-\r
- ExceptionBase() throw();\r
- ExceptionBase(const ExceptionBase& copied) throw();\r
- ExceptionBase& operator=(const ExceptionBase& copied) throw();\r
- ExceptionBase(const std::string& context, const char* message = 0, ...) throw();\r
-\r
- virtual ~ExceptionBase() throw();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
- virtual const char* Origin() const throw();\r
- virtual const char* ErrorMessage() const throw();\r
- virtual const char* what() const throw();\r
-};\r
-\r
-class LogicExceptionImpl : public IBPP::LogicException, public ExceptionBase\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-public:\r
- // The following constructors are small and could be inlined, but for object\r
- // code compacity of the library it is much better to have them non-inlined.\r
- // The amount of code generated by compilers for a throw is well-enough.\r
-\r
- LogicExceptionImpl() throw();\r
- LogicExceptionImpl(const LogicExceptionImpl& copied) throw();\r
- LogicExceptionImpl& operator=(const LogicExceptionImpl& copied) throw();\r
- LogicExceptionImpl(const std::string& context, const char* message = 0, ...) throw();\r
-\r
- virtual ~LogicExceptionImpl() throw ();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
- //\r
- // The object public interface is partly implemented by inheriting from\r
- // the ExceptionBase class.\r
-\r
-public:\r
- virtual const char* Origin() const throw();\r
- virtual const char* ErrorMessage() const throw();\r
- virtual const char* what() const throw();\r
-};\r
-\r
-class SQLExceptionImpl : public IBPP::SQLException, public ExceptionBase\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- int mSqlCode;\r
- int mEngineCode;\r
-\r
-public:\r
- // The following constructors are small and could be inlined, but for object\r
- // code compacity of the library it is much better to have them non-inlined.\r
- // The amount of code generated by compilers for a throw is well-enough.\r
-\r
- SQLExceptionImpl() throw();\r
- SQLExceptionImpl(const SQLExceptionImpl& copied) throw();\r
- SQLExceptionImpl& operator=(const SQLExceptionImpl& copied) throw();\r
- SQLExceptionImpl(const IBS& status, const std::string& context,\r
- const char* message = 0, ...) throw();\r
-\r
- virtual ~SQLExceptionImpl() throw ();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
- //\r
- // The object public interface is partly implemented by inheriting from\r
- // the ExceptionBase class.\r
-\r
-public:\r
- virtual const char* Origin() const throw();\r
- virtual const char* ErrorMessage() const throw();\r
- virtual const char* what() const throw();\r
- virtual int SqlCode() const throw();\r
- virtual int EngineCode() const throw();\r
-};\r
-\r
-class WrongTypeImpl : public IBPP::WrongType, public ExceptionBase\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-public:\r
- // The following constructors are small and could be inlined, but for object\r
- // code compacity of the library it is much better to have them non-inlined.\r
- // The amount of code generated by compilers for a throw is well-enough.\r
-\r
- WrongTypeImpl() throw();\r
- WrongTypeImpl(const WrongTypeImpl& copied) throw();\r
- WrongTypeImpl& operator=(const WrongTypeImpl& copied) throw();\r
- WrongTypeImpl(const std::string& context, int sqlType, IITYPE varType,\r
- const char* message = 0, ...) throw();\r
-\r
- virtual ~WrongTypeImpl() throw ();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
- //\r
- // The object public interface is partly implemented by inheriting from\r
- // the ExceptionBase class.\r
-\r
-public:\r
- virtual const char* Origin() const throw();\r
- virtual const char* ErrorMessage() const throw();\r
- virtual const char* what() const throw();\r
-};\r
-\r
-class ServiceImpl : public IBPP::IService\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- int mRefCount; // Reference counter\r
- isc_svc_handle mHandle; // InterBase API Service Handle\r
- std::string mServerName; // Nom du serveur\r
- std::string mUserName; // Nom de l'utilisateur\r
- std::string mUserPassword; // Mot de passe de l'utilisateur\r
- std::string mWaitMessage; // Progress message returned by WaitMsg()\r
-\r
- isc_svc_handle* GetHandlePtr() { return &mHandle; }\r
- void SetServerName(const char*);\r
- void SetUserName(const char*);\r
- void SetUserPassword(const char*);\r
-\r
-public:\r
- isc_svc_handle GetHandle() { return mHandle; }\r
-\r
- ServiceImpl(const std::string& ServerName, const std::string& UserName,\r
- const std::string& UserPassword);\r
- ~ServiceImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void Connect();\r
- bool Connected() { return mHandle == 0 ? false : true; }\r
- void Disconnect();\r
-\r
- void GetVersion(std::string& version);\r
-\r
- void AddUser(const IBPP::User&);\r
- void GetUser(IBPP::User&);\r
- void GetUsers(std::vector<IBPP::User>&);\r
- void ModifyUser(const IBPP::User&);\r
- void RemoveUser(const std::string& username);\r
-\r
- void SetPageBuffers(const std::string& dbfile, int buffers);\r
- void SetSweepInterval(const std::string& dbfile, int sweep);\r
- void SetSyncWrite(const std::string& dbfile, bool);\r
- void SetReadOnly(const std::string& dbfile, bool);\r
- void SetReserveSpace(const std::string& dbfile, bool);\r
-\r
- void Shutdown(const std::string& dbfile, IBPP::DSM mode, int sectimeout);\r
- void Restart(const std::string& dbfile);\r
- void Sweep(const std::string& dbfile);\r
- void Repair(const std::string& dbfile, IBPP::RPF flags);\r
-\r
- void StartBackup(const std::string& dbfile, const std::string& bkfile,\r
- IBPP::BRF flags = IBPP::BRF(0));\r
- void StartRestore(const std::string& bkfile, const std::string& dbfile,\r
- int pagesize, IBPP::BRF flags = IBPP::BRF(0));\r
-\r
- const char* WaitMsg();\r
- void Wait();\r
-\r
- IBPP::IService* AddRef();\r
- void Release();\r
-};\r
-\r
-class DatabaseImpl : public IBPP::IDatabase\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
- int mRefCount; // Reference counter\r
- isc_db_handle mHandle; // InterBase API Session Handle\r
- std::string mServerName; // Server name\r
- std::string mDatabaseName; // Database name (path/file)\r
- std::string mUserName; // User name\r
- std::string mUserPassword; // User password\r
- std::string mRoleName; // Role used for the duration of the connection\r
- std::string mCharSet; // Character Set used for the connection\r
- std::string mCreateParams; // Other parameters (creation only)\r
-\r
- int mDialect; // 1 if IB5, 1 or 3 if IB6/FB1\r
- std::vector<TransactionImpl*> mTransactions;// Table of Transaction*\r
- std::vector<StatementImpl*> mStatements;// Table of Statement*\r
- std::vector<BlobImpl*> mBlobs; // Table of Blob*\r
- std::vector<ArrayImpl*> mArrays; // Table of Array*\r
- std::vector<EventsImpl*> mEvents; // Table of Events*\r
-\r
-public:\r
- isc_db_handle* GetHandlePtr() { return &mHandle; }\r
- isc_db_handle GetHandle() { return mHandle; }\r
-\r
- void AttachTransactionImpl(TransactionImpl*);\r
- void DetachTransactionImpl(TransactionImpl*);\r
- void AttachStatementImpl(StatementImpl*);\r
- void DetachStatementImpl(StatementImpl*);\r
- void AttachBlobImpl(BlobImpl*);\r
- void DetachBlobImpl(BlobImpl*);\r
- void AttachArrayImpl(ArrayImpl*);\r
- void DetachArrayImpl(ArrayImpl*);\r
- void AttachEventsImpl(EventsImpl*);\r
- void DetachEventsImpl(EventsImpl*);\r
-\r
- DatabaseImpl(const std::string& ServerName, const std::string& DatabaseName,\r
- const std::string& UserName, const std::string& UserPassword,\r
- const std::string& RoleName, const std::string& CharSet,\r
- const std::string& CreateParams);\r
- ~DatabaseImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- const char* ServerName() const { return mServerName.c_str(); }\r
- const char* DatabaseName() const { return mDatabaseName.c_str(); }\r
- const char* Username() const { return mUserName.c_str(); }\r
- const char* UserPassword() const { return mUserPassword.c_str(); }\r
- const char* RoleName() const { return mRoleName.c_str(); }\r
- const char* CharSet() const { return mCharSet.c_str(); }\r
- const char* CreateParams() const { return mCreateParams.c_str(); }\r
-\r
- void Info(int* ODSMajor, int* ODSMinor,\r
- int* PageSize, int* Pages, int* Buffers, int* Sweep,\r
- bool* SyncWrites, bool* Reserve);\r
- void Statistics(int* Fetches, int* Marks, int* Reads, int* Writes);\r
- void Counts(int* Insert, int* Update, int* Delete,\r
- int* ReadIdx, int* ReadSeq);\r
- void Users(std::vector<std::string>& users);\r
- int Dialect() { return mDialect; }\r
-\r
- void Create(int dialect);\r
- void Connect();\r
- bool Connected() { return mHandle == 0 ? false : true; }\r
- void Inactivate();\r
- void Disconnect();\r
- void Drop();\r
-\r
- IBPP::IDatabase* AddRef();\r
- void Release();\r
-};\r
-\r
-class TransactionImpl : public IBPP::ITransaction\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- int mRefCount; // Reference counter\r
- isc_tr_handle mHandle; // Transaction InterBase\r
-\r
- std::vector<DatabaseImpl*> mDatabases; // Tableau de IDatabase*\r
- std::vector<StatementImpl*> mStatements; // Tableau de IStatement*\r
- std::vector<BlobImpl*> mBlobs; // Tableau de IBlob*\r
- std::vector<ArrayImpl*> mArrays; // Tableau de Array*\r
- std::vector<TPB*> mTPBs; // Tableau de TPB\r
-\r
- void Init(); // A usage exclusif des constructeurs\r
-\r
-public:\r
- isc_tr_handle* GetHandlePtr() { return &mHandle; }\r
- isc_tr_handle GetHandle() { return mHandle; }\r
-\r
- void AttachStatementImpl(StatementImpl*);\r
- void DetachStatementImpl(StatementImpl*);\r
- void AttachBlobImpl(BlobImpl*);\r
- void DetachBlobImpl(BlobImpl*);\r
- void AttachArrayImpl(ArrayImpl*);\r
- void DetachArrayImpl(ArrayImpl*);\r
- void AttachDatabaseImpl(DatabaseImpl* dbi, IBPP::TAM am = IBPP::amWrite,\r
- IBPP::TIL il = IBPP::ilConcurrency,\r
- IBPP::TLR lr = IBPP::lrWait, IBPP::TFF flags = IBPP::TFF(0));\r
- void DetachDatabaseImpl(DatabaseImpl* dbi);\r
-\r
- TransactionImpl(DatabaseImpl* db, IBPP::TAM am = IBPP::amWrite,\r
- IBPP::TIL il = IBPP::ilConcurrency,\r
- IBPP::TLR lr = IBPP::lrWait, IBPP::TFF flags = IBPP::TFF(0));\r
- ~TransactionImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void AttachDatabase(IBPP::Database db, IBPP::TAM am = IBPP::amWrite,\r
- IBPP::TIL il = IBPP::ilConcurrency,\r
- IBPP::TLR lr = IBPP::lrWait, IBPP::TFF flags = IBPP::TFF(0));\r
- void DetachDatabase(IBPP::Database db);\r
- void AddReservation(IBPP::Database db,\r
- const std::string& table, IBPP::TTR tr);\r
-\r
- void Start();\r
- bool Started() { return mHandle == 0 ? false : true; }\r
- void Commit();\r
- void Rollback();\r
- void CommitRetain();\r
- void RollbackRetain();\r
-\r
- IBPP::ITransaction* AddRef();\r
- void Release();\r
-};\r
-\r
-class RowImpl : public IBPP::IRow\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- int mRefCount; // Reference counter\r
-\r
- XSQLDA* mDescrArea; // XSQLDA descriptor itself\r
- std::vector<double> mNumerics; // Temporary storage for Numerics\r
- std::vector<float> mFloats; // Temporary storage for Floats\r
- std::vector<int64_t> mInt64s; // Temporary storage for 64 bits\r
- std::vector<int32_t> mInt32s; // Temporary storage for 32 bits\r
- std::vector<int16_t> mInt16s; // Temporary storage for 16 bits\r
- std::vector<char> mBools; // Temporary storage for Bools\r
- std::vector<std::string> mStrings; // Temporary storage for Strings\r
- std::vector<bool> mUpdated; // Which columns where updated (Set()) ?\r
-\r
- int mDialect; // Related database dialect\r
- DatabaseImpl* mDatabase; // Related Database (important for Blobs, ...)\r
- TransactionImpl* mTransaction; // Related Transaction (same remark)\r
-\r
- void SetValue(int, IITYPE, const void* value, int = 0);\r
- void* GetValue(int, IITYPE, void* = 0);\r
-\r
-public:\r
- void Free();\r
- short AllocatedSize() { return mDescrArea->sqln; }\r
- void Resize(int n);\r
- void AllocVariables();\r
- bool MissingValues(); // Returns wether one of the mMissing[] is true\r
- XSQLDA* Self() { return mDescrArea; }\r
-\r
- RowImpl& operator=(const RowImpl& copied);\r
- RowImpl(const RowImpl& copied);\r
- RowImpl(int dialect, int size, DatabaseImpl* db, TransactionImpl* tr);\r
- ~RowImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void SetNull(int);\r
- void Set(int, bool);\r
- void Set(int, const char*); // c-strings\r
- void Set(int, const void*, int); // byte buffers\r
- void Set(int, const std::string&);\r
- void Set(int, int16_t);\r
- void Set(int, int32_t);\r
- void Set(int, int64_t);\r
- void Set(int, float);\r
- void Set(int, double);\r
- void Set(int, const IBPP::Timestamp&);\r
- void Set(int, const IBPP::Date&);\r
- void Set(int, const IBPP::Time&);\r
- void Set(int, const IBPP::DBKey&);\r
- void Set(int, const IBPP::Blob&);\r
- void Set(int, const IBPP::Array&);\r
-\r
- bool IsNull(int);\r
- bool Get(int, bool&);\r
- bool Get(int, char*); // c-strings, len unchecked\r
- bool Get(int, void*, int&); // byte buffers\r
- bool Get(int, std::string&);\r
- bool Get(int, int16_t&);\r
- bool Get(int, int32_t&);\r
- bool Get(int, int64_t&);\r
- bool Get(int, float&);\r
- bool Get(int, double&);\r
- bool Get(int, IBPP::Timestamp&);\r
- bool Get(int, IBPP::Date&);\r
- bool Get(int, IBPP::Time&);\r
- bool Get(int, IBPP::DBKey&);\r
- bool Get(int, IBPP::Blob&);\r
- bool Get(int, IBPP::Array&);\r
-\r
- bool IsNull(const std::string&);\r
- bool Get(const std::string&, bool&);\r
- bool Get(const std::string&, char*); // c-strings, len unchecked\r
- bool Get(const std::string&, void*, int&); // byte buffers\r
- bool Get(const std::string&, std::string&);\r
- bool Get(const std::string&, int16_t&);\r
- bool Get(const std::string&, int32_t&);\r
- bool Get(const std::string&, int64_t&);\r
- bool Get(const std::string&, float&);\r
- bool Get(const std::string&, double&);\r
- bool Get(const std::string&, IBPP::Timestamp&);\r
- bool Get(const std::string&, IBPP::Date&);\r
- bool Get(const std::string&, IBPP::Time&);\r
- bool Get(const std::string&, IBPP::DBKey&);\r
- bool Get(const std::string&, IBPP::Blob&);\r
- bool Get(const std::string&, IBPP::Array&);\r
-\r
- int ColumnNum(const std::string&);\r
- const char* ColumnName(int);\r
- const char* ColumnAlias(int);\r
- const char* ColumnTable(int);\r
- IBPP::SDT ColumnType(int);\r
- int ColumnSubtype(int);\r
- int ColumnSize(int);\r
- int ColumnScale(int);\r
- int Columns();\r
-\r
- bool ColumnUpdated(int);\r
- bool Updated();\r
-\r
- IBPP::Database DatabasePtr() const;\r
- IBPP::Transaction TransactionPtr() const;\r
-\r
- IBPP::IRow* Clone();\r
- IBPP::IRow* AddRef();\r
- void Release();\r
-};\r
-\r
-class StatementImpl : public IBPP::IStatement\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- friend class TransactionImpl;\r
-\r
- int mRefCount; // Reference counter\r
- isc_stmt_handle mHandle; // Statement Handle\r
-\r
- DatabaseImpl* mDatabase; // Attached database\r
- TransactionImpl* mTransaction; // Attached transaction\r
- RowImpl* mInRow;\r
- //bool* mInMissing; // Quels paramètres n'ont pas été spécifiés\r
- RowImpl* mOutRow;\r
- bool mResultSetAvailable; // Executed and result set is available\r
- bool mCursorOpened; // dsql_set_cursor_name was called\r
- IBPP::STT mType; // Type de requète\r
- std::string mSql; // Last SQL statement prepared or executed\r
-\r
- // Internal Methods\r
- void CursorFree();\r
-\r
-public:\r
- // Properties and Attributes Access Methods\r
- isc_stmt_handle GetHandle() { return mHandle; }\r
-\r
- void AttachDatabaseImpl(DatabaseImpl*);\r
- void DetachDatabaseImpl();\r
- void AttachTransactionImpl(TransactionImpl*);\r
- void DetachTransactionImpl();\r
-\r
- StatementImpl(DatabaseImpl*, TransactionImpl*, const std::string&);\r
- ~StatementImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void Prepare(const std::string& sql);\r
- void Execute(const std::string& sql);\r
- inline void Execute() { Execute(std::string()); }\r
- void ExecuteImmediate(const std::string&);\r
- void CursorExecute(const std::string& cursor, const std::string& sql);\r
- inline void CursorExecute(const std::string& cursor) { CursorExecute(cursor, std::string()); }\r
- bool Fetch();\r
- bool Fetch(IBPP::Row&);\r
- int AffectedRows();\r
- void Close(); // Free resources, attachments maintained\r
- std::string& Sql() { return mSql; }\r
- IBPP::STT Type() { return mType; }\r
-\r
- void SetNull(int);\r
- void Set(int, bool);\r
- void Set(int, const char*); // c-strings\r
- void Set(int, const void*, int); // byte buffers\r
- void Set(int, const std::string&);\r
- void Set(int, int16_t);\r
- void Set(int, int32_t);\r
- void Set(int, int64_t);\r
- void Set(int, float);\r
- void Set(int, double);\r
- void Set(int, const IBPP::Timestamp&);\r
- void Set(int, const IBPP::Date&);\r
- void Set(int, const IBPP::Time&);\r
- void Set(int, const IBPP::DBKey&);\r
- void Set(int, const IBPP::Blob&);\r
- void Set(int, const IBPP::Array&);\r
-\r
- bool IsNull(int);\r
- bool Get(int, bool*);\r
- bool Get(int, bool&);\r
- bool Get(int, char*); // c-strings, len unchecked\r
- bool Get(int, void*, int&); // byte buffers\r
- bool Get(int, std::string&);\r
- bool Get(int, int16_t*);\r
- bool Get(int, int16_t&);\r
- bool Get(int, int32_t*);\r
- bool Get(int, int32_t&);\r
- bool Get(int, int64_t*);\r
- bool Get(int, int64_t&);\r
- bool Get(int, float*);\r
- bool Get(int, float&);\r
- bool Get(int, double*);\r
- bool Get(int, double&);\r
- bool Get(int, IBPP::Timestamp&);\r
- bool Get(int, IBPP::Date&);\r
- bool Get(int, IBPP::Time&);\r
- bool Get(int, IBPP::DBKey&);\r
- bool Get(int, IBPP::Blob&);\r
- bool Get(int, IBPP::Array&);\r
-\r
- bool IsNull(const std::string&);\r
- bool Get(const std::string&, bool*);\r
- bool Get(const std::string&, bool&);\r
- bool Get(const std::string&, char*); // c-strings, len unchecked\r
- bool Get(const std::string&, void*, int&); // byte buffers\r
- bool Get(const std::string&, std::string&);\r
- bool Get(const std::string&, int16_t*);\r
- bool Get(const std::string&, int16_t&);\r
- bool Get(const std::string&, int32_t*);\r
- bool Get(const std::string&, int32_t&);\r
- bool Get(const std::string&, int64_t*);\r
- bool Get(const std::string&, int64_t&);\r
- bool Get(const std::string&, float*);\r
- bool Get(const std::string&, float&);\r
- bool Get(const std::string&, double*);\r
- bool Get(const std::string&, double&);\r
- bool Get(const std::string&, IBPP::Timestamp&);\r
- bool Get(const std::string&, IBPP::Date&);\r
- bool Get(const std::string&, IBPP::Time&);\r
- bool Get(const std::string&, IBPP::DBKey&);\r
- bool Get(const std::string&, IBPP::Blob&);\r
- bool Get(const std::string&, IBPP::Array&);\r
-\r
- int ColumnNum(const std::string&);\r
- int ColumnNumAlias(const std::string&);\r
- const char* ColumnName(int);\r
- const char* ColumnAlias(int);\r
- const char* ColumnTable(int);\r
- IBPP::SDT ColumnType(int);\r
- int ColumnSubtype(int);\r
- int ColumnSize(int);\r
- int ColumnScale(int);\r
- int Columns();\r
-\r
- IBPP::SDT ParameterType(int);\r
- int ParameterSubtype(int);\r
- int ParameterSize(int);\r
- int ParameterScale(int);\r
- int Parameters();\r
-\r
- void Plan(std::string&);\r
-\r
- IBPP::Database DatabasePtr() const;\r
- IBPP::Transaction TransactionPtr() const;\r
-\r
- IBPP::IStatement* AddRef();\r
- void Release();\r
-};\r
-\r
-class BlobImpl : public IBPP::IBlob\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- friend class RowImpl;\r
-\r
- int mRefCount;\r
- bool mIdAssigned;\r
- ISC_QUAD mId;\r
- isc_blob_handle mHandle;\r
- bool mWriteMode;\r
- DatabaseImpl* mDatabase; // Belongs to this database\r
- TransactionImpl* mTransaction; // Belongs to this transaction\r
-\r
- void Init();\r
- void SetId(ISC_QUAD*);\r
- void GetId(ISC_QUAD*);\r
-\r
-public:\r
- void AttachDatabaseImpl(DatabaseImpl*);\r
- void DetachDatabaseImpl();\r
- void AttachTransactionImpl(TransactionImpl*);\r
- void DetachTransactionImpl();\r
-\r
- BlobImpl(const BlobImpl&);\r
- BlobImpl(DatabaseImpl*, TransactionImpl* = 0);\r
- ~BlobImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void Create();\r
- void Open();\r
- void Close();\r
- void Cancel();\r
- int Read(void*, int size);\r
- void Write(const void*, int size);\r
- void Info(int* Size, int* Largest, int* Segments);\r
-\r
- void Save(const std::string& data);\r
- void Load(std::string& data);\r
-\r
- IBPP::Database DatabasePtr() const;\r
- IBPP::Transaction TransactionPtr() const;\r
-\r
- IBPP::IBlob* AddRef();\r
- void Release();\r
-};\r
-\r
-class ArrayImpl : public IBPP::IArray\r
-{\r
- // (((((((( OBJECT INTERNALS ))))))))\r
-\r
-private:\r
- friend class RowImpl;\r
-\r
- int mRefCount; // Reference counter\r
- bool mIdAssigned;\r
- ISC_QUAD mId;\r
- bool mDescribed;\r
- ISC_ARRAY_DESC mDesc;\r
- DatabaseImpl* mDatabase; // Database attachée\r
- TransactionImpl* mTransaction; // Transaction attachée\r
- void* mBuffer; // Buffer for native data\r
- int mBufferSize; // Size of this buffer in bytes\r
- int mElemCount; // Count of elements in this array\r
- int mElemSize; // Size of an element in the buffer\r
-\r
- void Init();\r
- void SetId(ISC_QUAD*);\r
- void GetId(ISC_QUAD*);\r
- void ResetId();\r
- void AllocArrayBuffer();\r
-\r
-public:\r
- void AttachDatabaseImpl(DatabaseImpl*);\r
- void DetachDatabaseImpl();\r
- void AttachTransactionImpl(TransactionImpl*);\r
- void DetachTransactionImpl();\r
-\r
- ArrayImpl(const ArrayImpl&);\r
- ArrayImpl(DatabaseImpl*, TransactionImpl* = 0);\r
- ~ArrayImpl();\r
-\r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void Describe(const std::string& table, const std::string& column);\r
- void ReadTo(IBPP::ADT, void*, int);\r
- void WriteFrom(IBPP::ADT, const void*, int);\r
- IBPP::SDT ElementType();\r
- int ElementSize();\r
- int ElementScale();\r
- int Dimensions();\r
- void Bounds(int dim, int* low, int* high);\r
- void SetBounds(int dim, int low, int high);\r
-\r
- IBPP::Database DatabasePtr() const;\r
- IBPP::Transaction TransactionPtr() const;\r
-\r
- IBPP::IArray* AddRef();\r
- void Release();\r
-};\r
-\r
-//\r
-// EventBufferIterator: used in EventsImpl implementation.\r
-//\r
-\r
-template<class It>\r
-struct EventBufferIterator\r
-{\r
- It mIt;\r
-\r
-public:\r
- EventBufferIterator& operator++()\r
- { mIt += 1 + static_cast<int>(*mIt) + 4; return *this; }\r
-\r
- bool operator == (const EventBufferIterator& i) const { return i.mIt == mIt; }\r
- bool operator != (const EventBufferIterator& i) const { return i.mIt != mIt; }\r
-\r
-#ifdef __BCPLUSPLUS__\r
-#pragma warn -8027\r
-#endif\r
- std::string get_name() const\r
- {\r
- return std::string(mIt + 1, mIt + 1 + static_cast<int32_t>(*mIt));\r
- }\r
-#ifdef __BCPLUSPLUS__\r
-#pragma warn .8027\r
-#endif\r
-\r
- uint32_t get_count() const\r
- {\r
- return (*gds.Call()->m_vax_integer)\r
- (const_cast<char*>(&*(mIt + 1 + static_cast<int>(*mIt))), 4);\r
- }\r
-\r
- // Those container like begin() and end() allow access to the underlying type\r
- It begin() { return mIt; }\r
- It end() { return mIt + 1 + static_cast<int>(*mIt) + 4; }\r
-\r
- EventBufferIterator() {}\r
- EventBufferIterator(It it) : mIt(it) {}\r
-};\r
-\r
-class EventsImpl : public IBPP::IEvents\r
-{\r
- static const size_t MAXEVENTNAMELEN;\r
- static void EventHandler(const char*, short, const char*);\r
-\r
- typedef std::vector<IBPP::EventInterface*> ObjRefs;\r
- ObjRefs mObjectReferences;\r
-\r
- typedef std::vector<char> Buffer;\r
- Buffer mEventBuffer;\r
- Buffer mResultsBuffer;\r
-\r
- int mRefCount; // Reference counter\r
-\r
- DatabaseImpl* mDatabase;\r
- ISC_LONG mId; // Firebird internal Id of these events\r
- bool mQueued; // Has isc_que_events() been called?\r
- bool mTrapped; // EventHandled() was called since last que_events()\r
-\r
- void FireActions();\r
- void Queue();\r
- void Cancel();\r
-\r
- EventsImpl& operator=(const EventsImpl&);\r
- EventsImpl(const EventsImpl&);\r
-\r
-public:\r
- void AttachDatabaseImpl(DatabaseImpl*);\r
- void DetachDatabaseImpl();\r
- \r
- EventsImpl(DatabaseImpl* dbi);\r
- ~EventsImpl();\r
- \r
- // (((((((( OBJECT INTERFACE ))))))))\r
-\r
-public:\r
- void Add(const std::string&, IBPP::EventInterface*);\r
- void Drop(const std::string&);\r
- void List(std::vector<std::string>&);\r
- void Clear(); // Drop all events\r
- void Dispatch(); // Dispatch NON async events\r
-\r
- IBPP::Database DatabasePtr() const;\r
-\r
- IBPP::IEvents* AddRef();\r
- void Release();\r
-};\r
-\r
-void encodeDate(ISC_DATE& isc_dt, const IBPP::Date& dt);\r
-void decodeDate(IBPP::Date& dt, const ISC_DATE& isc_dt);\r
-\r
-void encodeTime(ISC_TIME& isc_tm, const IBPP::Time& tm);\r
-void decodeTime(IBPP::Time& tm, const ISC_TIME& isc_tm);\r
-\r
-void encodeTimestamp(ISC_TIMESTAMP& isc_ts, const IBPP::Timestamp& ts);\r
-void decodeTimestamp(IBPP::Timestamp& ts, const ISC_TIMESTAMP& isc_ts);\r
-\r
-struct consts // See _ibpp.cpp for initializations of these constants\r
-{\r
- static const double dscales[19];\r
- static const int Dec31_1899;\r
- static const int16_t min16;\r
- static const int16_t max16;\r
- static const int32_t min32;\r
- static const int32_t max32;\r
-};\r
-\r
-} // namespace ibpp_internal\r
-\r
-#endif // __INTERNAL_IBPP_H__\r
-\r
-//\r
-// Eof\r
-//\r