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 QPROTOBUFREGISTRATION_P_H
5#define QPROTOBUFREGISTRATION_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/qprotobufregistration.h>
19#include <QtProtobuf/qtprotobufexports.h>
20
21#include <QtCore/qxpfunctional.h>
22
23QT_BEGIN_NAMESPACE
24
25namespace QtProtobufPrivate {
26
27inline void ensureValue(const void *valuePtr)
28{
29 Q_ASSERT_X(valuePtr != nullptr, "QAbstractProtobufSerializer", "Value is nullptr");
30}
31
32using MessageFieldSerializer = qxp::function_ref<void(const QProtobufMessage *,
33 const QProtobufFieldInfo &)>;
34using MessageFieldDeserializer = qxp::function_ref<bool(QProtobufMessage *)>;
35
36using Serializer = void (*)(MessageFieldSerializer, const void *, const QProtobufFieldInfo &);
37using Deserializer = void (*)(MessageFieldDeserializer, void *);
38
39struct SerializationHandler
40{
41 Serializer serializer = nullptr; /*!< serializer assigned to class */
42 Deserializer deserializer = nullptr; /*!< deserializer assigned to class */
43};
44
45extern Q_PROTOBUF_EXPORT void registerHandler(QMetaType type, Serializer serializer,
46 Deserializer deserializer);
47
48extern Q_PROTOBUF_EXPORT SerializationHandler findHandler(QMetaType type);
49}
50
51QT_END_NAMESPACE
52
53#endif // QPROTOBUFREGISTRATION_P_H
54

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