Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsqlnulldriver_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QSQLNULLDRIVER_P_H
6#define QSQLNULLDRIVER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. This header file may
13// change from version to version without notice, or even be
14// removed.
15//
16// We mean it.
17//
18
19#include <QtSql/private/qtsqlglobal_p.h>
20#include "QtCore/qvariant.h"
21#include "QtSql/qsqldriver.h"
22#include "QtSql/qsqlerror.h"
23#include "QtSql/qsqlresult.h"
24
25QT_BEGIN_NAMESPACE
26
27class QSqlNullResult : public QSqlResult
28{
29public:
30 inline explicit QSqlNullResult(const QSqlDriver* d): QSqlResult(d)
31 { QSqlResult::setLastError(
32 QSqlError(QLatin1StringView("Driver not loaded"), QLatin1StringView("Driver not loaded"), QSqlError::ConnectionError)); }
33protected:
34 inline QVariant data(int) override { return QVariant(); }
35 inline bool reset (const QString&) override { return false; }
36 inline bool fetch(int) override { return false; }
37 inline bool fetchFirst() override { return false; }
38 inline bool fetchLast() override { return false; }
39 inline bool isNull(int) override { return false; }
40 inline int size() override { return -1; }
41 inline int numRowsAffected() override { return 0; }
42
43 inline void setAt(int) override {}
44 inline void setActive(bool) override {}
45 inline void setLastError(const QSqlError&) override {}
46 inline void setQuery(const QString&) override {}
47 inline void setSelect(bool) override {}
48 inline void setForwardOnly(bool) override {}
49
50 inline bool exec() override { return false; }
51 inline bool prepare(const QString&) override { return false; }
52 inline bool savePrepare(const QString&) override { return false; }
53 inline void bindValue(int, const QVariant&, QSql::ParamType) override {}
54 inline void bindValue(const QString&, const QVariant&, QSql::ParamType) override {}
55};
56
58{
59public:
61 { QSqlDriver::setLastError(
62 QSqlError(QLatin1StringView("Driver not loaded"), QLatin1StringView("Driver not loaded"), QSqlError::ConnectionError)); }
63 inline bool hasFeature(DriverFeature) const override { return false; }
64 inline bool open(const QString &, const QString &, const QString &, const QString &, int, const QString&) override
65 { return false; }
66 inline void close() override {}
67 inline QSqlResult *createResult() const override { return new QSqlNullResult(this); }
68
69protected:
70 inline void setOpen(bool) override {}
71 inline void setOpenError(bool) override {}
72 inline void setLastError(const QSqlError&) override {}
73};
74
75QT_END_NAMESPACE
76
77#endif // QSQLNULLDRIVER_P_H
bool open(const QString &, const QString &, const QString &, const QString &, int, const QString &) override
Derived classes must reimplement this pure virtual function to open a database connection on database...
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
void setOpenError(bool) override
This function sets the open error state of the database to error.
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
void setOpen(bool) override
This function sets the open state of the database to open.
void setLastError(const QSqlError &) override
This function is used to set the value of the last error, error, that occurred on the database.
bool hasFeature(DriverFeature) const override
Returns true if the driver supports feature feature; otherwise returns false.