Diff for /parser3/src/include/pa_sql_connection.h between versions 1.2 and 1.16

version 1.2, 2001/04/05 11:01:55 version 1.16, 2001/10/29 17:34:24
Line 1 Line 1
 /** @file  /** @file
         Parser: sql connection decl.          Parser: sql fconnection decl.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$          $Id$
Line 11 Line 10
 #ifndef PA_SQL_CONNECTION_H  #ifndef PA_SQL_CONNECTION_H
 #define PA_SQL_CONNECTION_H  #define PA_SQL_CONNECTION_H
   
   #include "pa_config_includes.h"
 #include "pa_pool.h"  #include "pa_pool.h"
 #include "pa_sql_driver.h"  #include "pa_sql_driver.h"
 #include "pa_exception.h"  #include "pa_sql_driver_manager.h"
   
   // defines
   
 /// sql connection  /// @see SQL_Driver_services_impl::_throw
   #define SQL_CONNECTION_FUNC_GUARDED(actions) \
           if(!fservices || !setjmp(fservices->mark)) { \
                   actions; \
           } else \
                   fservices->propagate_exception();
   
   /// SQL connection. handy wrapper around low level SQL_Driver
 class SQL_Connection : public Pooled {  class SQL_Connection : public Pooled {
   
 public:  public:
   
         void set_services(Services_for_SQL_driver *services) {          SQL_Connection(Pool& pool, const String& aurl, SQL_Driver& adriver) : Pooled(pool),
                 fdriver.set_services(services);  
         }  
   
         SQL_Connection(Pool& pool,  
                 const String& aurl,   
                 SQL_Driver& adriver, Services_for_SQL_driver& services,   
                 char *url_cstr) : Pooled(pool),  
                 furl(aurl),                  furl(aurl),
                 fdriver(adriver) {                  fdriver(adriver),
                   fconnection(0),
                   time_stamp(0) {
           }
           
           const String& url() { return furl; }
   
                 set_services(&services); // associate with services[request]          void set_services(SQL_Driver_services *aservices) {
                 fdriver.connect(url_cstr, &connection);                  time_stamp=time(0); // they started to use at this time
                   fservices=aservices;
           }
           bool expired(time_t older_dies) {
                   return time_stamp<older_dies;
         }          }
   
         void close() {          void close() {
                 set_services(0); // deassociate from services[request]  
                 SQL_driver_manager->close_connection(furl, *this);                  SQL_driver_manager->close_connection(furl, *this);
         }          }
   
         void disconnect() { fdriver.disconnect(connection); }          bool connected() { return fconnection!=0; }
         void commit() { fdriver.commit(connection); }          void connect(char *used_only_in_connect_url_cstr) { 
         void rollback() { fdriver.rollback(connection); }                  SQL_CONNECTION_FUNC_GUARDED(
                           fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection)
                   );
           }
           void disconnect() { 
                   fdriver.disconnect(fconnection); fconnection=0; 
           }
           void commit() { 
                   SQL_CONNECTION_FUNC_GUARDED(
                           fdriver.commit(*fservices, fconnection) 
                   );
           }
           void rollback() { 
                   SQL_CONNECTION_FUNC_GUARDED(
                           fdriver.rollback(*fservices, fconnection)
                   );
           }
           bool ping() { 
                   SQL_CONNECTION_FUNC_GUARDED(
                           return fdriver.ping(*fservices, fconnection)
                   );
                   return 0; // never reached
           }
           uint quote(char *to, const char *from, unsigned int length) {
                   SQL_CONNECTION_FUNC_GUARDED(
                           return fdriver.quote(*fservices, fconnection, to, from, length)
                   );
                   return 0; // never reached
           }
   
         void query(          void query(
                 const char *statement,                   const char *statement, unsigned long offset, unsigned long limit,
                 unsigned int *column_count, SQL_Driver::Cell **columns,                  SQL_Driver_query_event_handlers& handlers) { 
                 unsigned long *row_count, SQL_Driver::Cell ***rows) {                   SQL_CONNECTION_FUNC_GUARDED(
                 fdriver.query(connection,                           fdriver.query(*fservices, fconnection, 
                         statement,                                   statement, offset, limit, 
                         column_count, columns,                                  handlers)
                         row_count, rows);                  );
         }          }
   
   
 private:  private:
   
         SQL_Driver& fdriver;  
         void *connection;  
         const String& furl;          const String& furl;
           SQL_Driver& fdriver;
           SQL_Driver_services *fservices;
           void *fconnection;
           time_t time_stamp;
 };  };
   
 #endif  #endif

Removed from v.1.2  
changed lines
  Added in v.1.16


E-mail: