source: trunk/src/sql/kernel/qsqlresult.h@ 98

Last change on this file since 98 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 4.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtSql module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSQLRESULT_H
43#define QSQLRESULT_H
44
45#include <QtCore/qvariant.h>
46#include <QtCore/qvector.h>
47#include <QtSql/qsql.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Sql)
54
55class QString;
56class QSqlRecord;
57template <typename T> class QVector;
58class QVariant;
59class QSqlDriver;
60class QSqlError;
61class QSqlResultPrivate;
62
63class Q_SQL_EXPORT QSqlResult
64{
65 friend class QSqlQuery;
66 friend class QSqlTableModelPrivate;
67 friend class QSqlResultPrivate;
68
69public:
70 virtual ~QSqlResult();
71 virtual QVariant handle() const;
72
73protected:
74 enum BindingSyntax {
75 PositionalBinding,
76 NamedBinding
77#ifdef QT3_SUPPORT
78 , BindByPosition = PositionalBinding,
79 BindByName = NamedBinding
80#endif
81 };
82
83 explicit QSqlResult(const QSqlDriver * db);
84 int at() const;
85 QString lastQuery() const;
86 QSqlError lastError() const;
87 bool isValid() const;
88 bool isActive() const;
89 bool isSelect() const;
90 bool isForwardOnly() const;
91 const QSqlDriver* driver() const;
92 virtual void setAt(int at);
93 virtual void setActive(bool a);
94 virtual void setLastError(const QSqlError& e);
95 virtual void setQuery(const QString& query);
96 virtual void setSelect(bool s);
97 virtual void setForwardOnly(bool forward);
98
99 // prepared query support
100 virtual bool exec();
101 virtual bool prepare(const QString& query);
102 virtual bool savePrepare(const QString& sqlquery);
103 virtual void bindValue(int pos, const QVariant& val, QSql::ParamType type);
104 virtual void bindValue(const QString& placeholder, const QVariant& val,
105 QSql::ParamType type);
106 void addBindValue(const QVariant& val, QSql::ParamType type);
107 QVariant boundValue(const QString& placeholder) const;
108 QVariant boundValue(int pos) const;
109 QSql::ParamType bindValueType(const QString& placeholder) const;
110 QSql::ParamType bindValueType(int pos) const;
111 int boundValueCount() const;
112 QVector<QVariant>& boundValues() const;
113 QString executedQuery() const;
114 QString boundValueName(int pos) const;
115 void clear();
116 bool hasOutValues() const;
117
118 BindingSyntax bindingSyntax() const;
119
120 virtual QVariant data(int i) = 0;
121 virtual bool isNull(int i) = 0;
122 virtual bool reset(const QString& sqlquery) = 0;
123 virtual bool fetch(int i) = 0;
124 virtual bool fetchNext();
125 virtual bool fetchPrevious();
126 virtual bool fetchFirst() = 0;
127 virtual bool fetchLast() = 0;
128 virtual int size() = 0;
129 virtual int numRowsAffected() = 0;
130 virtual QSqlRecord record() const;
131 virtual QVariant lastInsertId() const;
132
133 enum VirtualHookOperation { BatchOperation, DetachFromResultSet, SetNumericalPrecision, NextResult };
134 virtual void virtual_hook(int id, void *data);
135 bool execBatch(bool arrayBind = false);
136 void detachFromResultSet();
137 void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy);
138 bool nextResult();
139
140private:
141 QSqlResultPrivate* d;
142 void resetBindCount(); // HACK
143
144private:
145 Q_DISABLE_COPY(QSqlResult)
146};
147
148QT_END_NAMESPACE
149
150QT_END_HEADER
151
152#endif // QSQLRESULT_H
Note: See TracBrowser for help on using the repository browser.