| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSQLRESULT_H |
| 5 | #define QSQLRESULT_H |
| 6 | |
| 7 | #include <QtSql/qtsqlglobal.h> |
| 8 | #include <QtCore/qvariant.h> |
| 9 | #include <QtCore/qcontainerfwd.h> |
| 10 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | |
| 14 | class QString; |
| 15 | class QSqlRecord; |
| 16 | class QVariant; |
| 17 | class QSqlDriver; |
| 18 | class QSqlError; |
| 19 | class QSqlResultPrivate; |
| 20 | |
| 21 | class Q_SQL_EXPORT QSqlResult |
| 22 | { |
| 23 | Q_DECLARE_PRIVATE(QSqlResult) |
| 24 | friend class QSqlQuery; |
| 25 | friend class QSqlTableModelPrivate; |
| 26 | |
| 27 | public: |
| 28 | virtual ~QSqlResult(); |
| 29 | virtual QVariant handle() const; |
| 30 | |
| 31 | protected: |
| 32 | enum BindingSyntax { |
| 33 | PositionalBinding, |
| 34 | NamedBinding |
| 35 | }; |
| 36 | |
| 37 | explicit QSqlResult(const QSqlDriver * db); |
| 38 | QSqlResult(QSqlResultPrivate &dd); |
| 39 | int at() const; |
| 40 | QString lastQuery() const; |
| 41 | QSqlError lastError() const; |
| 42 | bool isValid() const; |
| 43 | bool isActive() const; |
| 44 | bool isSelect() const; |
| 45 | bool isForwardOnly() const; |
| 46 | const QSqlDriver* driver() const; |
| 47 | virtual void setAt(int at); |
| 48 | virtual void setActive(bool a); |
| 49 | virtual void setLastError(const QSqlError& e); |
| 50 | virtual void setQuery(const QString& query); |
| 51 | virtual void setSelect(bool s); |
| 52 | virtual void setForwardOnly(bool forward); |
| 53 | |
| 54 | // prepared query support |
| 55 | virtual bool exec(); |
| 56 | virtual bool prepare(const QString& query); |
| 57 | virtual bool savePrepare(const QString& sqlquery); |
| 58 | virtual void bindValue(int pos, const QVariant& val, QSql::ParamType type); |
| 59 | virtual void bindValue(const QString& placeholder, const QVariant& val, |
| 60 | QSql::ParamType type); |
| 61 | void addBindValue(const QVariant& val, QSql::ParamType type); |
| 62 | QVariant boundValue(const QString& placeholder) const; |
| 63 | QVariant boundValue(int pos) const; |
| 64 | QSql::ParamType bindValueType(const QString& placeholder) const; |
| 65 | QSql::ParamType bindValueType(int pos) const; |
| 66 | int boundValueCount() const; |
| 67 | #if QT_SQL_REMOVED_SINCE(6, 6) |
| 68 | QList<QVariant> &boundValues() const; |
| 69 | #endif |
| 70 | QVariantList &boundValues(QT6_DECL_NEW_OVERLOAD); |
| 71 | QVariantList boundValues(QT6_DECL_NEW_OVERLOAD) const; |
| 72 | |
| 73 | QString executedQuery() const; |
| 74 | QStringList boundValueNames() const; |
| 75 | QString boundValueName(int pos) const; |
| 76 | void clear(); |
| 77 | bool hasOutValues() const; |
| 78 | |
| 79 | BindingSyntax bindingSyntax() const; |
| 80 | |
| 81 | virtual QVariant data(int i) = 0; |
| 82 | virtual bool isNull(int i) = 0; |
| 83 | virtual bool reset(const QString& sqlquery) = 0; |
| 84 | virtual bool fetch(int i) = 0; |
| 85 | virtual bool fetchNext(); |
| 86 | virtual bool fetchPrevious(); |
| 87 | virtual bool fetchFirst() = 0; |
| 88 | virtual bool fetchLast() = 0; |
| 89 | virtual int size() = 0; |
| 90 | virtual int numRowsAffected() = 0; |
| 91 | virtual QSqlRecord record() const; |
| 92 | virtual QVariant lastInsertId() const; |
| 93 | |
| 94 | enum VirtualHookOperation { }; |
| 95 | virtual void virtual_hook(int id, void *data); |
| 96 | virtual bool execBatch(bool arrayBind = false); |
| 97 | virtual void detachFromResultSet(); |
| 98 | virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy); |
| 99 | QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const; |
| 100 | void setPositionalBindingEnabled(bool enable); |
| 101 | bool isPositionalBindingEnabled() const; |
| 102 | virtual bool nextResult(); |
| 103 | void resetBindCount(); // HACK |
| 104 | |
| 105 | QSqlResultPrivate *d_ptr; |
| 106 | |
| 107 | private: |
| 108 | Q_DISABLE_COPY(QSqlResult) |
| 109 | }; |
| 110 | |
| 111 | QT_END_NAMESPACE |
| 112 | |
| 113 | #endif // QSQLRESULT_H |
| 114 | |