Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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
25
27{
28public:
29 inline explicit QSqlNullResult(const QSqlDriver* d): QSqlResult(d)
31 QSqlError(QLatin1StringView("Driver not loaded"), QLatin1StringView("Driver not loaded"), QSqlError::ConnectionError)); }
32protected:
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
57{
58public:
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
68protected:
69 inline void setOpen(bool) override {}
70 inline void setOpenError(bool) override {}
71 inline void setLastError(const QSqlError&) override {}
72};
73
75
76#endif // QSQLNULLDRIVER_P_H
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition qsqldriver.h:26
DriverFeature
This enum contains a list of features a driver might support.
Definition qsqldriver.h:33
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database.
The QSqlError class provides SQL database error information.
Definition qsqlerror.h:17
@ ConnectionError
Definition qsqlerror.h:21
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.
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
bool savePrepare(const QString &) override
Prepares the given query, using the underlying database functionality where possible.
bool prepare(const QString &) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
void bindValue(int, const QVariant &, QSql::ParamType) override
Binds the value val of parameter type paramType to position index in the current record (row).
bool fetchLast() override
Positions the result to the last record (last row) in the result.
QSqlNullResult(const QSqlDriver *d)
void setLastError(const QSqlError &) override
This function is provided for derived classes to set the last error to error.
bool reset(const QString &) override
Sets the result to use the SQL statement query for subsequent data retrieval.
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
void setForwardOnly(bool) override
Sets forward only mode to forward.
int size() override
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
bool isNull(int) override
Returns true if the field at position index in the current row is null; otherwise returns false.
void setSelect(bool) override
This function is provided for derived classes to indicate whether or not the current statement is a S...
void setAt(int) override
This function is provided for derived classes to set the internal (zero-based) row position to index.
void setQuery(const QString &) override
Sets the current query for the result to query.
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool fetch(int) override
Positions the result to an arbitrary (zero-based) row index.
void setActive(bool) override
This function is provided for derived classes to set the internal active state to active.
void bindValue(const QString &, const QVariant &, QSql::ParamType) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
QVariant data(int) override
Returns the data for field index in the current row as a QVariant.
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
Definition qsqlresult.h:22
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.