Qt 4.8
qsql_symsql.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_SYMSQL_H
43 #define QSQL_SYMSQL_H
44 
45 #include <QtSql/qsqldriver.h>
46 #include <QtSql/qsqlresult.h>
47 #include <QtSql/private/qsqlcachedresult_p.h>
48 
49 
50 
51 #ifdef QT_PLUGIN
52 #define Q_EXPORT_SQLDRIVER_SYMSQL
53 #else
54 #define Q_EXPORT_SQLDRIVER_SYMSQL Q_SQL_EXPORT
55 #endif
56 
58 
62 class QSymSQLDriver;
63 class RSqlDatabase;
64 
65 class QSymSQLResult : public QSqlResult
66 {
67  friend class QSymSQLDriver;
68  friend class QSymSQLResultPrivate;
69 public:
70  explicit QSymSQLResult(const QSymSQLDriver* db);
72  QVariant handle() const;
73 
74 protected:
75  QVariant data(int field);
76  bool isNull(int i);
77  bool fetch(int i);
78  bool fetchNext();
79  bool fetchPrevious();
80  bool fetchFirst();
81  bool fetchLast();
82 
83  bool reset(const QString &query);
84  bool prepare(const QString &query);
85  bool exec();
86  int size();
87  int numRowsAffected();
88  QSqlRecord record() const;
89  void virtual_hook(int id, void *data);
90 
91  QVariant lastInsertId() const;
92 
93 private:
95 };
96 
98 {
99  Q_OBJECT
100  friend class QSymSQLResult;
101 public:
102  explicit QSymSQLDriver(QObject *parent = 0);
103  explicit QSymSQLDriver(RSqlDatabase& connection, QObject *parent = 0);
104  ~QSymSQLDriver();
105  bool hasFeature(DriverFeature f) const;
106  bool open(const QString & db,
107  const QString & user,
108  const QString & password,
109  const QString & host,
110  int port,
111  const QString & connOpts);
112  void close();
113  QSqlResult *createResult() const;
114  bool beginTransaction();
115  bool commitTransaction();
116  bool rollbackTransaction();
117  QStringList tables(QSql::TableType)const;
118 
119  QSqlRecord record(const QString& tablename) const;
120  QSqlIndex primaryIndex(const QString &table) const;
121  QVariant handle() const;
122  QString escapeIdentifier(const QString &identifier, IdentifierType) const;
123 
124 private:
126 };
127 
129 
131 
132 #endif // QSQL_SYMSQL_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 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
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
DriverFeature
This enum contains a list of features a driver might support.
Definition: qsqldriver.h:75
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
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
bool isNull(int i)
Returns true if the field at position index in the current row is null; otherwise returns false...
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool fetchFirst()
Positions the result to the first record (row 0) in the result.
QSymSQLResult(const QSymSQLDriver *db)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool fetchLast()
Positions the result to the last record (last row) in the result.
#define Q_EXPORT_SQLDRIVER_SYMSQL
Definition: qsql_symsql.h:54
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool exec()
Executes the query, returning true if successful; otherwise returns false.
TableType
Definition: qsql.h:74
friend class QSymSQLDriver
Definition: qsql_symsql.h:67
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
#define Q_OBJECT
Definition: qobjectdefs.h:157
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QSymSQLDriverPrivate * d
Definition: qsql_symsql.h:125
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool fetchPrevious()
Positions the result to the previous record (row) in the result.
QSymSQLResultPrivate * d
Definition: qsql_symsql.h:94
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
#define QT_END_HEADER
Definition: qglobal.h:137
bool fetchNext()
Positions the result to the next available record (row) in the result.
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,...)
void virtual_hook(int id, void *data)