OSDN Git Service

use proper type for written bytes count in QFileSystemEngine::copyFile()
[kde/Katie.git] / src / sql / drivers / qsql_sqlite_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Copyright (C) 2016 Ivailo Monev
5 **
6 ** This file is part of the QtSql module of the Katie Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 **
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser
12 ** General Public License version 2.1 as published by the Free Software
13 ** Foundation and appearing in the file LICENSE.LGPL included in the
14 ** packaging of this file.  Please review the following information to
15 ** ensure the GNU Lesser General Public License version 2.1 requirements
16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** $QT_END_LICENSE$
19 **
20 ****************************************************************************/
21
22 #ifndef QSQL_SQLITE_H
23 #define QSQL_SQLITE_H
24
25 #include "qsqldriver.h"
26 #include "qsqlresult.h"
27 #include "qsqlcachedresult_p.h"
28
29 struct sqlite3;
30
31
32 QT_BEGIN_NAMESPACE
33 class QSQLiteDriverPrivate;
34 class QSQLiteResultPrivate;
35 class QSQLiteDriver;
36
37 class QSQLiteResult : public QSqlCachedResult
38 {
39     friend class QSQLiteDriver;
40     friend class QSQLiteResultPrivate;
41 public:
42     explicit QSQLiteResult(const QSQLiteDriver* db);
43     ~QSQLiteResult();
44     QVariant handle() const;
45
46 protected:
47     bool gotoNext(QSqlCachedResult::ValueCache& row, int idx);
48     bool reset(const QString &query);
49     bool prepare(const QString &query);
50     bool exec();
51     int size() const;
52     int numRowsAffected() const;
53     QVariant lastInsertId() const;
54     QSqlRecord record() const;
55     void virtual_hook(int id, void *data);
56
57 private:
58     QSQLiteResultPrivate* d;
59 };
60
61 class Q_SQL_EXPORT QSQLiteDriver : public QSqlDriver
62 {
63     Q_OBJECT
64     friend class QSQLiteResult;
65 public:
66     explicit QSQLiteDriver(QObject *parent = nullptr);
67     explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = nullptr);
68     ~QSQLiteDriver();
69     bool hasFeature(DriverFeature f) const;
70     bool open(const QString & db,
71                    const QString & user,
72                    const QString & password,
73                    const QString & host,
74                    int port,
75                    const QString & connOpts);
76     void close();
77     QSqlResult *createResult() const;
78     bool beginTransaction();
79     bool commitTransaction();
80     bool rollbackTransaction();
81     QStringList tables(QSql::TableType) const;
82
83     QSqlRecord record(const QString& tablename) const;
84     QSqlIndex primaryIndex(const QString &table) const;
85     QVariant handle() const;
86     QString escapeIdentifier(const QString &identifier, IdentifierType) const;
87
88 private:
89     QSQLiteDriverPrivate* d;
90 };
91
92 QT_END_NAMESPACE
93
94
95 #endif // QSQL_SQLITE_H