| 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 QSQLNULLDRIVER_P_H |
| 5 | #define QSQLNULLDRIVER_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. This header file may |
| 12 | // change from version to version without notice, or even be |
| 13 | // removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtSql/private/qtsqlglobal_p.h> |
| 19 | #include "QtCore/qvariant.h" |
| 20 | #include "QtSql/qsqldriver.h" |
| 21 | #include "QtSql/qsqlerror.h" |
| 22 | #include "QtSql/qsqlresult.h" |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class QSqlNullResult : public QSqlResult |
| 27 | { |
| 28 | public: |
| 29 | inline explicit QSqlNullResult(const QSqlDriver* d): QSqlResult(d) |
| 30 | { QSqlResult::setLastError( |
| 31 | QSqlError(QLatin1StringView("Driver not loaded" ), QLatin1StringView("Driver not loaded" ), QSqlError::ConnectionError)); } |
| 32 | protected: |
| 33 | inline QVariant data(int) override { return QVariant(); } |
| 34 | inline bool reset (const QString&) override { return false; } |
| 35 | inline bool fetch(int) override { return false; } |
| 36 | inline bool fetchFirst() override { return false; } |
| 37 | inline bool fetchLast() override { return false; } |
| 38 | inline bool isNull(int) override { return false; } |
| 39 | inline int size() override { return -1; } |
| 40 | inline int numRowsAffected() override { return 0; } |
| 41 | |
| 42 | inline void setAt(int) override {} |
| 43 | inline void setActive(bool) override {} |
| 44 | inline void setLastError(const QSqlError&) override {} |
| 45 | inline void setQuery(const QString&) override {} |
| 46 | inline void setSelect(bool) override {} |
| 47 | inline void setForwardOnly(bool) override {} |
| 48 | |
| 49 | inline bool exec() override { return false; } |
| 50 | inline bool prepare(const QString&) override { return false; } |
| 51 | inline bool savePrepare(const QString&) override { return false; } |
| 52 | inline void bindValue(int, const QVariant&, QSql::ParamType) override {} |
| 53 | inline void bindValue(const QString&, const QVariant&, QSql::ParamType) override {} |
| 54 | }; |
| 55 | |
| 56 | class QSqlNullDriver : public QSqlDriver |
| 57 | { |
| 58 | public: |
| 59 | inline QSqlNullDriver(): QSqlDriver() |
| 60 | { QSqlDriver::setLastError( |
| 61 | QSqlError(QLatin1StringView("Driver not loaded" ), QLatin1StringView("Driver not loaded" ), QSqlError::ConnectionError)); } |
| 62 | inline bool hasFeature(DriverFeature) const override { return false; } |
| 63 | inline bool open(const QString &, const QString &, const QString &, const QString &, int, const QString&) override |
| 64 | { return false; } |
| 65 | inline void close() override {} |
| 66 | inline QSqlResult *createResult() const override { return new QSqlNullResult(this); } |
| 67 | |
| 68 | protected: |
| 69 | inline void setOpen(bool) override {} |
| 70 | inline void setOpenError(bool) override {} |
| 71 | inline void setLastError(const QSqlError&) override {} |
| 72 | }; |
| 73 | |
| 74 | QT_END_NAMESPACE |
| 75 | |
| 76 | #endif // QSQLNULLDRIVER_P_H |
| 77 | |