QProtobufSerializer Class
The QProtobufSerializer class is interface that represents basic functions for serialization/deserialization. More...
Header: | #include <QProtobufSerializer> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Protobuf) target_link_libraries(mytarget PRIVATE Qt6::Protobuf) |
Since: | Qt 6.5 |
Inherits: | QAbstractProtobufSerializer |
Note: All functions in this class are reentrant.
Public Functions
QProtobufSerializer() | |
virtual | ~QProtobufSerializer() override |
Reimplemented Public Functions
virtual QProtobufSerializer::DeserializationError | deserializationError() const override |
virtual QString | deserializationErrorString() const override |
virtual bool | deserializeMessage(QProtobufMessage *message, const QtProtobufPrivate::QProtobufPropertyOrdering &ordering, QByteArrayView data) const override |
virtual QByteArray | serializeMessage(const QProtobufMessage *message, const QtProtobufPrivate::QProtobufPropertyOrdering &ordering) const override |
Related Non-Members
void | qRegisterProtobufEnumType() |
void | qRegisterProtobufMapType() |
void | qRegisterProtobufType() |
Detailed Description
The QProtobufSerializer class registers serializers/deserializers for classes implementing a protobuf message, inheriting QProtobufMessage. These classes are generated automatically, based on a .proto file, using the cmake build macro qt6_add_protobuf or by running qtprotobufgen directly.
Member Function Documentation
QProtobufSerializer::QProtobufSerializer()
Constructs a new serializer instance.
[override virtual]
QProtobufSerializer::~QProtobufSerializer()
Destroys the serializer instance.
[override virtual]
QProtobufSerializer::DeserializationError QProtobufSerializer::deserializationError() const
Returns the last deserialization error.
[override virtual]
QString QProtobufSerializer::deserializationErrorString() const
Returns a human-readable string describing the last deserialization error. If there was no error, an empty string is returned.
[override virtual]
bool QProtobufSerializer::deserializeMessage(QProtobufMessage *message, const QtProtobufPrivate::QProtobufPropertyOrdering &ordering, QByteArrayView data) const
This is called by deserialize() to deserialize a registered Protobuf message message with ordering, from a QByteArrayView data. message can be assumed to not be nullptr
. Returns true
if deserialization was successful, otherwise false
.
[override virtual]
QByteArray QProtobufSerializer::serializeMessage(const QProtobufMessage *message, const QtProtobufPrivate::QProtobufPropertyOrdering &ordering) const
This is called by serialize() to serialize a registered Protobuf message message with ordering. message must not be nullptr
. Returns a QByteArray containing the serialized message.
Related Non-Members
template <typename T> void qRegisterProtobufEnumType()
Registers serializers for enumeration type T
in QtProtobuf global serializers registry.
This function is normally called by generated code.
template <typename K, typename V> void qRegisterProtobufMapType()
Registers a Protobuf map type K
and V
. V
must be a QProtobufMessage. This function is normally called by generated code.
template <typename T> void qRegisterProtobufType()
Registers a Protobuf type T. This function is normally called by generated code.