QProtobufBaseSerializer Class

The QProtobufBaseSerializer class is an interface that represents basic functions for serializing/deserializing objects, lists, and enums. 更多...

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

QProtobufJsonSerializer and QProtobufSerializer

状态: 技术预览

公共函数

virtual bool deserializeEnum (QtProtobuf::int64 & value , const QMetaEnum & metaEnum ) const = 0
virtual bool deserializeEnumList (QList<QtProtobuf::int64> & value , const QMetaEnum & metaEnum ) const = 0
virtual bool deserializeListObject (QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering ) const = 0
virtual bool deserializeMapPair (QVariant & key , QVariant & value ) const = 0
virtual bool deserializeObject (QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering ) const = 0
virtual void serializeEnum (QtProtobuf::int64 value , const QMetaEnum & metaEnum , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const = 0
virtual void serializeEnumList (const QList<QtProtobuf::int64> & value , const QMetaEnum & metaEnum , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const = 0
virtual void serializeListObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const = 0
virtual void serializeMapPair (const QVariant & key , const QVariant & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const = 0
virtual void serializeObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const = 0
void qRegisterProtobufEnumType ()
void qRegisterProtobufMapType ()
void qRegisterProtobufType ()

详细描述

The QProtobufBaseSerializer 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 function qt_add_protobuf or by running qtprotobufgen 直接。

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.

成员函数文档编制

[pure virtual] bool QProtobufBaseSerializer:: deserializeEnum ( QtProtobuf::int64 & value , const QMetaEnum & metaEnum ) const

This function deserializes an enum value from a wire. metaEnum helps to decode the enum value. Returns true if deserialization was successful, otherwise false .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::serializeEnum ().

[pure virtual] bool QProtobufBaseSerializer:: deserializeEnumList ( QList < QtProtobuf::int64 > & value , const QMetaEnum & metaEnum ) const

This function deserializes a list of enum value from a wire. metaEnum helps to decode the enum value. Returns true if deserialization was successful, otherwise false .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::serializeEnumList ().

[pure virtual] bool QProtobufBaseSerializer:: deserializeListObject ( QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering ) const

This function deserializes an message from byte stream as part of list property, with the associated message ordering from a wire. Returns true if deserialization was successful, otherwise false .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::serializeListObject ().

[pure virtual] bool QProtobufBaseSerializer:: deserializeMapPair ( QVariant & key , QVariant & value ) const

This function deserializes a pair of key and value from a wire. Returns true if deserialization was successful, otherwise false .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::serializeMapPair ().

[pure virtual] bool QProtobufBaseSerializer:: deserializeObject ( QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering ) const

This function deserializes a registered Protobuf message message with defined ordering . message 不得为 nullptr 。返回 true if deserialization was successful, otherwise false .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::serializeObject ().

[pure virtual] void QProtobufBaseSerializer:: serializeEnum ( QtProtobuf::int64 value , const QMetaEnum & metaEnum , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes value from enum associated with property fieldInfo . metaEnum helps to encode the enum value.

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::deserializeEnum ().

[pure virtual] void QProtobufBaseSerializer:: serializeEnumList (const QList < QtProtobuf::int64 > & value , const QMetaEnum & metaEnum , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes a list, value , for enum list associated with property fieldInfo . metaEnum helps to encode the enum value.

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::deserializeEnumList ().

[pure virtual] void QProtobufBaseSerializer:: serializeListObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes message as part of a list of messages one by one with ordering and fieldInfo .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::deserializeListObject ().

[pure virtual] void QProtobufBaseSerializer:: serializeMapPair (const QVariant & key , const QVariant & value , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes pair of key and value , that belong as a protobuf map record, according to fieldInfo .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::deserializeMapPair ().

[pure virtual] void QProtobufBaseSerializer:: serializeObject (const QProtobufMessage * message , const QtProtobufPrivate::QProtobufPropertyOrdering & ordering , const QtProtobufPrivate::QProtobufPropertyOrderingInfo & fieldInfo ) const

This function serializes a registered Protobuf message message with defined ordering and fieldInfo , that is recognized like an object, into a QByteArray . message 不得为 nullptr .

You should not call this function directly.

另请参阅 QProtobufBaseSerializer::deserializeObject ().

相关非成员

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.