source: trunk/src/sql/drivers/psql/qsql_psql.h

Last change on this file was 196, checked in by rudi, 14 years ago

Add SQL module (currently it isn't build by default, however it's needed for QtDesigner)

File size: 3.9 KB
Line 
1/****************************************************************************
2**
3** Definition of PostgreSQL driver classes
4**
5** Created : 001103
6**
7** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
8**
9** This file is part of the sql module of the Qt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech ASA of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided
22** with the Software.
23**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36
37#ifndef QSQL_PSQL_H
38#define QSQL_PSQL_H
39
40#include <qsqlresult.h>
41#include <qsqlfield.h>
42#include <qsqldriver.h>
43#include <libpq-fe.h>
44
45#ifdef QT_PLUGIN
46#define Q_EXPORT_SQLDRIVER_PSQL
47#else
48#define Q_EXPORT_SQLDRIVER_PSQL Q_EXPORT
49#endif
50
51class QPSQLPrivate;
52class QPSQLDriver;
53class QSqlRecordInfo;
54
55class QPSQLResult : public QSqlResult
56{
57 friend class QPSQLDriver;
58public:
59 QPSQLResult( const QPSQLDriver* db, const QPSQLPrivate* p );
60 ~QPSQLResult();
61 PGresult* result();
62protected:
63 void cleanup();
64 bool fetch( int i );
65 bool fetchFirst();
66 bool fetchLast();
67 QVariant data( int i );
68 bool isNull( int field );
69 bool reset ( const QString& query );
70 int size();
71 int numRowsAffected();
72private:
73 int currentSize;
74 QPSQLPrivate* d;
75};
76
77class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
78{
79public:
80 enum Protocol {
81 Version6 = 6,
82 Version7 = 7,
83 Version71 = 8,
84 Version73 = 9
85 };
86
87 QPSQLDriver( QObject * parent=0, const char * name=0 );
88 QPSQLDriver( PGconn * conn, QObject * parent=0, const char * name=0 );
89 ~QPSQLDriver();
90 bool hasFeature( DriverFeature f ) const;
91 bool open( const QString & db,
92 const QString & user = QString::null,
93 const QString & password = QString::null,
94 const QString & host = QString::null,
95 int port = -1 );
96 void close();
97 QSqlQuery createQuery() const;
98 QStringList tables( const QString& user ) const;
99 QSqlIndex primaryIndex( const QString& tablename ) const;
100 QSqlRecord record( const QString& tablename ) const;
101 QSqlRecord record( const QSqlQuery& query ) const;
102 QSqlRecordInfo recordInfo( const QString& tablename ) const;
103 QSqlRecordInfo recordInfo( const QSqlQuery& query ) const;
104
105 Protocol protocol() const { return pro; }
106 PGconn* connection();
107 QString formatValue( const QSqlField* field,
108 bool trimStrings ) const;
109
110 // ### remove me for 4.0
111 bool open( const QString& db,
112 const QString& user,
113 const QString& password,
114 const QString& host,
115 int port,
116 const QString& connOpts );
117protected:
118 bool beginTransaction();
119 bool commitTransaction();
120 bool rollbackTransaction();
121private:
122 void init();
123 Protocol pro;
124 QPSQLPrivate* d;
125};
126
127#endif
Note: See TracBrowser for help on using the repository browser.