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
4#ifndef QPROTOBUFSERIALIZERBASE_P_H
5#define QPROTOBUFSERIALIZERBASE_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 purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtProtobuf/qprotobufpropertyordering.h>
19
20#include <QtCore/qtconfigmacros.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QtProtobufPrivate {
25struct QProtobufFieldInfo;
26}
27class QVariant;
28class QProtobufMessage;
29class QProtobufSerializerBase
30{
31public:
32 QProtobufSerializerBase();
33
34 void serializeMessage(const QProtobufMessage *message);
35
36 static bool isOneofOrOptionalField(QtProtobufPrivate::FieldFlags flags)
37 {
38 return flags.testAnyFlags(flags: { QtProtobufPrivate::FieldFlag::Oneof,
39 QtProtobufPrivate::FieldFlag::Optional });
40 }
41
42protected:
43 ~QProtobufSerializerBase();
44
45 virtual void serializeMessageField(const QProtobufMessage *message,
46 const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo);
47
48private:
49 virtual bool serializeEnum(QVariant &value,
50 const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo) = 0;
51 virtual bool serializeScalarField(const QVariant &value,
52 const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo) = 0;
53 virtual void serializeMessageFieldBegin() = 0;
54 virtual void serializeMessageFieldEnd(const QProtobufMessage *,
55 const QtProtobufPrivate::QProtobufFieldInfo &) = 0;
56
57 Q_DISABLE_COPY_MOVE(QProtobufSerializerBase)
58};
59
60QT_END_NAMESPACE
61
62#endif // QPROTOBUFSERIALIZERBASE_P_H
63

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtgrpc/src/protobuf/qprotobufserializerbase_p.h