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 QSQLRECORD_H
5#define QSQLRECORD_H
6
7#include <QtSql/qtsqlglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qstring.h>
10
11QT_BEGIN_NAMESPACE
12
13
14class QSqlField;
15class QVariant;
16class QSqlRecordPrivate;
17QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlRecordPrivate, Q_SQL_EXPORT)
18
19class Q_SQL_EXPORT QSqlRecord
20{
21public:
22 QSqlRecord();
23 QSqlRecord(const QSqlRecord &other);
24 QSqlRecord(QSqlRecord &&other) noexcept = default;
25 QSqlRecord& operator=(const QSqlRecord &other);
26 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlRecord)
27 ~QSqlRecord();
28
29 void swap(QSqlRecord &other) noexcept { d.swap(other&: other.d); }
30
31 bool operator==(const QSqlRecord &other) const;
32 inline bool operator!=(const QSqlRecord &other) const { return !operator==(other); }
33
34 QVariant value(int i) const;
35#if QT_SQL_REMOVED_SINCE(6, 8)
36 QVariant value(const QString &name) const;
37#endif
38 QVariant value(QAnyStringView name) const;
39 void setValue(int i, const QVariant &val);
40#if QT_SQL_REMOVED_SINCE(6, 8)
41 void setValue(const QString &name, const QVariant &val);
42#endif
43 void setValue(QAnyStringView name, const QVariant &val);
44
45 void setNull(int i);
46#if QT_SQL_REMOVED_SINCE(6, 8)
47 void setNull(const QString &name);
48#endif
49 void setNull(QAnyStringView name);
50 bool isNull(int i) const;
51#if QT_SQL_REMOVED_SINCE(6, 8)
52 bool isNull(const QString &name) const;
53#endif
54 bool isNull(QAnyStringView name) const;
55
56#if QT_SQL_REMOVED_SINCE(6, 8)
57 int indexOf(const QString &name) const;
58#endif
59 int indexOf(QAnyStringView name) const;
60 QString fieldName(int i) const;
61
62 QSqlField field(int i) const;
63#if QT_SQL_REMOVED_SINCE(6, 8)
64 QSqlField field(const QString &name) const;
65#endif
66 QSqlField field(QAnyStringView name) const;
67
68 bool isGenerated(int i) const;
69#if QT_SQL_REMOVED_SINCE(6, 8)
70 bool isGenerated(const QString &name) const;
71#endif
72 bool isGenerated(QAnyStringView name) const;
73#if QT_SQL_REMOVED_SINCE(6, 8)
74 void setGenerated(const QString &name, bool generated);
75#endif
76 void setGenerated(QAnyStringView name, bool generated);
77 void setGenerated(int i, bool generated);
78
79 void append(const QSqlField &field);
80 void replace(int pos, const QSqlField &field);
81 void insert(int pos, const QSqlField &field);
82 void remove(int pos);
83
84 bool isEmpty() const;
85#if QT_SQL_REMOVED_SINCE(6, 8)
86 bool contains(const QString &name) const;
87#endif
88 bool contains(QAnyStringView name) const;
89 void clear();
90 void clearValues();
91 int count() const;
92 QSqlRecord keyValues(const QSqlRecord &keyFields) const;
93
94private:
95 void detach();
96 QExplicitlySharedDataPointer<QSqlRecordPrivate> d;
97};
98
99Q_DECLARE_SHARED(QSqlRecord)
100
101#ifndef QT_NO_DEBUG_STREAM
102Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlRecord &);
103#endif
104
105QT_END_NAMESPACE
106
107#endif // QSQLRECORD_H
108

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtbase/src/sql/kernel/qsqlrecord.h