| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Firebird/ibpp/core/ibpp.h
Go to the documentation of this file.

    00001
    00002 //
    00003 //         File    : $Id: ibpp.h 9715 2011-07-13 01:40:44Z frederico.bede $
    00004 //         Subject : IBPP public header file. This is _the_ only file you include in
    00005 //                                 your application files when developing with IBPP.
    00006 //
    00008 //
    00009 //         (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org)
    00010 //
    00011 //         The contents of this file are subject to the IBPP License (the "License");
    00012 //         you may not use this file except in compliance with the License.  You may
    00013 //         obtain a copy of the License at http://www.ibpp.org or in the 'license.txt'
    00014 //         file which must have been distributed along with this file.
    00015 //
    00016 //         This software, distributed under the License, is distributed on an "AS IS"
    00017 //         basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the
    00018 //         License for the specific language governing rights and limitations
    00019 //         under the License.
    00020 //
    00021 //         Contributor(s):
    00022 //
    00023 //                    Olivier Mascia, main coding
    00024 //                    Matt Hortman, initial linux port
    00025 //                    Mark Jordan, design contributions
    00026 //                    Maxim Abrashkin, enhancement patches
    00027 //                    Torsten Martinsen, enhancement patches
    00028 //                    Michael Hieke, darwin (OS X) port, enhancement patches
    00029 //                    Val Samko, enhancement patches and debugging
    00030 //                    Mike Nordell, invaluable C++ advices
    00031 //                    Claudio Valderrama, help with not-so-well documented IB/FB features
    00032 //                    Many others, excellent suggestions, bug finding, and support
    00033 //
    00035 //
    00036 //         COMMENTS
    00037 //         Tabulations should be set every four characters when editing this file.
    00038 //
    00039 //         When compiling a project using IBPP, the following defines should be made
    00040 //         on the command-line (or in makefiles) according to the OS platform and
    00041 //         compiler used.
    00042 //
    00043 //         Select the platform:  IBPP_WINDOWS | IBPP_LINUX | IBPP_DARWIN
    00044 //
    00046
    00047 #ifndef __IBPP_H__
    00048 #define __IBPP_H__
    00049
    00050 #if !defined(IBPP_WINDOWS) && !defined(IBPP_LINUX) && !defined(IBPP_DARWIN)
    00051 #error Please define IBPP_WINDOWS/IBPP_LINUX/IBPP_DARWIN before compiling !
    00052 #endif
    00053
    00054 #if !defined(__BCPLUSPLUS__) && !defined(__GNUC__) \
    00055            && !defined(_MSC_VER) && !defined(__DMC__)
    00056 #error Your compiler is not recognized.
    00057 #endif
    00058
    00059 #if defined(IBPP_LINUX) || defined(IBPP_DARWIN)
    00060 #define IBPP_UNIX     // IBPP_UNIX stands as a common denominator to *NIX flavours
    00061 #endif
    00062
    00063 // IBPP is written for 32 bits systems or higher.
    00064 // The standard type 'int' is assumed to be at least 32 bits.
    00065 // And the standard type 'short' is assumed to be exactly 16 bits.
    00066 // Everywhere possible, where the exact size of an integer does not matter,
    00067 // the standard type 'int' is used. And where an exact integer size is required
    00068 // the standard exact precision types definitions of C 99 standard are used.
    00069
    00070 #if defined(_MSC_VER) || defined(__DMC__) || defined(__BCPLUSPLUS__)
    00071 // C99 §7.18.1.1 Exact-width integer types (only those used by IBPP)
    00072 #if defined(_MSC_VER) && (_MSC_VER < 1300)  // MSVC 6 should be < 1300
    00073            typedef short int16_t;
    00074            typedef int int32_t;
    00075            typedef unsigned int uint32_t;
    00076 #else
    00077            typedef __int16 int16_t;
    00078            typedef __int32 int32_t;
    00079            typedef unsigned __int32 uint32_t;
    00080 #endif
    00081            typedef __int64 int64_t;
    00082 #else
    00083            #include <stdint.h>                         // C99 (§7.18) integer types definitions
    00084 #endif
    00085
    00086 #if !defined(_)
    00087 #define _(s)          s
    00088 #endif
    00089
    00090 #include <exception>
    00091 #include <string>
    00092 #include <vector>
    00093 #include <cstring>
    00094
    00095 namespace IBPP
    00096 {
    00097            //         Typically you use this constant in a call IBPP::CheckVersion as in:
    00098            //         if (! IBPP::CheckVersion(IBPP::Version)) { throw .... ; }
    00099            const uint32_t Version = (2<<24) + (5<<16) + (3<<8) + 1; // Version == 2.5.3.1
    00100
    00101            //         Dates range checking
    00102            const int MinDate = -693594;     //  1 JAN 0001
    00103            const int MaxDate = 2958464;     // 31 DEC 9999
    00104
    00105            //         Transaction Access Modes
    00106            enum TAM {amWrite, amRead};
    00107
    00108            //         Transaction Isolation Levels
    00109            enum TIL {ilConcurrency, ilReadDirty, ilReadCommitted, ilConsistency};
    00110
    00111            //         Transaction Lock Resolution
    00112            enum TLR {lrWait, lrNoWait};
    00113
    00114            // Transaction Table Reservation
    00115            enum TTR {trSharedWrite, trSharedRead, trProtectedWrite, trProtectedRead};
    00116
    00117            //         Prepared Statement Types
    00118            enum STT {stUnknown, stUnsupported,
    00119                       stSelect, stInsert, stUpdate, stDelete,     stDDL, stExecProcedure,
    00120                       stSelectUpdate, stSetGenerator, stSavePoint};
    00121
    00122            //         SQL Data Types
    00123            enum SDT {sdArray, sdBlob, sdDate, sdTime, sdTimestamp, sdString,
    00124                       sdSmallint, sdInteger, sdLargeint, sdFloat, sdDouble};
    00125
    00126            //         Array Data Types
    00127            enum ADT {adDate, adTime, adTimestamp, adString,
    00128                       adBool, adInt16, adInt32, adInt64, adFloat, adDouble};
    00129
    00130            // Database::Shutdown Modes
    00131            enum DSM {dsForce, dsDenyTrans, dsDenyAttach};
    00132
    00133            // Service::StartBackup && Service::StartRestore Flags
    00134            enum BRF {
    00135                       brVerbose = 0x1,
    00136                       // Backup flags
    00137                       brIgnoreChecksums = 0x100, brIgnoreLimbo = 0x200,
    00138                       brMetadataOnly = 0x400, brNoGarbageCollect = 0x800,
    00139                       brNonTransportable = 0x1000, brConvertExtTables = 0x2000,
    00140                       // Restore flags
    00141                       brReplace = 0x10000, brDeactivateIdx = 0x20000,
    00142                       brNoShadow = 0x40000, brNoValidity = 0x80000,
    00143                       brPerTableCommit = 0x100000, brUseAllSpace = 0x200000
    00144            };
    00145
    00146            // Service::Repair Flags
    00147            enum RPF
    00148            {
    00149                       // Mandatory and mutually exclusives
    00150                       rpMendRecords = 0x1, rpValidatePages = 0x2, rpValidateFull = 0x4,
    00151                       // Options
    00152                       rpReadOnly = 0x100, rpIgnoreChecksums = 0x200, rpKillShadows = 0x400
    00153            };
    00154
    00155            // TransactionFactory Flags
    00156            enum TFF {tfIgnoreLimbo = 0x1, tfAutoCommit = 0x2, tfNoAutoUndo = 0x4};
    00157
    00158            /* IBPP never return any error codes. It throws exceptions.
    00159             * On database engine reported errors, an IBPP::SQLException is thrown.
    00160             * In all other cases, IBPP throws IBPP::LogicException.
    00161             * Also note that the runtime and the language might also throw exceptions
    00162             * while executing some IBPP methods. A failing new operator will throw
    00163             * std::bad_alloc, IBPP does nothing to alter the standard behaviour.
    00164             *
    00165             *                    std::exception
    00166             *                           |
    00167             *                   IBPP::Exception
    00168             *                 /                 \
    00169             *    IBPP::LogicException    IBPP::SQLException
    00170             *             |
    00171             *      IBPP::WrongType
    00172             */
    00173
    00174            class Exception : public std::exception
    00175            {
    00176            public:
    00177                       virtual const char* Origin() const throw() = 0;
    00178                       virtual const char* ErrorMessage() const throw() = 0;  // Deprecated, use what()
    00179                       virtual const char* what() const throw() = 0;
    00180                       virtual ~Exception() throw();
    00181            };
    00182
    00183            class LogicException : public Exception
    00184            {
    00185            public:
    00186                       virtual ~LogicException() throw();
    00187            };
    00188
    00189            class SQLException : public Exception
    00190            {
    00191            public:
    00192                       virtual int SqlCode() const throw() = 0;
    00193                       virtual int EngineCode() const throw() = 0;
    00194
    00195                       virtual ~SQLException() throw();
    00196            };
    00197
    00198            class WrongType : public LogicException
    00199            {
    00200            public:
    00201                       virtual ~WrongType() throw();
    00202            };
    00203
    00204            /* Classes Date, Time, Timestamp and DBKey are 'helper' classes.  They help
    00205             * in retrieving or setting some special SQL types. Dates, times and dbkeys
    00206             * are often read and written as strings in SQL scripts. When programming
    00207             * with IBPP, we handle those data with these specific classes, which
    00208             * enhance their usefullness and free us of format problems (M/D/Y, D/M/Y,
    00209             * Y-M-D ?, and so on...). */
    00210
    00211            /* Class Date represent purely a Date (no time part specified). It is
    00212             * usefull in interactions with the SQL DATE type of Interbase.  You can add
    00213             * or substract a number from a Date, that will modify it to represent the
    00214             * correct date, X days later or sooner. All the Y2K details taken into
    00215             * account.
    00216             * The full range goes from integer values IBPP::MinDate to IBPP::MaxDate
    00217             * which means from 01 Jan 0001 to 31 Dec 9999. ( Which is inherently
    00218             * incorrect as this assumes Gregorian calendar. ) */
    00219
    00220            class Timestamp;      // Cross-reference between Timestamp, Date and Time
    00221
    00222            class Date
    00223            {
    00224            protected:
    00225                       int mDate; // The date : 1 == 1 Jan 1900
    00226
    00227            public:
    00228                       void Clear()          { mDate = MinDate - 1; };
    00229                       void Today();
    00230                       void SetDate(int year, int month, int day);
    00231                       void SetDate(int dt);
    00232                       void GetDate(int& year, int& month, int& day) const;
    00233                       int GetDate() const   { return mDate; }
    00234                       int Year() const;
    00235                       int Month() const;
    00236                       int Day() const;
    00237                       void Add(int days);
    00238                       void StartOfMonth();
    00239                       void EndOfMonth();
    00240
    00241                       Date()                           { Clear(); };
    00242                       Date(int dt)          { SetDate(dt); }
    00243                       Date(int year, int month, int day);
    00244                       Date(const Date&);                                                                      // Copy Constructor
    00245                       Date& operator=(const Timestamp&);                                // Timestamp Assignment operator
    00246                       Date& operator=(const Date&);                                     // Date Assignment operator
    00247
    00248                       bool operator==(const Date& rv)  const { return mDate == rv.GetDate(); }
    00249                       bool operator!=(const Date& rv)  const { return mDate != rv.GetDate(); }
    00250                       bool operator<(const Date& rv) const { return mDate < rv.GetDate(); }
    00251                       bool operator>(const Date& rv) const { return mDate > rv.GetDate(); }
    00252
    00253                       virtual ~Date() { };
    00254            };
    00255
    00256            /* Class Time represent purely a Time. It is usefull in interactions
    00257             * with the SQL TIME type of Interbase. */
    00258
    00259            class Time
    00260            {
    00261            protected:
    00262                       int mTime; // The time, in ten-thousandths of seconds since midnight
    00263
    00264            public:
    00265                       void Clear()          { mTime = 0; }
    00266                       void Now();
    00267                       void SetTime(int hour, int minute, int second, int tenthousandths = 0);
    00268                       void SetTime(int tm);
    00269                       void GetTime(int& hour, int& minute, int& second) const;
    00270                       void GetTime(int& hour, int& minute, int& second, int& tenthousandths) const;
    00271                       int GetTime() const   { return mTime; }
    00272                       int Hours() const;
    00273                       int Minutes() const;
    00274                       int Seconds() const;
    00275                       int SubSeconds() const;                     // Actually tenthousandths of seconds
    00276                       Time()                           { Clear(); }
    00277                       Time(int tm)          { SetTime(tm); }
    00278                       Time(int hour, int minute, int second, int tenthousandths = 0);
    00279                       Time(const Time&);                                                                      // Copy Constructor
    00280                       Time& operator=(const Timestamp&);                                // Timestamp Assignment operator
    00281                       Time& operator=(const Time&);                                     // Time Assignment operator
    00282
    00283                       bool operator==(const Time& rv)  const { return mTime == rv.GetTime(); }
    00284                       bool operator!=(const Time& rv)  const { return mTime != rv.GetTime(); }
    00285                       bool operator<(const Time& rv) const { return mTime < rv.GetTime(); }
    00286                       bool operator>(const Time& rv) const { return mTime > rv.GetTime(); }
    00287
    00288                       virtual ~Time() { };
    00289            };
    00290
    00291            /* Class Timestamp represent a date AND a time. It is usefull in
    00292             * interactions with the SQL TIMESTAMP type of Interbase. This class
    00293             * inherits from Date and Time and completely inline implements its small
    00294             * specific details. */
    00295
    00296            class Timestamp : public Date, public Time
    00297            {
    00298            public:
    00299                       void Clear()          { Date::Clear(); Time::Clear(); }
    00300                       void Today()          { Date::Today(); Time::Clear(); }
    00301                       void Now()            { Date::Today(); Time::Now(); }
    00302
    00303                       Timestamp()                      { Clear(); }
    00304
    00305                       Timestamp(int y, int m, int d)
    00306                                  { Date::SetDate(y, m, d); Time::Clear(); }
    00307
    00308                       Timestamp(int y, int mo, int d, int h, int mi, int s, int t = 0)
    00309                                  { Date::SetDate(y, mo, d); Time::SetTime(h, mi, s, t); }
    00310
    00311                       Timestamp(const Timestamp& rv)
    00312                                  : Date(rv.mDate), Time(rv.mTime) {}         // Copy Constructor
    00313
    00314                       Timestamp(const Date& rv)
    00315                                  { mDate = rv.GetDate(); mTime = 0; }
    00316
    00317                       Timestamp(const Time& rv)
    00318                                  { mDate = 0; mTime = rv.GetTime(); }
    00319
    00320                       Timestamp& operator=(const Timestamp& rv)   // Timestamp Assignment operator
    00321                                  { mDate = rv.mDate; mTime = rv.mTime; return *this; }
    00322
    00323                       Timestamp& operator=(const Date& rv)                   // Date Assignment operator
    00324                                  { mDate = rv.GetDate(); return *this; }
    00325
    00326                       Timestamp& operator=(const Time& rv)                   // Time Assignment operator
    00327                                  { mTime = rv.GetTime(); return *this; }
    00328
    00329                       bool operator==(const Timestamp& rv) const
    00330                                  { return (mDate == rv.GetDate()) && (mTime == rv.GetTime()); }
    00331
    00332                       bool operator!=(const Timestamp& rv) const
    00333                                  { return (mDate != rv.GetDate()) || (mTime != rv.GetTime()); }
    00334
    00335                       bool operator<(const Timestamp& rv) const
    00336                                  { return (mDate < rv.GetDate()) ||
    00337                                             (mDate == rv.GetDate() && mTime < rv.GetTime()); }
    00338
    00339                       bool operator>(const Timestamp& rv) const
    00340                                  { return (mDate > rv.GetDate()) ||
    00341                                             (mDate == rv.GetDate() && mTime > rv.GetTime()); }
    00342
    00343                       ~Timestamp() { }
    00344            };
    00345
    00346            /* Class DBKey can store a DBKEY, that special value which the hidden
    00347             * RDB$DBKEY can give you from a select statement. A DBKey is nothing
    00348             * specific to IBPP. It's a feature of the Firebird database engine. See its
    00349             * documentation for more information. */
    00350
    00351            class DBKey
    00352            {
    00353            private:
    00354                       std::string mDBKey;                         // Stores the binary DBKey
    00355                       mutable std::string mString;// String (temporary) representation of it
    00356
    00357            public:
    00358                       void Clear();
    00359                       int Size() const      { return (int)mDBKey.size(); }
    00360                       void SetKey(const void*, int size);
    00361                       void GetKey(void*, int size) const;
    00362                       const char* AsString() const;
    00363
    00364                       DBKey& operator=(const DBKey&);  // Assignment operator
    00365                       DBKey(const DBKey&);                        // Copy Constructor
    00366                       DBKey() { }
    00367                       ~DBKey() { }
    00368            };
    00369
    00370            /* Class User wraps all the information about a user that the engine can manage. */
    00371
    00372            class User
    00373            {
    00374            public:
    00375                       std::string username;
    00376                       std::string password;
    00377                       std::string firstname;
    00378                       std::string middlename;
    00379                       std::string lastname;
    00380                       uint32_t userid;                 // Only relevant on unixes
    00381                       uint32_t groupid;                // Only relevant on unixes
    00382
    00383            private:
    00384                       void copyfrom(const User& r);
    00385
    00386            public:
    00387                       void clear();
    00388                       User& operator=(const User& r)   { copyfrom(r); return *this; }
    00389                       User(const User& r)                                    { copyfrom(r); }
    00390                       User() : userid(0), groupid(0)   { }
    00391                       ~User() { };
    00392            };
    00393
    00394            //         Interface Wrapper
    00395            template <class T>
    00396            class Ptr
    00397            {
    00398            private:
    00399                       T* mObject;
    00400
    00401            public:
    00402                       void clear()
    00403                       {
    00404                                  if (mObject != 0) { mObject->Release(); mObject = 0; }
    00405                       }
    00406
    00407                       T* intf() const                                                              { return mObject; }
    00408                       T* operator->() const                                  { return mObject; }
    00409
    00410                       bool operator==(const T* p) const           { return mObject == p; }
    00411                       bool operator==(const Ptr& r) const         { return mObject == r.mObject; }
    00412                       bool operator!=(const T* p) const           { return mObject != p; }
    00413                       bool operator!=(const Ptr& r) const         { return mObject != r.mObject; }
    00414
    00415                       Ptr& operator=(T* p)
    00416                       {
    00417                                  // AddRef _before_ Release gives correct behaviour on self-assigns
    00418                                  T* tmp = (p == 0 ? 0 : p->AddRef());        // Take care of 0
    00419                                  if (mObject != 0) mObject->Release();
    00420                                  mObject = tmp; return *this;
    00421                       }
    00422
    00423                       Ptr& operator=(const Ptr& r)
    00424                       {
    00425                                  // AddRef _before_ Release gives correct behaviour on self-assigns
    00426                                  T* tmp = (r.intf() == 0 ? 0 : r->AddRef());// Take care of 0
    00427                                  if (mObject != 0) mObject->Release();
    00428                                  mObject = tmp; return *this;
    00429                       }
    00430
    00431                       Ptr(T* p) : mObject(p == 0 ? 0 : p->AddRef()) { }
    00432                       Ptr(const Ptr& r) : mObject(r.intf() == 0 ? 0 : r->AddRef()) {  }
    00433
    00434                       Ptr() : mObject(0) { }
    00435                       ~Ptr() { clear(); }
    00436            };
    00437
    00438            //         --- Interface Classes --- //
    00439
    00440            /* Interfaces IBlob, IArray, IService, IDatabase, ITransaction and
    00441             * IStatement are at the core of IBPP. Though it is possible to program your
    00442             * applications by using theses interfaces directly (as was the case with
    00443             * IBPP 1.x), you should refrain from using them and prefer the new IBPP
    00444             * Objects Blob, Array, ... (without the I in front). Those new objects are
    00445             * typedef'd right after each interface class definition as you can read
    00446             * below. If you program using the Blob (instead of the IBlob interface
    00447             * itself), you'll never have to care about AddRef/Release and you'll never
    00448             * have to care about deleting your objects. */
    00449
    00450            class IBlob;                                typedef Ptr<IBlob> Blob;
    00451            class IArray;                               typedef Ptr<IArray> Array;
    00452            class IService;                             typedef Ptr<IService> Service;
    00453            class IDatabase;                 typedef Ptr<IDatabase> Database;
    00454            class ITransaction;              typedef Ptr<ITransaction> Transaction;
    00455            class IStatement;                typedef Ptr<IStatement> Statement;
    00456            class IEvents;                              typedef Ptr<IEvents> Events;
    00457            class IRow;                                            typedef Ptr<IRow> Row;
    00458
    00459            /* IBlob is the interface to the blob capabilities of IBPP. Blob is the
    00460             * object class you actually use in your programming. In Firebird, at the
    00461             * row level, a blob is merely a handle to a blob, stored elsewhere in the
    00462             * database. Blob allows you to retrieve such a handle and then read from or
    00463             * write to the blob, much in the same manner than you would do with a file. */
    00464
    00465            class IBlob
    00466            {
    00467            public:
    00468                       virtual void Create() = 0;
    00469                       virtual void Open() = 0;
    00470                       virtual void Close() = 0;
    00471                       virtual void Cancel() = 0;
    00472                       virtual int Read(void*, int size) = 0;
    00473                       virtual void Write(const void*, int size) = 0;
    00474                       virtual void Info(int* Size, int* Largest, int* Segments) = 0;
    00475
    00476                       virtual void Save(const std::string& data) = 0;
    00477                       virtual void Load(std::string& data) = 0;
    00478
    00479                       virtual Database DatabasePtr() const = 0;
    00480                       virtual Transaction TransactionPtr() const = 0;
    00481
    00482                       virtual IBlob* AddRef() = 0;
    00483                       virtual void Release() = 0;
    00484
    00485                       virtual ~IBlob() { };
    00486            };
    00487
    00488            /*         IArray is the interface to the array capabilities of IBPP. Array is the
    00489            * object class you actually use in your programming. With an Array object, you
    00490            * can create, read and write Interbase Arrays, as a whole or in slices. */
    00491
    00492            class IArray
    00493            {
    00494            public:
    00495                       virtual void Describe(const std::string& table, const std::string& column) = 0;
    00496                       virtual void ReadTo(ADT, void* buffer, int elemcount) = 0;
    00497                       virtual void WriteFrom(ADT, const void* buffer, int elemcount) = 0;
    00498                       virtual SDT ElementType() = 0;
    00499                       virtual int ElementSize() = 0;
    00500                       virtual int ElementScale() = 0;
    00501                       virtual int Dimensions() = 0;
    00502                       virtual void Bounds(int dim, int* low, int* high) = 0;
    00503                       virtual void SetBounds(int dim, int low, int high) = 0;
    00504
    00505                       virtual Database DatabasePtr() const = 0;
    00506                       virtual Transaction TransactionPtr() const = 0;
    00507
    00508                       virtual IArray* AddRef() = 0;
    00509                       virtual void Release() = 0;
    00510
    00511                       virtual ~IArray() { };
    00512            };
    00513
    00514            /* IService is the interface to the service capabilities of IBPP. Service is
    00515             * the object class you actually use in your programming. With a Service
    00516             * object, you can do some maintenance work of databases and servers
    00517             * (backup, restore, create/update users, ...) */
    00518
    00519            class IService
    00520            {
    00521            public:
    00522                virtual void Connect() = 0;
    00523                       virtual bool Connected() = 0;
    00524                       virtual void Disconnect() = 0;
    00525
    00526                       virtual void GetVersion(std::string& version) = 0;
    00527
    00528                       virtual void AddUser(const User&) = 0;
    00529                       virtual void GetUser(User&) = 0;
    00530                       virtual void GetUsers(std::vector<User>&) = 0;
    00531                       virtual void ModifyUser(const User&) = 0;
    00532                       virtual void RemoveUser(const std::string& username) = 0;
    00533
    00534                       virtual void SetPageBuffers(const std::string& dbfile, int buffers) = 0;
    00535                       virtual void SetSweepInterval(const std::string& dbfile, int sweep) = 0;
    00536                       virtual void SetSyncWrite(const std::string& dbfile, bool) = 0;
    00537                       virtual void SetReadOnly(const std::string& dbfile, bool) = 0;
    00538                       virtual void SetReserveSpace(const std::string& dbfile, bool) = 0;
    00539
    00540                       virtual void Shutdown(const std::string& dbfile, DSM mode, int sectimeout) = 0;
    00541                       virtual void Restart(const std::string& dbfile) = 0;
    00542                       virtual void Sweep(const std::string& dbfile) = 0;
    00543                       virtual void Repair(const std::string& dbfile, RPF flags) = 0;
    00544
    00545                       virtual void StartBackup(const std::string& dbfile,
    00546                                  const std::string& bkfile, BRF flags = BRF(0)) = 0;
    00547                       virtual void StartRestore(const std::string& bkfile, const std::string& dbfile,
    00548                                  int pagesize = 0, BRF flags = BRF(0)) = 0;
    00549
    00550                       virtual const char* WaitMsg() = 0;          // With reporting (does not block)
    00551                       virtual void Wait() = 0;                               // Without reporting (does block)
    00552
    00553                       virtual IService* AddRef() = 0;
    00554                       virtual void Release() = 0;
    00555
    00556                       virtual ~IService() { };
    00557            };
    00558
    00559            /*         IDatabase is the interface to the database connections in IBPP. Database
    00560             * is the object class you actually use in your programming. With a Database
    00561             * object, you can create/drop/connect databases. */
    00562
    00563            class EventInterface; // Cross-reference between EventInterface and IDatabase
    00564
    00565            class IDatabase
    00566            {
    00567            public:
    00568                       virtual const char* ServerName() const = 0;
    00569                       virtual const char* DatabaseName() const = 0;
    00570                       virtual const char* Username() const = 0;
    00571                       virtual const char* UserPassword() const = 0;
    00572                       virtual const char* RoleName() const = 0;
    00573                       virtual const char* CharSet() const = 0;
    00574                       virtual const char* CreateParams() const = 0;
    00575
    00576                       virtual void Info(int* ODS, int* ODSMinor, int* PageSize,
    00577                                  int* Pages,           int* Buffers, int* Sweep, bool* Sync,
    00578                                  bool* Reserve) = 0;
    00579                       virtual void Statistics(int* Fetches, int* Marks,
    00580                                  int* Reads, int* Writes) = 0;
    00581                       virtual void Counts(int* Insert, int* Update, int* Delete,
    00582                                  int* ReadIdx, int* ReadSeq) = 0;
    00583                       virtual void Users(std::vector<std::string>& users) = 0;
    00584                       virtual int Dialect() = 0;
    00585
    00586                       virtual void Create(int dialect) = 0;
    00587                       virtual void Connect() = 0;
    00588                       virtual bool Connected() = 0;
    00589                       virtual void Inactivate() = 0;
    00590                       virtual void Disconnect() = 0;
    00591                       virtual void Drop() = 0;
    00592
    00593                       virtual IDatabase* AddRef() = 0;
    00594                       virtual void Release() = 0;
    00595
    00596                virtual ~IDatabase() { };
    00597            };
    00598
    00599            /* ITransaction is the interface to the transaction connections in IBPP.
    00600             * Transaction is the object class you actually use in your programming. A
    00601             * Transaction object can be associated with more than one Database,
    00602             * allowing for distributed transactions spanning multiple databases,
    00603             * possibly located on different servers. IBPP is one among the few
    00604             * programming interfaces to Firebird that allows you to support distributed
    00605             * transactions. */
    00606
    00607            class ITransaction
    00608            {
    00609            public:
    00610                virtual void AttachDatabase(Database db, TAM am = amWrite,
    00611                                  TIL il = ilConcurrency, TLR lr = lrWait, TFF flags = TFF(0)) = 0;
    00612                virtual void DetachDatabase(Database db) = 0;
    00613                       virtual void AddReservation(Database db,
    00614                                             const std::string& table, TTR tr) = 0;
    00615
    00616                       virtual void Start() = 0;
    00617                       virtual bool Started() = 0;
    00618                virtual void Commit() = 0;
    00619                virtual void Rollback() = 0;
    00620                virtual void CommitRetain() = 0;
    00621                       virtual void RollbackRetain() = 0;
    00622
    00623                       virtual ITransaction* AddRef() = 0;
    00624                       virtual void Release() = 0;
    00625
    00626                virtual ~ITransaction() { };
    00627            };
    00628
    00629            /*
    00630             *         Class Row can hold all the values of a row (from a SELECT for instance).
    00631             */
    00632
    00633            class IRow
    00634            {
    00635            public:
    00636                       virtual void SetNull(int) = 0;
    00637                       virtual void Set(int, bool) = 0;
    00638                       virtual void Set(int, const void*, int) = 0;                      // byte buffers
    00639                       virtual void Set(int, const char*) = 0;                                      // c-string
    00640                       virtual void Set(int, const std::string&) = 0;
    00641                       virtual void Set(int, int16_t) = 0;
    00642                       virtual void Set(int, int32_t) = 0;
    00643                       virtual void Set(int, int64_t) = 0;
    00644                       virtual void Set(int, float) = 0;
    00645                       virtual void Set(int, double) = 0;
    00646                       virtual void Set(int, const Timestamp&) = 0;
    00647                       virtual void Set(int, const Date&) = 0;
    00648                       virtual void Set(int, const Time&) = 0;
    00649                       virtual void Set(int, const DBKey&) = 0;
    00650                       virtual void Set(int, const Blob&) = 0;
    00651                       virtual void Set(int, const Array&) = 0;
    00652
    00653                       virtual bool IsNull(int) = 0;
    00654                       virtual bool Get(int, bool&) = 0;
    00655                       virtual bool Get(int, void*, int&) = 0;     // byte buffers
    00656                       virtual bool Get(int, std::string&) = 0;
    00657                       virtual bool Get(int, int16_t&) = 0;
    00658                       virtual bool Get(int, int32_t&) = 0;
    00659                       virtual bool Get(int, int64_t&) = 0;
    00660                       virtual bool Get(int, float&) = 0;
    00661                       virtual bool Get(int, double&) = 0;
    00662                       virtual bool Get(int, Timestamp&) = 0;
    00663                       virtual bool Get(int, Date&) = 0;
    00664                       virtual bool Get(int, Time&) = 0;
    00665                       virtual bool Get(int, DBKey&) = 0;
    00666                       virtual bool Get(int, Blob&) = 0;
    00667                       virtual bool Get(int, Array&) = 0;
    00668
    00669                       virtual bool IsNull(const std::string&) = 0;
    00670                       virtual bool Get(const std::string&, bool&) = 0;
    00671                       virtual bool Get(const std::string&, void*, int&) = 0; // byte buffers
    00672                       virtual bool Get(const std::string&, std::string&) = 0;
    00673                       virtual bool Get(const std::string&, int16_t&) = 0;
    00674                       virtual bool Get(const std::string&, int32_t&) = 0;
    00675                       virtual bool Get(const std::string&, int64_t&) = 0;
    00676                       virtual bool Get(const std::string&, float&) = 0;
    00677                       virtual bool Get(const std::string&, double&) = 0;
    00678                       virtual bool Get(const std::string&, Timestamp&) = 0;
    00679                       virtual bool Get(const std::string&, Date&) = 0;
    00680                       virtual bool Get(const std::string&, Time&) = 0;
    00681                       virtual bool Get(const std::string&, DBKey&) = 0;
    00682                       virtual bool Get(const std::string&, Blob&) = 0;
    00683                       virtual bool Get(const std::string&, Array&) = 0;
    00684
    00685                       virtual int ColumnNum(const std::string&) = 0;
    00686                       virtual const char* ColumnName(int) = 0;
    00687                       virtual const char* ColumnAlias(int) = 0;
    00688                       virtual const char* ColumnTable(int) = 0;
    00689                       virtual SDT ColumnType(int) = 0;
    00690                       virtual int ColumnSubtype(int) = 0;
    00691                       virtual int ColumnSize(int) = 0;
    00692                       virtual int ColumnScale(int) = 0;
    00693                       virtual int Columns() = 0;
    00694
    00695                       virtual bool ColumnUpdated(int) = 0;
    00696                       virtual bool Updated() = 0;
    00697
    00698                       virtual    Database DatabasePtr() const = 0;
    00699                       virtual Transaction TransactionPtr() const = 0;
    00700
    00701                       virtual IRow* Clone() = 0;
    00702                       virtual IRow* AddRef() = 0;
    00703                       virtual void Release() = 0;
    00704
    00705                virtual ~IRow() {};
    00706            };
    00707
    00708            /* IStatement is the interface to the statements execution in IBPP.
    00709             * Statement is the object class you actually use in your programming. A
    00710             * Statement object is the work horse of IBPP. All your data manipulation
    00711             * statements will be done through it. It is also used to access the result
    00712             * set of a query (when the statement is such), one row at a time and in
    00713             * strict forward direction. */
    00714
    00715            class IStatement
    00716            {
    00717            public:
    00718                       virtual void Prepare(const std::string&) = 0;
    00719                       virtual void Execute() = 0;
    00720                       virtual void Execute(const std::string&) = 0;
    00721                       virtual void ExecuteImmediate(const std::string&) = 0;
    00722                       virtual void CursorExecute(const std::string& cursor) = 0;
    00723                       virtual void CursorExecute(const std::string& cursor, const std::string&) = 0;
    00724                       virtual bool Fetch() = 0;
    00725                       virtual bool Fetch(Row&) = 0;
    00726                       virtual int AffectedRows() = 0;
    00727                       virtual void Close() = 0;
    00728                       virtual std::string& Sql() = 0;
    00729                       virtual STT Type() = 0;
    00730
    00731                       virtual void SetNull(int) = 0;
    00732                       virtual void Set(int, bool) = 0;
    00733                       virtual void Set(int, const void*, int) = 0;                      // byte buffers
    00734                       virtual void Set(int, const char*) = 0;                                      // c-string
    00735                       virtual void Set(int, const std::string&) = 0;
    00736                       virtual void Set(int, int16_t value) = 0;
    00737                       virtual void Set(int, int32_t value) = 0;
    00738                       virtual void Set(int, int64_t value) = 0;
    00739                       virtual void Set(int, float value) = 0;
    00740                       virtual void Set(int, double value) = 0;
    00741                       virtual void Set(int, const Timestamp& value) = 0;
    00742                       virtual void Set(int, const Date& value) = 0;
    00743                       virtual void Set(int, const Time& value) = 0;
    00744                       virtual void Set(int, const DBKey& value) = 0;
    00745                       virtual void Set(int, const Blob& value) = 0;
    00746                       virtual void Set(int, const Array& value) = 0;
    00747
    00748                       virtual bool IsNull(int) = 0;
    00749                       virtual bool Get(int, bool&) = 0;
    00750                       virtual bool Get(int, void*, int&) = 0;     // byte buffers
    00751                       virtual bool Get(int, std::string&) = 0;
    00752                       virtual bool Get(int, int16_t&) = 0;
    00753                       virtual bool Get(int, int32_t&) = 0;
    00754                       virtual bool Get(int, int64_t&) = 0;
    00755                       virtual bool Get(int, float&) = 0;
    00756                       virtual bool Get(int, double&) = 0;
    00757                       virtual bool Get(int, Timestamp& value) = 0;
    00758                       virtual bool Get(int, Date& value) = 0;
    00759                       virtual bool Get(int, Time& value) = 0;
    00760                       virtual bool Get(int, DBKey& value) = 0;
    00761                       virtual bool Get(int, Blob& value) = 0;
    00762                       virtual bool Get(int, Array& value) = 0;
    00763
    00764                       virtual bool IsNull(const std::string&) = 0;
    00765                       virtual bool Get(const std::string&, bool&) = 0;
    00766                       virtual bool Get(const std::string&, void*, int&) = 0; // byte buffers
    00767                       virtual bool Get(const std::string&, std::string&) = 0;
    00768                       virtual bool Get(const std::string&, int16_t&) = 0;
    00769                       virtual bool Get(const std::string&, int32_t&) = 0;
    00770                       virtual bool Get(const std::string&, int64_t&) = 0;
    00771                       virtual bool Get(const std::string&, float&) = 0;
    00772                       virtual bool Get(const std::string&, double&) = 0;
    00773                       virtual bool Get(const std::string&, Timestamp& value) = 0;
    00774                       virtual bool Get(const std::string&, Date& value) = 0;
    00775                       virtual bool Get(const std::string&, Time& value) = 0;
    00776                       virtual bool Get(const std::string&, DBKey& value) = 0;
    00777                       virtual bool Get(const std::string&, Blob& value) = 0;
    00778                       virtual bool Get(const std::string&, Array& value) = 0;
    00779
    00780                       virtual int ColumnNum(const std::string&) = 0;
    00781                       virtual const char* ColumnName(int) = 0;
    00782                       virtual const char* ColumnAlias(int) = 0;
    00783                       virtual const char* ColumnTable(int) = 0;
    00784                       virtual SDT ColumnType(int) = 0;
    00785                       virtual int ColumnSubtype(int) = 0;
    00786                       virtual int ColumnSize(int) = 0;
    00787                       virtual int ColumnScale(int) = 0;
    00788                       virtual int Columns() = 0;
    00789
    00790                       virtual SDT ParameterType(int) = 0;
    00791                       virtual int ParameterSubtype(int) = 0;
    00792                       virtual int ParameterSize(int) = 0;
    00793                       virtual int ParameterScale(int) = 0;
    00794                       virtual int Parameters() = 0;
    00795
    00796                       virtual void Plan(std::string&) = 0;
    00797
    00798                       virtual    Database DatabasePtr() const = 0;
    00799                       virtual Transaction TransactionPtr() const = 0;
    00800
    00801                       virtual IStatement* AddRef() = 0;
    00802                       virtual void Release() = 0;
    00803
    00804                virtual ~IStatement() { };
    00805
    00806                       // DEPRECATED METHODS (WON'T BE AVAILABLE IN VERSIONS 3.x)
    00807                       virtual bool Get(int, char*) = 0;                                                       // DEPRECATED
    00808                       virtual bool Get(const std::string&, char*) = 0;       // DEPRECATED
    00809                       virtual bool Get(int, bool*) = 0;                                                       // DEPRECATED
    00810                       virtual bool Get(const std::string&, bool*) = 0;       // DEPRECATED
    00811                       virtual bool Get(int, int16_t*) = 0;                                         // DEPRECATED
    00812                       virtual bool Get(const std::string&, int16_t*) = 0;    // DEPRECATED
    00813                       virtual bool Get(int, int32_t*) = 0;                                         // DEPRECATED
    00814                       virtual bool Get(const std::string&, int32_t*) = 0;    // DEPRECATED
    00815                       virtual bool Get(int, int64_t*) = 0;                                         // DEPRECATED
    00816                       virtual bool Get(const std::string&, int64_t*) = 0;    // DEPRECATED
    00817                       virtual bool Get(int, float*) = 0;                                                      // DEPRECATED
    00818                       virtual bool Get(const std::string&, float*) = 0;      // DEPRECATED
    00819                       virtual bool Get(int, double*) = 0;                                                     // DEPRECATED
    00820                       virtual bool Get(const std::string&, double*) = 0;     // DEPRECATED
    00821            };
    00822
    00823            class IEvents
    00824            {
    00825            public:
    00826                       virtual void Add(const std::string&, EventInterface*) = 0;
    00827                       virtual void Drop(const std::string&) = 0;
    00828                       virtual void List(std::vector<std::string>&) = 0;
    00829                       virtual void Clear() = 0;                                         // Drop all events
    00830                       virtual void Dispatch() = 0;                           // Dispatch events (calls handlers)
    00831
    00832                       virtual    Database DatabasePtr() const = 0;
    00833
    00834                       virtual IEvents* AddRef() = 0;
    00835                       virtual void Release() = 0;
    00836
    00837                virtual ~IEvents() { };
    00838            };
    00839
    00840            /* Class EventInterface is merely a pure interface.
    00841             * It is _not_ implemented by IBPP. It is only a base class definition from
    00842             * which your own event interface classes have to derive from.
    00843             * Please read the reference guide at http://www.ibpp.org for more info. */
    00844
    00845            class EventInterface
    00846            {
    00847            public:
    00848                       virtual void ibppEventHandler(Events, const std::string&, int) = 0;
    00849                       virtual ~EventInterface() { };
    00850            };
    00851
    00852            //         --- Factories ---
    00853            //         These methods are the only way to get one of the above
    00854            //         Interfaces.  They are at the heart of how you program using IBPP.  For
    00855            //         instance, to get access to a database, you'll write code similar to this:
    00856            //         {
    00857            //                    Database db = DatabaseFactory("server", "databasename",
    00858            //                                                                "user", "password");
    00859            //                    db->Connect();
    00860            //                    ...
    00861            //                    db->Disconnect();
    00862            //         }
    00863
    00864            Service ServiceFactory(const std::string& ServerName,
    00865                       const std::string& UserName, const std::string& UserPassword);
    00866
    00867            Database DatabaseFactory(const std::string& ServerName,
    00868                       const std::string& DatabaseName, const std::string& UserName,
    00869                                  const std::string& UserPassword, const std::string& RoleName,
    00870                                             const std::string& CharSet, const std::string& CreateParams);
    00871
    00872            inline Database DatabaseFactory(const std::string& ServerName,
    00873                       const std::string& DatabaseName, const std::string& UserName,
    00874                                  const std::string& UserPassword)
    00875                       { return DatabaseFactory(ServerName, DatabaseName, UserName, UserPassword, "", "", ""); }
    00876
    00877            Transaction TransactionFactory(Database db, TAM am = amWrite,
    00878                       TIL il = ilConcurrency, TLR lr = lrWait, TFF flags = TFF(0));
    00879
    00880            Statement StatementFactory(Database db, Transaction tr,
    00881                       const std::string& sql);
    00882
    00883            inline Statement StatementFactory(Database db, Transaction tr)
    00884                       { return StatementFactory(db, tr, ""); }
    00885
    00886            Blob BlobFactory(Database db, Transaction tr);
    00887
    00888            Array ArrayFactory(Database db, Transaction tr);
    00889
    00890            Events EventsFactory(Database db);
    00891
    00892            /* IBPP uses a self initialization system. Each time an object that may
    00893             * require the usage of the Interbase client C-API library is used, the
    00894             * library internal handling details are automatically initialized, if not
    00895             * already done. You can kick this initialization at the start of an
    00896             * application by calling IBPP::CheckVersion(). This is recommended, because
    00897             * IBPP::CheckVersion will assure you that YOUR code has been compiled
    00898             * against a compatible version of the library. */
    00899
    00900            bool CheckVersion(uint32_t);
    00901            int GDSVersion();
    00902
    00903            /* On Win32 platform, ClientLibSearchPaths() allows to setup
    00904             * one or multiple additional paths (separated with a ';') where IBPP
    00905             * will look for the client library (before the default implicit search
    00906             * locations). This is usefull for applications distributed with a 'private'
    00907             * copy of Firebird, when the registry is useless to identify the location
    00908             * from where to attempt loading the fbclient.dll / gds32.dll.
    00909             * If called, this function must be called *early* by the application,
    00910             * before *any* other function or object methods of IBPP.
    00911             * Currently, this is a NO-OP on platforms other than Win32. */
    00912
    00913            void ClientLibSearchPaths(const std::string&);
    00914
    00915            /* Finally, here are some date and time conversion routines used by IBPP and
    00916             * that may be helpful at the application level. They do not depend on
    00917             * anything related to Firebird/Interbase. Just a bonus. dtoi and itod
    00918             * return false on invalid parameters or out of range conversions. */
    00919
    00920            bool dtoi(int date, int* py, int* pm, int* pd);
    00921            bool itod(int* pdate, int year, int month, int day);
    00922            void ttoi(int itime, int* phour, int* pminute, int* psecond, int* ptt);
    00923            void itot(int* ptime, int hour, int minute, int second = 0, int tenthousandths = 0);
    00924
    00925 }
    00926
    00927 #endif
    00928
    00929 //
    00930 //         EOF
    00931 //

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines