00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pqxx/libcompiler.h"
00020
00021 #include "pqxx/connection_base"
00022
00023
00024
00025
00026
00027 namespace pqxx
00028 {
00029
00031
00047 class PQXX_LIBEXPORT connection : public connection_base
00048 {
00049 public:
00051
00055 connection();
00056
00058
00068 explicit connection(const PGSTD::string &ConnInfo);
00069
00071
00079 explicit connection(const char ConnInfo[]);
00080
00081 virtual ~connection() throw ();
00082
00083 private:
00084 virtual void startconnect() { do_startconnect(); }
00085 virtual void completeconnect() {}
00086
00087 void do_startconnect()
00088 { if (!get_conn()) set_conn(PQXXPQ::PQconnectdb(options())); }
00089 };
00090
00091
00093
00101 class PQXX_LIBEXPORT lazyconnection : public connection_base
00102 {
00103 public:
00105 lazyconnection() : connection_base(0) {}
00106
00108
00116 explicit lazyconnection(const PGSTD::string &ConnInfo) :
00117 connection_base(ConnInfo) {}
00118
00120
00129 explicit lazyconnection(const char ConnInfo[]) :
00130 connection_base(ConnInfo) {}
00131
00132 virtual ~lazyconnection() throw ();
00133
00134 private:
00135 virtual void startconnect() {}
00136 virtual void completeconnect()
00137 { if (!get_conn()) set_conn(PQXXPQ::PQconnectdb(options())); }
00138 };
00139
00140
00142
00148 class PQXX_LIBEXPORT asyncconnection : public connection_base
00149 {
00150 public:
00152 asyncconnection();
00153
00155
00163 explicit asyncconnection(const PGSTD::string &ConnInfo);
00164
00166
00175 explicit asyncconnection(const char ConnInfo[]);
00176
00177 virtual ~asyncconnection() throw ();
00178
00179 private:
00180 virtual void startconnect() { do_startconnect(); }
00181 virtual void completeconnect();
00182 virtual void dropconnect() throw () { do_dropconnect(); }
00183
00184 void do_startconnect();
00185 void do_dropconnect() throw () { m_connecting = false; }
00186
00188 bool m_connecting;
00189 };
00190
00191
00193
00198 class PQXX_LIBEXPORT nullconnection : public connection_base
00199 {
00200 public:
00202 nullconnection() : connection_base("") {}
00204 explicit nullconnection(const PGSTD::string &c) :
00205 connection_base(c) {}
00207 explicit nullconnection(const char c[]) :
00208 connection_base(c) {}
00209
00210 virtual ~nullconnection() throw ();
00211
00212 private:
00213 virtual void startconnect() {}
00214 virtual void completeconnect() {}
00215 };
00216
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226 #ifdef _WIN32
00227 inline pqxx::connection::~connection() throw () { close(); }
00228 inline pqxx::lazyconnection::~lazyconnection() throw () { close(); }
00229 inline pqxx::asyncconnection::~asyncconnection() throw () {do_dropconnect();close();}
00230 #endif
00231