1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com> |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef QPROTOBUFOBJECT_H |
6 | #define QPROTOBUFOBJECT_H |
7 | |
8 | #if 0 |
9 | # pragma qt_sync_skip_header_check |
10 | # pragma qt_sync_stop_processing |
11 | #endif |
12 | |
13 | #include <QtProtobuf/qabstractprotobufserializer.h> |
14 | |
15 | #define Q_DECLARE_PROTOBUF_SERIALIZERS(Type)\ |
16 | public:\ |
17 | QByteArray serialize(QAbstractProtobufSerializer *serializer) const {\ |
18 | qRegisterProtobufTypes();\ |
19 | Q_ASSERT_X(serializer != nullptr, "QProtobufObject", "Serializer is null");\ |
20 | return serializer->serialize<Type>(this);\ |
21 | }\ |
22 | bool deserialize(QAbstractProtobufSerializer *serializer, QByteArrayView array) {\ |
23 | qRegisterProtobufTypes();\ |
24 | Q_ASSERT_X(serializer != nullptr, "QProtobufObject", "Serializer is null");\ |
25 | return serializer->deserialize<Type>(this, array);\ |
26 | }\ |
27 | private: |
28 | |
29 | #define Q_PROTOBUF_OBJECT\ |
30 | public:\ |
31 | static const QtProtobufPrivate::QProtobufPropertyOrdering propertyOrdering;\ |
32 | private: |
33 | |
34 | #endif // QPROTOBUFOBJECT_H |
35 | |