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
qsqlcachedresult_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 QSQLCACHEDRESULT_P_H
6#define QSQLCACHEDRESULT_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 other Qt classes. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtSql/private/qtsqlglobal_p.h>
20#include "QtSql/qsqlresult.h"
21#include "QtSql/private/qsqlresult_p.h"
22#include <QtCore/qcontainerfwd.h>
23
24QT_BEGIN_NAMESPACE
25
26class QVariant;
27
28class QSqlCachedResultPrivate;
29
30class Q_SQL_EXPORT QSqlCachedResult: public QSqlResult
31{
32 Q_DECLARE_PRIVATE(QSqlCachedResult)
33
34public:
35 typedef QList<QVariant> ValueCache;
36
37protected:
38 QSqlCachedResult(QSqlCachedResultPrivate &d);
39
40 void init(int colCount);
41 void cleanup();
42 void clearValues();
43
44 virtual bool gotoNext(ValueCache &values, int index) = 0;
45
46 QVariant data(int i) override;
47 bool isNull(int i) override;
48 bool fetch(int i) override;
49 bool fetchNext() override;
50 bool fetchPrevious() override;
51 bool fetchFirst() override;
52 bool fetchLast() override;
53
54 int colCount() const;
55 ValueCache &cache();
56
57 void virtual_hook(int id, void *data) override;
58 void detachFromResultSet() override;
59 void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) override;
60private:
61 bool cacheNext();
62};
63
64class Q_SQL_EXPORT QSqlCachedResultPrivate: public QSqlResultPrivate
65{
66 Q_DECLARE_PUBLIC(QSqlCachedResult)
67
68public:
69 using QSqlResultPrivate::QSqlResultPrivate;
70
71 bool canSeek(int i) const;
72 inline int cacheCount() const;
73 void init(int count, bool fo);
74 void cleanup();
75 int nextIndex();
76 void revertLast();
77
78 QSqlCachedResult::ValueCache cache;
79 int rowCacheEnd = 0;
80 int colCount = 0;
81 bool atEnd = false;
82};
83
84QT_END_NAMESPACE
85
86#endif // QSQLCACHEDRESULT_P_H