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 QVariant value(const QString& name) const;
36 void setValue(int i, const QVariant& val);
37 void setValue(const QString& name, const QVariant& val);
38
39 void setNull(int i);
40 void setNull(const QString& name);
41 bool isNull(int i) const;
42 bool isNull(const QString& name) const;
43
44 int indexOf(const QString &name) const;
45 QString fieldName(int i) const;
46
47 QSqlField field(int i) const;
48 QSqlField field(const QString &name) const;
49
50 bool isGenerated(int i) const;
51 bool isGenerated(const QString& name) const;
52 void setGenerated(const QString& name, bool generated);
53 void setGenerated(int i, bool generated);
54
55 void append(const QSqlField& field);
56 void replace(int pos, const QSqlField& field);
57 void insert(int pos, const QSqlField& field);
58 void remove(int pos);
59
60 bool isEmpty() const;
61 bool contains(const QString& name) const;
62 void clear();
63 void clearValues();
64 int count() const;
65 QSqlRecord keyValues(const QSqlRecord &keyFields) const;
66
67private:
68 void detach();
69 QExplicitlySharedDataPointer<QSqlRecordPrivate> d;
70};
71
72Q_DECLARE_SHARED(QSqlRecord)
73
74#ifndef QT_NO_DEBUG_STREAM
75Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlRecord &);
76#endif
77
78QT_END_NAMESPACE
79
80#endif // QSQLRECORD_H
81

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