Qt 4.8
qsql_sqlite2.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_SQLITE2_H
43 #define QSQL_SQLITE2_H
44 
45 #include <QtSql/qsqldriver.h>
46 #include <QtSql/qsqlresult.h>
47 #include <QtSql/qsqlrecord.h>
48 #include <QtSql/qsqlindex.h>
49 #include <QtSql/private/qsqlcachedresult_p.h>
50 
51 #if defined (Q_OS_WIN32)
52 # include <QtCore/qt_windows.h>
53 #endif
54 
55 struct sqlite;
56 
58 
60 
63 class QSQLite2Driver;
64 
66 {
67  friend class QSQLite2Driver;
68  friend class QSQLite2ResultPrivate;
69 public:
70  explicit QSQLite2Result(const QSQLite2Driver* db);
72  QVariant handle() const;
73 
74 protected:
75  bool gotoNext(QSqlCachedResult::ValueCache& row, int idx);
76  bool reset (const QString& query);
77  int size();
78  int numRowsAffected();
79  QSqlRecord record() const;
80  void virtual_hook(int id, void *data);
81 
82 private:
84 };
85 
86 class QSQLite2Driver : public QSqlDriver
87 {
88  Q_OBJECT
89  friend class QSQLite2Result;
90 public:
91  explicit QSQLite2Driver(QObject *parent = 0);
92  explicit QSQLite2Driver(sqlite *connection, QObject *parent = 0);
93  ~QSQLite2Driver();
94  bool hasFeature(DriverFeature f) const;
95  bool open(const QString & db,
96  const QString & user,
97  const QString & password,
98  const QString & host,
99  int port,
100  const QString & connOpts);
101  bool open(const QString & db,
102  const QString & user,
103  const QString & password,
104  const QString & host,
105  int port) { return open (db, user, password, host, port, QString()); }
106  void close();
107  QSqlResult *createResult() const;
108  bool beginTransaction();
109  bool commitTransaction();
110  bool rollbackTransaction();
111  QStringList tables(QSql::TableType) const;
112 
113  QSqlRecord record(const QString& tablename) const;
114  QSqlIndex primaryIndex(const QString &table) const;
115  QVariant handle() const;
116  QString escapeIdentifier(const QString &identifier, IdentifierType) const;
117 
118 private:
120 };
121 
123 
125 
126 #endif // QSQL_SQLITE2_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition: qsqlindex.h:55
QVariant data(int i)
Returns the data for field index in the current row as a QVariant.
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
DriverFeature
This enum contains a list of features a driver might support.
Definition: qsqldriver.h:75
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QSQLite2Result(const QSQLite2Driver *db)
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
void virtual_hook(int id, void *data)
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition: qsqldriver.h:68
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
friend class QSQLite2Driver
Definition: qsql_sqlite2.h:67
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
TableType
Definition: qsql.h:74
QSQLite2ResultPrivate * d
Definition: qsql_sqlite2.h:83
#define Q_OBJECT
Definition: qobjectdefs.h:157
bool gotoNext(QSqlCachedResult::ValueCache &row, int idx)
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port)
Definition: qsql_sqlite2.h:101
QSQLite2DriverPrivate * d
Definition: qsql_sqlite2.h:119
#define QT_END_HEADER
Definition: qglobal.h:137
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
Definition: qsqlresult.h:63
IdentifierType
This enum contains a list of SQL identifier types.
Definition: qsqldriver.h:83
int open(const char *, int,...)
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.