QProtobufSerializer Class

The QProtobufSerializer class is interface that represents basic functions for serialization/deserialization. 更多...

头: #include <QProtobufSerializer>
CMake: find_package(Qt6 REQUIRED COMPONENTS Protobuf)
target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
Since: Qt 6.5
继承: QAbstractProtobufSerializer

注意: 此类的所有函数 可重入 .

公共函数

QProtobufSerializer ()
virtual ~QProtobufSerializer () override
bool deserializeEnum (QtProtobuf::int64 & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const
bool deserializeEnumList (QList<QtProtobuf::int64> & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const
bool deserializeListObject (QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const
bool deserializeMapPair (QVariant & key , QVariant & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const
bool deserializeObject (QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const
QByteArray serializeEnum (QtProtobuf::int64 value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const
QByteArray serializeEnumList (const QList<QtProtobuf::int64> & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const
QByteArray serializeListObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const
QByteArray serializeMapPair (const QVariant & key , const QVariant & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const
QByteArray serializeObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

重实现公共函数

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
void qRegisterProtobufEnumType ()
void qRegisterProtobufMapType ()
void qRegisterProtobufType ()

详细描述

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.

成员函数文档编制

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.

bool QProtobufSerializer:: deserializeEnum ( QtProtobuf::int64 & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const

This function deserializes an enum value from a QProtobufSelfcheckIterator it 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

bool QProtobufSerializer:: deserializeEnumList ( QList < QtProtobuf::int64 > & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const

This function deserializes a list of enum value from a QProtobufSelfcheckIterator it 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

bool QProtobufSerializer:: deserializeListObject ( QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const

This function deserializes an message from byte stream as part of list property, with ordering from a QProtobufSelfcheckIterator it 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

bool QProtobufSerializer:: deserializeMapPair ( QVariant & key , QVariant & value , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const

This function deserializes QMap pair of key and value from a QProtobufSelfcheckIterator it 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

[override virtual] bool QProtobufSerializer:: deserializeMessage ( QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , QByteArrayView data ) const

重实现: 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 。返回 true if deserialization was successful, otherwise false .

bool QProtobufSerializer:: deserializeObject ( QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , QtProtobufPrivate::QProtobufSelfcheckIterator & it ) const

Deserialize an message with ordering from a QProtobufSelfcheckIterator it 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

QByteArray QProtobufSerializer:: serializeEnum ( QtProtobuf::int64 value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes value 作为 QByteArray for enum associated with property fieldInfo .

You should not call this function directly.

QByteArray QProtobufSerializer:: serializeEnumList (const QList < QtProtobuf::int64 > & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes a list, value , as a QByteArray for enum associated with property fieldInfo .

You should not call this function directly.

QByteArray QProtobufSerializer:: serializeListObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function is called to serialize message as a part of list property with ordering and fieldInfo .

You should not call this function directly.

QByteArray QProtobufSerializer:: serializeMapPair (const QVariant & key , const QVariant & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes QMap pair of key and value with fieldInfo QByteArray

You should not call this function directly.

[override virtual] QByteArray QProtobufSerializer:: serializeMessage (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering ) const

重实现: 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 不得为 nullptr 。返回 QByteArray containing the serialized message.

QByteArray QProtobufSerializer:: serializeObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

Serialize an message with ordering and fieldInfo 。返回 QByteArray containing the serialized message.

You should not call this function directly.

相关非成员

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 必须为 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.