1 | // Copyright (C) 2022 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 QPROTOBUFMESSAGE_P_H |
5 | #define QPROTOBUFMESSAGE_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 the Qt Protobuf API. This header file may change from |
13 | // version to version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtProtobuf/qprotobufmessage.h> |
19 | #include <QtProtobuf/qprotobufpropertyordering.h> |
20 | #include <QtProtobuf/qtprotobufexports.h> |
21 | |
22 | #include <QtCore/qhash.h> |
23 | #include <QtCore/qshareddata.h> |
24 | |
25 | #include <optional> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | struct QMetaObject; |
30 | class QMetaProperty; |
31 | |
32 | class Q_PROTOBUF_EXPORT QProtobufMessagePrivate : public QSharedData |
33 | { |
34 | public: |
35 | QProtobufMessagePrivate() = default; |
36 | explicit QProtobufMessagePrivate(const QMetaObject *metaObject, |
37 | const QtProtobufPrivate::QProtobufPropertyOrdering *ordering); |
38 | QProtobufMessagePrivate(const QProtobufMessagePrivate &other) = default; |
39 | QProtobufMessagePrivate(QProtobufMessagePrivate &&other) = delete; |
40 | QProtobufMessagePrivate &operator=(const QProtobufMessagePrivate &other) = delete; |
41 | QProtobufMessagePrivate &operator=(QProtobufMessagePrivate &&other) = delete; |
42 | virtual ~QProtobufMessagePrivate(); |
43 | |
44 | // QHash of form <field index, data>. |
45 | QHash<qint32, QByteArrayList> unknownEntries; |
46 | const QMetaObject *metaObject = nullptr; |
47 | const QtProtobufPrivate::QProtobufPropertyOrdering *ordering = nullptr; |
48 | |
49 | int propertyIndex(QAnyStringView propertyName) const; |
50 | static void storeUnknownEntry(QProtobufMessage *message, QByteArrayView entry, int fieldNumber); |
51 | |
52 | std::optional<QMetaProperty> metaProperty(QAnyStringView name) const; |
53 | std::optional<QMetaProperty> |
54 | metaProperty(QtProtobufPrivate::QProtobufFieldInfo ord) const; |
55 | |
56 | static QProtobufMessagePrivate *get(QProtobufMessage *message) { return message->d_func(); } |
57 | static const QProtobufMessagePrivate *get(const QProtobufMessage *message) |
58 | { |
59 | return message->d_func(); |
60 | } |
61 | }; |
62 | |
63 | QT_END_NAMESPACE |
64 | |
65 | #endif // QPROTOBUFMESSAGE_P_H |
66 | |