--- parser3/src/sql/pa_sql_driver.h 2001/05/17 13:23:28 1.10 +++ parser3/src/sql/pa_sql_driver.h 2001/11/05 11:46:29 1.20 @@ -2,10 +2,9 @@ Parser: sql driver interface. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://paf.design.ru) - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: pa_sql_driver.h,v 1.10 2001/05/17 13:23:28 parser Exp $ + $Id: pa_sql_driver.h,v 1.20 2001/11/05 11:46:29 paf Exp $ driver dynamic library must look like this: @@ -38,22 +37,30 @@ public: virtual void *malloc(size_t size) =0; /// allocates some bytes clearing them with zeros virtual void *calloc(size_t size) =0; - /// throw exception + /// prepare throw exception virtual void _throw(const char *comment) =0; + /// throw C++ exception from prepared + virtual void propagate_exception() =0; +public: + /// regretrully public, because can't make stack frames: "nowhere to return to" + jmp_buf mark; }; -#define SQL_DRIVER_API_VERSION 0x0301 +#define SQL_DRIVER_API_VERSION 0x0100 +#define SQL_DRIVER_CREATE create +#define SQL_DRIVER_CREATE_NAME "create" /* could not figure out how to # it :( */ -/// SQL driver API -class SQL_Driver { +/// events, occuring when SQL_Driver::query()-ing +class SQL_Driver_query_event_handlers { public: + virtual void add_column(void *ptr, size_t size) =0; + virtual void before_rows() =0; + virtual void add_row() =0; + virtual void add_row_cell(void *ptr, size_t size) =0; +}; - /// row cell & column title storage - struct Cell { - void *ptr; - size_t size; - }; - +/// SQL driver API +class SQL_Driver { public: SQL_Driver() {} @@ -70,8 +77,7 @@ public: */ virtual void connect(char *used_only_in_connect_url_cstr, SQL_Driver_services& services, void **connection) =0; - virtual void disconnect( - SQL_Driver_services& services, void *connection) =0; + virtual void disconnect(void *connection) =0; virtual void commit( SQL_Driver_services& services, void *connection) =0; virtual void rollback( @@ -86,11 +92,7 @@ public: virtual void query( SQL_Driver_services& services, void *connection, const char *statement, unsigned long offset, unsigned long limit, - unsigned int *column_count, Cell **columns, - unsigned long *row_count, Cell ***rows) =0; - /// log error message - //static void log(Pool& pool, const char *fmt, ...); - + SQL_Driver_query_event_handlers& handlers) =0; }; typedef SQL_Driver *(*SQL_Driver_create_func)();