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
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// Qt-Security score:significant reason:default
4
5#ifndef QSQLRESULT_P_H
6#define QSQLRESULT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of qsql*model.h . This header file may change from version to version
14// without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtSql/private/qtsqlglobal_p.h>
20#include <QtCore/qpointer.h>
21#include <QtCore/qhash.h>
22#include "qsqlerror.h"
23#include "qsqlresult.h"
24#include "qsqldriver.h"
25
27
28// convenience method Q*ResultPrivate::drv_d_func() returns pointer to private driver. Compare to Q_DECLARE_PRIVATE in qglobal.h.
29#define Q_DECLARE_SQLDRIVER_PRIVATE(Class)
30 inline const Class##Private* drv_d_func() const { return !sqldriver ? nullptr : reinterpret_cast<const Class *>(static_cast<const QSqlDriver*>(sqldriver))->d_func(); }
31 inline Class##Private* drv_d_func() { return !sqldriver ? nullptr : reinterpret_cast<Class *>(static_cast<QSqlDriver*>(sqldriver))->d_func(); }
32
33struct QHolder {
34 QHolder(const QString &hldr = QString(), qsizetype index = -1): holderName(hldr), holderPos(index) { }
35 bool operator==(const QHolder &h) const { return h.holderPos == holderPos && h.holderName == holderName; }
36 bool operator!=(const QHolder &h) const { return h.holderPos != holderPos || h.holderName != holderName; }
37 QString holderName;
39};
40
41class Q_SQL_EXPORT QSqlResultPrivate
42{
43 Q_DECLARE_PUBLIC(QSqlResult)
44
45public:
46 QSqlResultPrivate(QSqlResult *q, const QSqlDriver *drv)
47 : q_ptr(q),
48 sqldriver(const_cast<QSqlDriver *>(drv))
49 { }
50 virtual ~QSqlResultPrivate() = default;
51
52 void clearValues()
53 {
54 values.clear();
55 bindCount = 0;
56 }
57
58 void resetBindCount()
59 {
60 bindCount = 0;
61 }
62
63 void clearIndex()
64 {
65 indexes.clear();
66 holders.clear();
67 types.clear();
68 }
69
70 void clear()
71 {
72 clearValues();
73 clearIndex();
74 }
75
76 virtual QString fieldSerial(qsizetype) const;
77 QString positionalToNamedBinding(const QString &query) const;
78 QString namedToPositionalBinding(const QString &query);
79 QString holderAt(int index) const;
80
81 QSqlResult *q_ptr = nullptr;
82 QPointer<QSqlDriver> sqldriver;
83 QString sql;
84 QSqlError error;
85
86 QString executedQuery;
87 QHash<int, QSql::ParamType> types;
88 QList<QVariant> values;
89 using IndexMap = QHash<QString, QList<int>>;
90 IndexMap indexes;
91
92 using QHolderVector = QList<QHolder>;
93 QHolderVector holders;
94
95 QSqlResult::BindingSyntax binds = QSqlResult::PositionalBinding;
96 QSql::NumericalPrecisionPolicy precisionPolicy = QSql::LowPrecisionDouble;
97 int idx = QSql::BeforeFirstRow;
98 int bindCount = 0;
99 bool active = false;
100 bool isSel = false;
101 bool forwardOnly = false;
102 bool positionalBindingEnabled = true;
103
104 static bool isVariantNull(const QVariant &variant);
105};
106
107QT_END_NAMESPACE
108
109#endif // QSQLRESULT_P_H
static bool qIsAlnum(QChar ch)
QString holderName
bool operator==(const QHolder &h) const
qsizetype holderPos
QHolder(const QString &hldr=QString(), qsizetype index=-1)
bool operator!=(const QHolder &h) const