QProtobufBaseSerializer Class | Qt Protobuf 6.7.1
Description: The QProtobufBaseSerializer class is an interface that represents basic functions for serializing/deserializing objects, lists, and enums.

- Qt 6.7
- Qt Protobuf
- C++ Classes
- QtProtobuf (Technical Preview)
- QProtobufBaseSerializer
- Qt 6.7.1 Reference Documentation

# QProtobufBaseSerializer Class

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

Header: | #include <QProtobufBaseSerializer>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Protobuf) target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
Since: | Qt 6.7
Inherits: | QAbstractProtobufSerializer
Inherited By: | QProtobufJsonSerializer and QProtobufSerializer
Status: | Technical Preview

- List of all members, including inherited members

## Public Functions

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

## Related Non-Members

void | qRegisterProtobufEnumType()
void | qRegisterProtobufMapType()
void | qRegisterProtobufType()

## Detailed Description

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

## Member Function Documentation

### `[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.

See also 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.

See also 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.

See also 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.

See also 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 must not be `nullptr`. Returns `true` if deserialization was successful, otherwise `false`.

You should not call this function directly.

See also 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.

See also 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.

See also 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.

See also 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.

See also 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 must not be `nullptr`.

You should not call this function directly.

See also QProtobufBaseSerializer::deserializeObject().

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