~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/sql/drivers/psql/qsql_psql.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the sql module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
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
****************************************************************************/
 
28
 
 
29
#ifndef QSQL_PSQL_H
 
30
#define QSQL_PSQL_H
 
31
 
 
32
#include <QtSql/qsqlresult.h>
 
33
#include <QtSql/qsqldriver.h>
 
34
 
 
35
#ifdef QT_PLUGIN
 
36
#define Q_EXPORT_SQLDRIVER_PSQL
 
37
#else
 
38
#define Q_EXPORT_SQLDRIVER_PSQL Q_SQL_EXPORT
 
39
#endif
 
40
 
 
41
typedef struct pg_conn PGconn;
 
42
typedef struct pg_result PGresult;
 
43
 
 
44
class QPSQLResultPrivate;
 
45
class QPSQLDriverPrivate;
 
46
class QPSQLDriver;
 
47
class QSqlRecordInfo;
 
48
 
 
49
class QPSQLResult : public QSqlResult
 
50
{
 
51
    friend class QPSQLResultPrivate;
 
52
public:
 
53
    QPSQLResult(const QPSQLDriver* db, const QPSQLDriverPrivate* p);
 
54
    ~QPSQLResult();
 
55
 
 
56
    QVariant handle() const;
 
57
 
 
58
protected:
 
59
    void cleanup();
 
60
    bool fetch(int i);
 
61
    bool fetchFirst();
 
62
    bool fetchLast();
 
63
    QVariant data(int i);
 
64
    bool isNull(int field);
 
65
    bool reset (const QString& query);
 
66
    int size();
 
67
    int numRowsAffected();
 
68
    QSqlRecord record() const;
 
69
    QVariant lastInsertId() const;
 
70
 
 
71
private:
 
72
    QPSQLResultPrivate *d;
 
73
};
 
74
 
 
75
class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
 
76
{
 
77
    Q_OBJECT
 
78
public:
 
79
    enum Protocol {
 
80
        Version6 = 6,
 
81
        Version7 = 7,
 
82
        Version71 = 8,
 
83
        Version73 = 9
 
84
    };
 
85
 
 
86
    explicit QPSQLDriver(QObject *parent=0);
 
87
    explicit QPSQLDriver(PGconn *conn, QObject *parent=0);
 
88
    ~QPSQLDriver();
 
89
    bool hasFeature(DriverFeature f) const;
 
90
    bool open(const QString & db,
 
91
              const QString & user,
 
92
              const QString & password,
 
93
              const QString & host,
 
94
              int port,
 
95
              const QString& connOpts);
 
96
    bool isOpen() const;
 
97
    void close();
 
98
    QSqlResult *createResult() const;
 
99
    QStringList tables(QSql::TableType) const;
 
100
    QSqlIndex primaryIndex(const QString& tablename) const;
 
101
    QSqlRecord record(const QString& tablename) const;
 
102
 
 
103
    Protocol protocol() const;
 
104
    QVariant handle() const;
 
105
 
 
106
    QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
 
107
    QString formatValue(const QSqlField &field,
 
108
                                     bool trimStrings) const;
 
109
 
 
110
protected:
 
111
    bool beginTransaction();
 
112
    bool commitTransaction();
 
113
    bool rollbackTransaction();
 
114
private:
 
115
    void init();
 
116
    QPSQLDriverPrivate *d;
 
117
};
 
118
 
 
119
#endif // QSQL_PSQL_H