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

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtSql module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSQL_PSQL_H
43#define QSQL_PSQL_H
44
45#include <QtSql/qsqlresult.h>
46#include <QtSql/qsqldriver.h>
47
48#ifdef QT_PLUGIN
49#define Q_EXPORT_SQLDRIVER_PSQL
50#else
51#define Q_EXPORT_SQLDRIVER_PSQL Q_SQL_EXPORT
52#endif
53
54QT_BEGIN_HEADER
55
56typedef struct pg_conn PGconn;
57typedef struct pg_result PGresult;
58
59QT_BEGIN_NAMESPACE
60
61class QPSQLResultPrivate;
62class QPSQLDriverPrivate;
63class QPSQLDriver;
64class QSqlRecordInfo;
65
66class QPSQLResult : public QSqlResult
67{
68 friend class QPSQLResultPrivate;
69public:
70 QPSQLResult(const QPSQLDriver* db, const QPSQLDriverPrivate* p);
71 ~QPSQLResult();
72
73 QVariant handle() const;
74 void virtual_hook(int id, void *data);
75
76protected:
77 void cleanup();
78 bool fetch(int i);
79 bool fetchFirst();
80 bool fetchLast();
81 QVariant data(int i);
82 bool isNull(int field);
83 bool reset (const QString& query);
84 int size();
85 int numRowsAffected();
86 QSqlRecord record() const;
87 QVariant lastInsertId() const;
88 bool prepare(const QString& query);
89 bool exec();
90
91private:
92 QPSQLResultPrivate *d;
93};
94
95class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
96{
97 Q_OBJECT
98public:
99 enum Protocol {
100 VersionUnknown = -1,
101 Version6 = 6,
102 Version7 = 7,
103 Version71 = 8,
104 Version73 = 9,
105 Version74 = 10,
106 Version8 = 11,
107 Version81 = 12,
108 Version82 = 13,
109 Version83 = 14,
110 Version84 = 15,
111 Version9 = 16,
112 };
113
114 explicit QPSQLDriver(QObject *parent=0);
115 explicit QPSQLDriver(PGconn *conn, QObject *parent=0);
116 ~QPSQLDriver();
117 bool hasFeature(DriverFeature f) const;
118 bool open(const QString & db,
119 const QString & user,
120 const QString & password,
121 const QString & host,
122 int port,
123 const QString& connOpts);
124 bool isOpen() const;
125 void close();
126 QSqlResult *createResult() const;
127 QStringList tables(QSql::TableType) const;
128 QSqlIndex primaryIndex(const QString& tablename) const;
129 QSqlRecord record(const QString& tablename) const;
130
131 Protocol protocol() const;
132 QVariant handle() const;
133
134 QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
135 QString formatValue(const QSqlField &field, bool trimStrings) const;
136
137protected:
138 bool beginTransaction();
139 bool commitTransaction();
140 bool rollbackTransaction();
141
142protected Q_SLOTS:
143 bool subscribeToNotificationImplementation(const QString &name);
144 bool unsubscribeFromNotificationImplementation(const QString &name);
145 QStringList subscribedToNotificationsImplementation() const;
146
147private Q_SLOTS:
148 void _q_handleNotification(int);
149
150private:
151 void init();
152 QPSQLDriverPrivate *d;
153};
154
155QT_END_NAMESPACE
156
157QT_END_HEADER
158
159#endif // QSQL_PSQL_H
Note: See TracBrowser for help on using the repository browser.