1 | // Copyright (C) 2024 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 | #ifndef QPROTOBUFDESERIALIZERBASE_P_H |
4 | #define QPROTOBUFDESERIALIZERBASE_P_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is not part of the Qt API. It exists purely as an |
11 | // implementation detail. This header file may change from version to |
12 | // version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | |
17 | #include <QtProtobuf/qabstractprotobufserializer.h> |
18 | #include <QtProtobuf/qprotobufpropertyordering.h> |
19 | #include <QtProtobuf/qprotobufrepeatediterator.h> |
20 | |
21 | #include <QtCore/qtconfigmacros.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QVariant; |
26 | class QProtobufMessage; |
27 | |
28 | class QProtobufDeserializerBase |
29 | { |
30 | public: |
31 | QProtobufDeserializerBase(); |
32 | |
33 | bool deserializeMessage(QProtobufMessage *message); |
34 | void clearCachedValue(); |
35 | |
36 | protected: |
37 | ~QProtobufDeserializerBase(); |
38 | |
39 | virtual void setError(QAbstractProtobufSerializer::Error error, QAnyStringView errorString) = 0; |
40 | |
41 | virtual bool deserializeMessageField(QProtobufMessage *message); |
42 | |
43 | private: |
44 | virtual bool deserializeEnum(QVariant &value, |
45 | const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo) = 0; |
46 | virtual int nextFieldIndex(QProtobufMessage *message) = 0; |
47 | virtual bool deserializeScalarField(QVariant &value, |
48 | const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo) = 0; |
49 | |
50 | bool storeCachedValue(QProtobufMessage *message); |
51 | |
52 | QVariant m_cachedPropertyValue; |
53 | QProtobufRepeatedIterator m_cachedRepeatedIterator; |
54 | int m_cachedIndex = -1; |
55 | |
56 | Q_DISABLE_COPY_MOVE(QProtobufDeserializerBase) |
57 | |
58 | public: |
59 | static constexpr QtProtobufPrivate::FieldFlags RepeatedMessageFlags{ |
60 | QtProtobufPrivate::FieldFlag::Message, QtProtobufPrivate::FieldFlag::Repeated |
61 | }; |
62 | }; |
63 | |
64 | QT_END_NAMESPACE |
65 | |
66 | #endif // QPROTOBUFDESERIALIZERBASE_P_H |
67 |