* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pgconnection.h,v 1.10 2001/02/10 02:31:30 tgl Exp $
+ * $Id: pgconnection.h,v 1.11 2001/05/09 17:29:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
#ifdef HAVE_NAMESPACE_STD
-using namespace std;
+#define PGSTD std::
+#else
+#define PGSTD
#endif
// derived from this class to obtain the connection interface.
class PgConnection {
protected:
- PGconn* pgConn; // Connection Structure
+ PGconn* pgConn; // Connection Structure
PGresult* pgResult; // Current Query Result
- int pgCloseConnection; // TRUE if connection should be closed by destructor
+ bool pgCloseConnection; // true if connection should be closed by destructor
public:
- PgConnection(const char* conninfo); // use reasonable & environment defaults
+ explicit PgConnection(const char* conninfo); // use reasonable & environment defaults
virtual ~PgConnection(); // close connection and clean up
// Connection status and error messages
- ConnStatusType Status();
- int ConnectionBad();
- const char* ErrorMessage();
+ ConnStatusType Status() const;
+ bool ConnectionBad() const;
+ const char* ErrorMessage() const;
// returns the database name of the connection
- const char* DBName();
+ const char* DBName() const;
// Query Execution interface
ExecStatusType Exec(const char* query); // send a query to the backend
protected:
ConnStatusType Connect(const char* conninfo);
void CloseConnection();
- string IntToString(int);
+ static PGSTD string IntToString(int);
// Default constructor is only available to subclasses
PgConnection();
PgConnection& operator= (const PgConnection&);
};
+
+#ifdef HAVE_NAMESPACE_STD
+#undef PGSTD
+#endif
+
+
#endif // PGCONNECTION_H