Annotation of parser3/src/sql/pa_sql_driver.h, revision 1.2
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:
1.2 ! paf 8: $Id: pa_sql_driver.h,v 1.1 2001/04/05 08:09:25 paf Exp $
1.1 paf 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:
1.2 ! paf 32: #include <sys/types.h>
1.1 paf 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:
1.2 ! paf 51: struct Cell {
! 52: void *ptr;
! 53: size_t size;
! 54: };
! 55:
! 56: public:
! 57:
1.1 paf 58: /// assignes services to driver. you can not use driver until this
59: void set_services(Services_for_SQL_driver *aservices) { fservices=aservices; }
60:
61: SQL_Driver() :
62: fservices(0) {
63: }
64: /// get api version
65: virtual int api_version() =0;
66: /// connect. @returns true+'connection' on success. 'error' on failure
67: virtual void connect(char *url, void **connection) =0;
68: virtual void disconnect(void *connection) =0;
69: virtual void commit(void *connection) =0;
70: virtual void rollback(void *connection) =0;
1.2 ! paf 71: virtual void query(void *connection,
! 72: const char *statement,
! 73: unsigned int *column_count, Cell **columns,
! 74: unsigned long *row_count, Cell ***rows) =0;
1.1 paf 75: /// log error message
76: //static void log(Pool& pool, const char *fmt, ...);
77:
78: protected:
79:
80: Services_for_SQL_driver *fservices;
81: };
82:
83: typedef SQL_Driver *(*SQL_Driver_create_func)();
84:
85: #endif
E-mail: