~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/sql/kernel/qsqldatabase.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtSql module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#ifndef QSQLDATABASE_H
 
43
#define QSQLDATABASE_H
 
44
 
 
45
#include <QtCore/qstring.h>
 
46
#include <QtSql/qsql.h>
 
47
 
 
48
QT_BEGIN_HEADER
 
49
 
 
50
QT_BEGIN_NAMESPACE
 
51
 
 
52
 
 
53
class QSqlError;
 
54
class QSqlDriver;
 
55
class QSqlIndex;
 
56
class QSqlRecord;
 
57
class QSqlQuery;
 
58
class QSqlDatabasePrivate;
 
59
 
 
60
class Q_SQL_EXPORT QSqlDriverCreatorBase
 
61
{
 
62
public:
 
63
    virtual ~QSqlDriverCreatorBase() {}
 
64
    virtual QSqlDriver *createObject() const = 0;
 
65
};
 
66
 
 
67
template <class T>
 
68
class QSqlDriverCreator : public QSqlDriverCreatorBase
 
69
{
 
70
public:
 
71
    QSqlDriver *createObject() const { return new T; }
 
72
};
 
73
 
 
74
class Q_SQL_EXPORT QSqlDatabase
 
75
{
 
76
public:
 
77
    QSqlDatabase();
 
78
    QSqlDatabase(const QSqlDatabase &other);
 
79
    ~QSqlDatabase();
 
80
 
 
81
    QSqlDatabase &operator=(const QSqlDatabase &other);
 
82
 
 
83
    bool open();
 
84
    bool open(const QString& user, const QString& password);
 
85
    void close();
 
86
    bool isOpen() const;
 
87
    bool isOpenError() const;
 
88
    QStringList tables(QSql::TableType type = QSql::Tables) const;
 
89
    QSqlIndex primaryIndex(const QString& tablename) const;
 
90
    QSqlRecord record(const QString& tablename) const;
 
91
    QSqlQuery exec(const QString& query = QString()) const;
 
92
    QSqlError lastError() const;
 
93
    bool isValid() const;
 
94
 
 
95
    bool transaction();
 
96
    bool commit();
 
97
    bool rollback();
 
98
 
 
99
    void setDatabaseName(const QString& name);
 
100
    void setUserName(const QString& name);
 
101
    void setPassword(const QString& password);
 
102
    void setHostName(const QString& host);
 
103
    void setPort(int p);
 
104
    void setConnectOptions(const QString& options = QString());
 
105
    QString databaseName() const;
 
106
    QString userName() const;
 
107
    QString password() const;
 
108
    QString hostName() const;
 
109
    QString driverName() const;
 
110
    int port() const;
 
111
    QString connectOptions() const;
 
112
    QString connectionName() const;
 
113
    void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
 
114
    QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
 
115
 
 
116
    QSqlDriver* driver() const;
 
117
 
 
118
    QT_STATIC_CONST char *defaultConnection;
 
119
 
 
120
    static QSqlDatabase addDatabase(const QString& type,
 
121
                                 const QString& connectionName = QLatin1String(defaultConnection));
 
122
    static QSqlDatabase addDatabase(QSqlDriver* driver,
 
123
                                 const QString& connectionName = QLatin1String(defaultConnection));
 
124
    static QSqlDatabase cloneDatabase(const QSqlDatabase &other, const QString& connectionName);
 
125
    static QSqlDatabase database(const QString& connectionName = QLatin1String(defaultConnection),
 
126
                                 bool open = true);
 
127
    static void removeDatabase(const QString& connectionName);
 
128
    static bool contains(const QString& connectionName = QLatin1String(defaultConnection));
 
129
    static QStringList drivers();
 
130
    static QStringList connectionNames();
 
131
    static void registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator);
 
132
    static bool isDriverAvailable(const QString &name);
 
133
 
 
134
protected:
 
135
    explicit QSqlDatabase(const QString& type);
 
136
    explicit QSqlDatabase(QSqlDriver* driver);
 
137
 
 
138
private:
 
139
    friend class QSqlDatabasePrivate;
 
140
    QSqlDatabasePrivate *d;
 
141
};
 
142
 
 
143
#ifndef QT_NO_DEBUG_STREAM
 
144
Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlDatabase &);
 
145
#endif
 
146
 
 
147
QT_END_NAMESPACE
 
148
 
 
149
QT_END_HEADER
 
150
 
 
151
#endif // QSQLDATABASE_H