QtSql/qsql_sqlite.h Source File

qsql_sqlite.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 QSQL_SQLITE_H
43 #define QSQL_SQLITE_H
44 
45 #include <QtSql/qsqldriver.h>
46 #include <QtSql/qsqlresult.h>
47 #include <QtSql/private/qsqlcachedresult_p.h>
48 
49 struct sqlite3;
50 
51 #ifdef QT_PLUGIN
52 #define Q_EXPORT_SQLDRIVER_SQLITE
53 #else
54 #define Q_EXPORT_SQLDRIVER_SQLITE Q_SQL_EXPORT
55 #endif
56 
58 
60 class QSQLiteDriverPrivate;
61 class QSQLiteResultPrivate;
62 class QSQLiteDriver;
63 
64 class QSQLiteResult : public QSqlCachedResult
65 {
66  friend class QSQLiteDriver;
67  friend class QSQLiteResultPrivate;
68 public:
69  explicit QSQLiteResult(const QSQLiteDriver* db);
71  QVariant handle() const;
72 
73 protected:
74  bool gotoNext(QSqlCachedResult::ValueCache& row, int idx);
75  bool reset(const QString &query);
76  bool prepare(const QString &query);
77  bool exec();
78  int size();
79  int numRowsAffected();
80  QVariant lastInsertId() const;
81  QSqlRecord record() const;
82  void virtual_hook(int id, void *data);
83 
84 private:
86 };
87 
89 {
90  Q_OBJECT
91  friend class QSQLiteResult;
92 public:
93  explicit QSQLiteDriver(QObject *parent = 0);
94  explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = 0);
95  ~QSQLiteDriver();
96  bool hasFeature(DriverFeature f) const;
97  bool open(const QString & db,
98  const QString & user,
99  const QString & password,
100  const QString & host,
101  int port,
102  const QString & connOpts);
103  void close();
104  QSqlResult *createResult() const;
105  bool beginTransaction();
106  bool commitTransaction();
107  bool rollbackTransaction();
109 
110  QSqlRecord record(const QString& tablename) const;
111  QSqlIndex primaryIndex(const QString &table) const;
112  QVariant handle() const;
113  QString escapeIdentifier(const QString &identifier, IdentifierType) const;
114 
115 private:
116  QSQLiteDriverPrivate* d;
117 };
118 
120 
122 
123 #endif // QSQL_SQLITE_H
int numRowsAffected()
#define QT_END_NAMESPACE
Definition: qglobal.h:128
virtual QStringList tables(QSql::TableType tableType) const
friend class QSQLiteResultPrivate
Definition: qsql_sqlite.h:67
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
void virtual_hook(int id, void *data)
virtual bool hasFeature(DriverFeature f) const =0
virtual void close()=0
QVariant lastInsertId() const
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: GLee.h:873
GLenum GLenum GLvoid * row
Definition: GLee.h:893
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
#define Q_EXPORT_SQLDRIVER_SQLITE
Definition: qsql_sqlite.h:54
friend class QSQLiteDriver
Definition: qsql_sqlite.h:66
bool gotoNext(QSqlCachedResult::ValueCache &row, int idx)
#define Q_OBJECT
Definition: qobjectdefs.h:157
QSQLiteResult(const QSQLiteDriver *db)
virtual bool rollbackTransaction()
QSqlRecord record() const
virtual bool commitTransaction()
virtual bool open(const QString &db, const QString &user=QString(), const QString &password=QString(), const QString &host=QString(), int port=-1, const QString &connOpts=QString())=0
QVariant handle() const
bool reset(const QString &query)
virtual QSqlResult * createResult() const =0
virtual QSqlRecord record(const QString &tableName) const
virtual QSqlIndex primaryIndex(const QString &tableName) const
virtual QVariant handle() const
TableType
Definition: qsql.h:74
bool prepare(const QString &query)
#define QT_END_HEADER
Definition: qglobal.h:142
virtual bool beginTransaction()
GLclampf f
Definition: GLee.h:9303
virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const