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
qsqlresult_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 QSQLRESULT_P_H
5#define QSQLRESULT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of qsql*model.h . This header file may change from version to version
13// without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtSql/private/qtsqlglobal_p.h>
19#include <QtCore/qpointer.h>
20#include <QtCore/qhash.h>
21#include "qsqlerror.h"
22#include "qsqlresult.h"
23#include "qsqldriver.h"
24
26
27// convenience method Q*ResultPrivate::drv_d_func() returns pointer to private driver. Compare to Q_DECLARE_PRIVATE in qglobal.h.
28#define Q_DECLARE_SQLDRIVER_PRIVATE(Class) \
29 inline const Class##Private* drv_d_func() const { return !sqldriver ? nullptr : reinterpret_cast<const Class *>(static_cast<const QSqlDriver*>(sqldriver))->d_func(); } \
30 inline Class##Private* drv_d_func() { return !sqldriver ? nullptr : reinterpret_cast<Class *>(static_cast<QSqlDriver*>(sqldriver))->d_func(); }
31
32struct QHolder {
33 QHolder(const QString &hldr = QString(), qsizetype index = -1): holderName(hldr), holderPos(index) { }
34 bool operator==(const QHolder &h) const { return h.holderPos == holderPos && h.holderName == holderName; }
35 bool operator!=(const QHolder &h) const { return h.holderPos != holderPos || h.holderName != holderName; }
38};
39
40class Q_SQL_EXPORT QSqlResultPrivate
41{
42 Q_DECLARE_PUBLIC(QSqlResult)
43
44public:
46 : q_ptr(q),
47 sqldriver(const_cast<QSqlDriver *>(drv))
48 { }
49 virtual ~QSqlResultPrivate() = default;
50
52 {
53 values.clear();
54 bindCount = 0;
55 }
56
58 {
59 bindCount = 0;
60 }
61
63 {
64 indexes.clear();
65 holders.clear();
66 types.clear();
67 }
68
69 void clear()
70 {
71 clearValues();
72 clearIndex();
73 }
74
75 virtual QString fieldSerial(qsizetype) const;
76 QString positionalToNamedBinding(const QString &query) const;
77 QString namedToPositionalBinding(const QString &query);
78 QString holderAt(int index) const;
79
80 QSqlResult *q_ptr = nullptr;
81 QPointer<QSqlDriver> sqldriver;
84
86 QHash<int, QSql::ParamType> types;
87 QList<QVariant> values;
88 using IndexMap = QHash<QString, QList<int>>;
90
91 using QHolderVector = QList<QHolder>;
93
97 int bindCount = 0;
98 bool active = false;
99 bool isSel = false;
100 bool forwardOnly = false;
101 bool positionalBindingEnabled = true;
102
103 static bool isVariantNull(const QVariant &variant);
104};
105
107
108#endif // QSQLRESULT_P_H
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition qsqldriver.h:26
The QSqlError class provides SQL database error information.
Definition qsqlerror.h:17
virtual ~QSqlResultPrivate()=default
QHolderVector holders
QSqlResultPrivate(QSqlResult *q, const QSqlDriver *drv)
QPointer< QSqlDriver > sqldriver
QList< QVariant > values
QHash< int, QSql::ParamType > types
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
Definition qsqlresult.h:22
BindingSyntax
This enum type specifies the different syntaxes for specifying placeholders in prepared queries.
Definition qsqlresult.h:32
@ PositionalBinding
Definition qsqlresult.h:33
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
@ BeforeFirstRow
Definition qtsqlglobal.h:21
NumericalPrecisionPolicy
Definition qtsqlglobal.h:43
@ LowPrecisionDouble
Definition qtsqlglobal.h:46
Combined button and popup list for selecting options.
GLenum GLsizei GLsizei GLint * values
[15]
GLuint index
[2]
GLsizei GLenum GLenum * types
GLfloat GLfloat GLfloat GLfloat h
GLenum query
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
ptrdiff_t qsizetype
Definition qtypes.h:165
QVariant variant
[1]
QString holderName
bool operator==(const QHolder &h) const
qsizetype holderPos
QHolder(const QString &hldr=QString(), qsizetype index=-1)
bool operator!=(const QHolder &h) const