Annotation of parser3/src/sql/pa_sql_driver.h, revision 1.1
1.1 ! paf 1: /** @file
! 2: Parser: sql driver interface.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5:
! 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 7:
! 8: $Id: pa_sql_driver.h,v 1.4 2001/04/04 12:45:46 paf Exp $
! 9:
! 10:
! 11: driver dynamic library must look like this:
! 12: @code
! 13: class X_SQL_Driver : public SQL_Driver {
! 14: public:
! 15:
! 16: X_SQL_Driver() : SQL_driver() {}
! 17:
! 18: int api_version() { return SQL_DRIVER_API_VERSION; }
! 19:
! 20: //...
! 21: };
! 22:
! 23: extern "C" SQL_Driver *create() {
! 24: return new X_SQL_Driver();
! 25: }
! 26: @endcode
! 27: */
! 28:
! 29: #ifndef PA_SQL_DRIVER_H
! 30: #define PA_SQL_DRIVER_H
! 31:
! 32: #include "pa_pool.h"
! 33:
! 34: /// service functions for SQL driver to use
! 35: class Services_for_SQL_driver {
! 36: public:
! 37: /// allocates some bytes on pool
! 38: virtual void *malloc(size_t size) =0;
! 39: /// allocates some bytes clearing them with zeros
! 40: virtual void *calloc(size_t size) =0;
! 41: /// throw exception
! 42: virtual void _throw(const char *comment) =0;
! 43: };
! 44:
! 45: #define SQL_DRIVER_API_VERSION 0x0300
! 46:
! 47: /// SQL driver API
! 48: class SQL_Driver {
! 49: public:
! 50:
! 51: /// assignes services to driver. you can not use driver until this
! 52: void set_services(Services_for_SQL_driver *aservices) { fservices=aservices; }
! 53:
! 54: SQL_Driver() :
! 55: fservices(0) {
! 56: }
! 57: /// get api version
! 58: virtual int api_version() =0;
! 59: /// connect. @returns true+'connection' on success. 'error' on failure
! 60: virtual void connect(char *url, void **connection) =0;
! 61: virtual void disconnect(void *connection) =0;
! 62: virtual void commit(void *connection) =0;
! 63: virtual void rollback(void *connection) =0;
! 64: /// log error message
! 65: //static void log(Pool& pool, const char *fmt, ...);
! 66:
! 67: protected:
! 68:
! 69: Services_for_SQL_driver *fservices;
! 70: };
! 71:
! 72: typedef SQL_Driver *(*SQL_Driver_create_func)();
! 73:
! 74: #endif
E-mail: