0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 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 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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 |
|
|
54 |
QT_BEGIN_HEADER
|
|
55 |
|
|
56 |
typedef struct pg_conn PGconn;
|
|
57 |
typedef struct pg_result PGresult;
|
|
58 |
|
|
59 |
QT_BEGIN_NAMESPACE
|
|
60 |
|
|
61 |
class QPSQLResultPrivate;
|
|
62 |
class QPSQLDriverPrivate;
|
|
63 |
class QPSQLDriver;
|
|
64 |
class QSqlRecordInfo;
|
|
65 |
|
|
66 |
class QPSQLResult : public QSqlResult
|
|
67 |
{
|
|
68 |
friend class QPSQLResultPrivate;
|
|
69 |
public:
|
|
70 |
QPSQLResult(const QPSQLDriver* db, const QPSQLDriverPrivate* p);
|
|
71 |
~QPSQLResult();
|
|
72 |
|
|
73 |
QVariant handle() const;
|
|
74 |
void virtual_hook(int id, void *data);
|
|
75 |
|
|
76 |
protected:
|
|
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 |
|
|
91 |
private:
|
|
92 |
QPSQLResultPrivate *d;
|
|
93 |
};
|
|
94 |
|
|
95 |
class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
|
|
96 |
{
|
|
97 |
Q_OBJECT
|
|
98 |
public:
|
|
99 |
enum Protocol {
|
|
100 |
Version6 = 6,
|
|
101 |
Version7 = 7,
|
|
102 |
Version71 = 8,
|
|
103 |
Version73 = 9,
|
|
104 |
Version74 = 10,
|
|
105 |
Version8 = 11,
|
|
106 |
Version81 = 12,
|
|
107 |
Version82 = 13
|
|
108 |
};
|
|
109 |
|
|
110 |
explicit QPSQLDriver(QObject *parent=0);
|
|
111 |
explicit QPSQLDriver(PGconn *conn, QObject *parent=0);
|
|
112 |
~QPSQLDriver();
|
|
113 |
bool hasFeature(DriverFeature f) const;
|
|
114 |
bool open(const QString & db,
|
|
115 |
const QString & user,
|
|
116 |
const QString & password,
|
|
117 |
const QString & host,
|
|
118 |
int port,
|
|
119 |
const QString& connOpts);
|
|
120 |
bool isOpen() const;
|
|
121 |
void close();
|
|
122 |
QSqlResult *createResult() const;
|
|
123 |
QStringList tables(QSql::TableType) const;
|
|
124 |
QSqlIndex primaryIndex(const QString& tablename) const;
|
|
125 |
QSqlRecord record(const QString& tablename) const;
|
|
126 |
|
|
127 |
Protocol protocol() const;
|
|
128 |
QVariant handle() const;
|
|
129 |
|
|
130 |
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
|
|
131 |
QString formatValue(const QSqlField &field, bool trimStrings) const;
|
|
132 |
|
|
133 |
protected:
|
|
134 |
bool beginTransaction();
|
|
135 |
bool commitTransaction();
|
|
136 |
bool rollbackTransaction();
|
|
137 |
|
|
138 |
protected Q_SLOTS:
|
|
139 |
bool subscribeToNotificationImplementation(const QString &name);
|
|
140 |
bool unsubscribeFromNotificationImplementation(const QString &name);
|
|
141 |
QStringList subscribedToNotificationsImplementation() const;
|
|
142 |
|
|
143 |
private Q_SLOTS:
|
|
144 |
void _q_handleNotification(int);
|
|
145 |
|
|
146 |
private:
|
|
147 |
void init();
|
|
148 |
QPSQLDriverPrivate *d;
|
|
149 |
};
|
|
150 |
|
|
151 |
QT_END_NAMESPACE
|
|
152 |
|
|
153 |
QT_END_HEADER
|
|
154 |
|
|
155 |
#endif // QSQL_PSQL_H
|