00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pqxx/connection_base"
00020
00021
00022
00023
00024
00025 namespace pqxx
00026 {
00027
00029
00045 class PQXX_LIBEXPORT connection : public connection_base
00046 {
00047 public:
00049
00053 connection();
00054
00056
00066 explicit connection(const PGSTD::string &ConnInfo);
00067
00069
00077 explicit connection(const char ConnInfo[]);
00078
00079 virtual ~connection() throw ();
00080
00081 private:
00082 virtual void startconnect() { do_startconnect(); }
00083 virtual void completeconnect() {}
00084
00085 void do_startconnect() { if (!get_conn()) set_conn(PQconnectdb(options())); }
00086 };
00087
00088
00090
00098 class PQXX_LIBEXPORT lazyconnection : public connection_base
00099 {
00100 public:
00102 lazyconnection() : connection_base(0) {}
00103
00105
00113 explicit lazyconnection(const PGSTD::string &ConnInfo) :
00114 connection_base(ConnInfo) {}
00115
00117
00126 explicit lazyconnection(const char ConnInfo[]) :
00127 connection_base(ConnInfo) {}
00128
00129 virtual ~lazyconnection() throw ();
00130
00131 private:
00132 virtual void startconnect() {}
00133 virtual void completeconnect()
00134 { if (!get_conn()) set_conn(PQconnectdb(options())); }
00135 };
00136
00137
00139 class PQXX_LIBEXPORT asyncconnection : public connection_base
00140 {
00141 public:
00143 asyncconnection();
00144
00146
00154 explicit asyncconnection(const PGSTD::string &ConnInfo);
00155
00157
00166 explicit asyncconnection(const char ConnInfo[]);
00167
00168 virtual ~asyncconnection() throw ();
00169
00170 private:
00171 virtual void startconnect() { do_startconnect(); }
00172 virtual void completeconnect();
00173 virtual void dropconnect() throw () { do_dropconnect(); }
00174
00175 void do_startconnect();
00176 void do_dropconnect() throw () { m_connecting = false; }
00177
00179 bool m_connecting;
00180 };
00181
00182
00184
00189 class PQXX_LIBEXPORT nullconnection : public connection_base
00190 {
00191 public:
00193 nullconnection() : connection_base("") {}
00195 explicit nullconnection(const PGSTD::string &c) :
00196 connection_base(c) {}
00198 explicit nullconnection(const char c[]) :
00199 connection_base(c) {}
00200
00201 virtual ~nullconnection() throw ();
00202
00203 private:
00204 virtual void startconnect() {}
00205 virtual void completeconnect() {}
00206 };
00207
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217 #ifdef _WIN32
00218 pqxx::connection::~connection() throw () { close(); }
00219 pqxx::lazyconnection::~lazyconnection() throw () { close(); }
00220 pqxx::asyncconnection::~asyncconnection() throw () {do_dropconnect();close();}
00221 #endif
00222