From e4ad28e8c58e289d281a99a5aa3ca25919be5d0c Mon Sep 17 00:00:00 2001 From: gsherman Date: Mon, 22 Nov 2004 07:08:04 +0000 Subject: [PATCH] PostgreSQL utility class (singleton). This is not used anywhere yet and is not complete. git-svn-id: http://svn.osgeo.org/qgis/trunk@2308 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgspgutil.cpp | 8 ++++++++ src/qgspgutil.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/qgspgutil.cpp b/src/qgspgutil.cpp index f51da16a435..c74cc87a4a0 100644 --- a/src/qgspgutil.cpp +++ b/src/qgspgutil.cpp @@ -40,6 +40,14 @@ bool QgsPgUtil::isReserved(QString word) QStringList::iterator it = mReservedWords.find(word.upper()); return (it != mReservedWords.end()); } +void QgsPgUtil::setConnection(PGconn *con) +{ + mPgConnection = con; +} +PGconn *QgsPgUtil::connection() +{ + return mPgConnection; +} void QgsPgUtil::initReservedWords() { // create the reserved word list by loading diff --git a/src/qgspgutil.h b/src/qgspgutil.h index d5c920420f1..341bc01c501 100644 --- a/src/qgspgutil.h +++ b/src/qgspgutil.h @@ -17,6 +17,11 @@ #define QGSPGUTIL_H #include #include +extern "C" +{ + #include +} + /*! * \class QgsPgUtil * \brief Class containing utility functions for working with PostgreSQL @@ -34,6 +39,16 @@ class QgsPgUtil * @return True if word is a PG reserved word */ bool isReserved(QString word); + /*! + * Set the connection to be used in database operations + * @param con Pointer to an active PostgreSQL connection + */ + void setConnection(PGconn *con); + /*! + * Get the connection currently in use for database operations + * @return Pointer to the PostgreSQL connection object + */ + PGconn *connection(); protected: //! Protected constructor QgsPgUtil(); @@ -46,5 +61,7 @@ class QgsPgUtil static QgsPgUtil* mInstance; //! Reserved word list QStringList mReservedWords; + //! PostgreSQL connection + PGconn *mPgConnection; }; #endif // QGSPGUTIL_H