Eneboo - Documentación para desarrolladores
src/qt/src/sql/drivers/psql/qsql_psql.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 **
00003 ** Definition of PostgreSQL driver classes
00004 **
00005 ** Created : 001103
00006 **
00007 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00008 **
00009 ** This file is part of the sql module of the Qt GUI Toolkit.
00010 **
00011 ** This file may be distributed under the terms of the Q Public License
00012 ** as defined by Trolltech ASA of Norway and appearing in the file
00013 ** LICENSE.QPL included in the packaging of this file.
00014 **
00015 ** This file may be distributed and/or modified under the terms of the
00016 ** GNU General Public License version 2 as published by the Free Software
00017 ** Foundation and appearing in the file LICENSE.GPL included in the
00018 ** packaging of this file.
00019 **
00020 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00021 ** file in accordance with the Qt Commercial License Agreement provided
00022 ** with the Software.
00023 **
00024 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00025 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00026 **
00027 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00028 **   information about Qt Commercial License Agreements.
00029 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00030 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00031 **
00032 ** Contact info@trolltech.com if any conditions of this licensing are
00033 ** not clear to you.
00034 **
00035 **********************************************************************/
00036 
00037 #ifndef QSQL_PSQL_H
00038 #define QSQL_PSQL_H
00039 
00040 #include <qsqlresult.h>
00041 #include <qsqlfield.h>
00042 #include <qsqldriver.h>
00043 #include <libpq-fe.h>
00044 
00045 #ifdef QT_PLUGIN
00046 #define Q_EXPORT_SQLDRIVER_PSQL
00047 #else
00048 #define Q_EXPORT_SQLDRIVER_PSQL Q_EXPORT
00049 #endif
00050 
00051 class QPSQLPrivate;
00052 class QPSQLDriver;
00053 class QSqlRecordInfo;
00054 
00055 class QPSQLResult : public QSqlResult
00056 {
00057     friend class QPSQLDriver;
00058 public:
00059     QPSQLResult( const QPSQLDriver* db, const QPSQLPrivate* p );
00060     ~QPSQLResult();
00061     PGresult* result();
00062 protected:
00063     void                cleanup();
00064     bool                fetch( int i );
00065     bool                fetchFirst();
00066     bool                fetchLast();
00067     QVariant            data( int i );
00068     bool                isNull( int field );
00069     bool                reset ( const QString& query );
00070     int                 size();
00071     int                 numRowsAffected();
00072 private:
00073     int                 currentSize;
00074     QPSQLPrivate*       d;
00075 };
00076 
00077 class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
00078 {
00079 Q_OBJECT
00080 public:
00081     enum Protocol {
00082         Version6 = 6,
00083         Version7 = 7,
00084         Version71 = 8,
00085         Version73 = 9
00086     };
00087 
00088     QPSQLDriver( QObject * parent=0, const char * name=0 );
00089     QPSQLDriver( PGconn * conn, QObject * parent=0, const char * name=0 );
00090     ~QPSQLDriver();
00091     bool                hasFeature( DriverFeature f ) const;
00092     bool                open( const QString & db,
00093                                 const QString & user = QString::null,
00094                                 const QString & password = QString::null,
00095                                 const QString & host = QString::null,
00096                                 int port = -1 );
00097     void                close();
00098     QSqlQuery           createQuery() const;
00099     QStringList         tables( const QString& user ) const;
00100     QSqlIndex           primaryIndex( const QString& tablename ) const;
00101     QSqlRecord          record( const QString& tablename ) const;
00102     QSqlRecord          record( const QSqlQuery& query ) const;
00103     QSqlRecordInfo      recordInfo( const QString& tablename ) const;
00104     QSqlRecordInfo      recordInfo( const QSqlQuery& query ) const;
00105 
00106     Protocol            protocol() const { return pro; }
00107     PGconn*             connection();
00108     QString             formatValue( const QSqlField* field,
00109                                      bool trimStrings ) const;
00110     
00111     // ### remove me for 4.0
00112     bool open( const QString& db,
00113                const QString& user,
00114                const QString& password,
00115                const QString& host,
00116                int port,
00117                const QString& connOpts );
00118 protected:
00119     bool                beginTransaction();
00120     bool                commitTransaction();
00121     bool                rollbackTransaction();
00122 private:
00123     void                init();
00124     Protocol            pro;
00125     QPSQLPrivate*       d;
00126 };
00127 
00128 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'