IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QAbstractProtobufSerializer Class

The QAbstractProtobufSerializer class is interface that represents basic functions for serialization/deserialization.

This class was introduced in Qt 6.5.

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QAbstractProtobufSerializer Class

  • Header: QAbstractProtobufSerializer

  • Since: Qt 6.5

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Protobuf)

    target_link_libraries(mytarget PRIVATE Qt6::Protobuf)

  • Inherited By: QProtobufSerializer

I. 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.

This class should be used as a base for specific serializers. The handlers property contains all message-specific serializers and should be used while serialization/deserialization. Inherited classes should reimplement scope of virtual methods that used by registered message serialization/deserialization functions.

II. Member Type Documentation

 

II-1. enum QAbstractProtobufSerializer::DeserializationError

This enum contains possible errors that can occur during deserialization. When an error occurs, call deserializationErrorString() to get a human-readable error message.

Constant

Value

Description

QAbstractProtobufSerializer::NoError

0

No error occurred.

QAbstractProtobufSerializer::InvalidHeaderError

1

Something went wrong while attempting to decode a header in the message.

QAbstractProtobufSerializer::NoDeserializerError

2

While deserializing a message, no deserializer was found for a type in the message.

QAbstractProtobufSerializer::UnexpectedEndOfStreamError

3

While deserializing a message, the stream ended unexpectedly.

III. Member Function Documentation

 

III-1. [virtual] QAbstractProtobufSerializer::~QAbstractProtobufSerializer()

III-2. bool QAbstractProtobufSerializer::deserialize(T *object, QByteArrayView data) const

This function deserializes a registered Protobuf message object from a QByteArray data. object must not be nullptr. Returns true if deserialization was successful, otherwise false.

For a given type, T, you should call the deserialize() function on an instance of that type, which in turn will call this function for you.

Unexpected/unknown properties in the data are skipped.

III-2-1. See Also

See also serialize()

III-3. [pure virtual protected] bool QAbstractProtobufSerializer::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.

III-4. QByteArray QAbstractProtobufSerializer::serialize(const QProtobufMessage *message) const

This function serializes a registered Protobuf message message into a QByteArray. message must not be nullptr.

For a given type, T, you should call the serialize() function on an instance of that type, which in turn will call this function for you.

III-4-1. See Also

See also deserialize()

III-5. [pure virtual protected] QByteArray QAbstractProtobufSerializer::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.

IV. Macro Documentation

 

IV-1. Q_DECLARE_PROTOBUF_SERIALIZERS(Type)

Defines serialize and deserialize functions for a Type inheriting QProtobufMessage. This is used as part of the code generated by the qtprotobufgen tool.

IV-2. Q_PROTOBUF_OBJECT

Declares the propertyOrdering member in a class inheriting QProtobufMessage. This is used as part of the code generated by the qtprotobufgen tool.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+