QtProtobuf  0.6
Protobuf plugin to generate Qt classes
qprotobufjsonserializer.h
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
5  *
6  * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
9  * software and associated documentation files (the "Software"), to deal in the Software
10  * without restriction, including without limitation the rights to use, copy, modify,
11  * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
12  * to permit persons to whom the Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in all copies
16  * or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21  * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  */
25 
26 #pragma once //QProtobufJsonSerializer
27 
28 #include "qabstractprotobufserializer.h"
29 #include "qtprotobufglobal.h"
30 
31 #include <memory>
32 
33 namespace QtProtobuf {
34 class QProtobufJsonSerializerPrivate;
39 class Q_PROTOBUF_EXPORT QProtobufJsonSerializer : public QAbstractProtobufSerializer
40 {
41 public:
44 
45 protected:
46  QByteArray serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const override;
47  void deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const override;
48 
49  QByteArray serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
50  void deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
51 
52  QByteArray serializeListBegin(const QProtobufMetaProperty &metaProperty) const override;
53  QByteArray serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
54  QByteArray serializeListEnd(QByteArray &buffer, const QProtobufMetaProperty &metaProperty) const override;
55 
56  bool deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
57 
58  QByteArray serializeMapBegin(const QProtobufMetaProperty &metaProperty) const override;
59  QByteArray serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufMetaProperty &metaProperty) const override;
60  QByteArray serializeMapEnd(QByteArray &buffer, const QProtobufMetaProperty &metaProperty) const override;
61 
62  bool deserializeMapPair(QVariant &key, QVariant &value, QProtobufSelfcheckIterator &it) const override;
63 
64  QByteArray serializeEnum(int64 value, const QMetaEnum &metaEnum, const QtProtobuf::QProtobufMetaProperty &metaProperty) const override;
65  QByteArray serializeEnumList(const QList<int64> &value, const QMetaEnum &metaEnum, const QtProtobuf::QProtobufMetaProperty &metaProperty) const override;
66 
67  void deserializeEnum(int64 &value, const QMetaEnum &metaEnum, QProtobufSelfcheckIterator &it) const override;
68  void deserializeEnumList(QList<int64> &value, const QMetaEnum &metaEnum, QProtobufSelfcheckIterator &it) const override;
69 private:
70  std::unique_ptr<QProtobufJsonSerializerPrivate> dPtr;
71 };
72 
73 }
The QAbstractProtobufSerializer class is interface that represents basic functions for serialization/...
Definition: qabstractprotobufserializer.h:72
The QProtobufJsonSerializer class.
Definition: qprotobufjsonserializer.h:40
Definition: qprotobufmetaproperty.h:41
The QProtobufSelfcheckIterator class.
Definition: qprotobufselfcheckiterator.h:40