QGrpcSerializationFormat Class | Qt GRPC 6.8.0
Description: The QGrpcSerializationFormat class holds the protobuf message serializer and the related content type suffix.

- Qt 6.8
- Qt GRPC
- C++ Classes
- QtGrpc (Technical Preview)
- QGrpcSerializationFormat
- Qt 6.8.0 Reference Documentation

# QGrpcSerializationFormat Class

The QGrpcSerializationFormat class holds the protobuf message serializer and the related content type suffix. More...

Header: | #include <QGrpcSerializationFormat>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: | Qt 6.8
Status: | Technical Preview

- List of all members, including inherited members

## Public Types

enum | Format { Default, Protobuf, Json }

## Public Functions

| QGrpcSerializationFormat(QGrpcSerializationFormat::Format format = Format::Default)
| QGrpcSerializationFormat(QByteArrayView suffix, std::shared_ptr<QAbstractProtobufSerializer> serializer)
| QGrpcSerializationFormat(const QGrpcSerializationFormat &other)
| QGrpcSerializationFormat(QGrpcSerializationFormat &&other)
| ~QGrpcSerializationFormat()
std::shared_ptr<QAbstractProtobufSerializer> | serializer() const
QByteArray | suffix() const
QGrpcSerializationFormat & | operator=(QGrpcSerializationFormat &&other)
QGrpcSerializationFormat & | operator=(const QGrpcSerializationFormat &other)

## Detailed Description

Provides a serializer and the content type assigned to it to QAbstractGrpcChannel implementations.

To set serializer format, use either one of the existing presets or the user serializer.

See also QAbstractGrpcChannel.

## Member Type Documentation

### enum QGrpcSerializationFormat::Format

Holds presets for setting the protobuf serializer format.

Constant | Value | Description
--- | --- | ---
`QGrpcSerializationFormat::Default` | `0` | The default QGrpcSerializationFormat preset. This preset constructs QProtobufSerializer with an empty content type suffix.
`QGrpcSerializationFormat::Protobuf` | `1` | The embedded protobuf QGrpcSerializationFormat preset. This preset constructs QProtobufSerializer with the `proto` content type suffix.
`QGrpcSerializationFormat::Json` | `2` | The embedded JSON QGrpcSerializationFormat preset. This preset constructs QProtobufJsonSerializer with the `json` content type suffix.

See also suffix() and serializer().

## Member Function Documentation

### `[explicit]` QGrpcSerializationFormat::QGrpcSerializationFormat(QGrpcSerializationFormat::Format format = Format::Default)

Creates a new QGrpcSerializationFormat object with the given preset format.

The QGrpcSerializationFormat::Default format is used by default.

### QGrpcSerializationFormat::QGrpcSerializationFormat(QByteArrayView suffix, std::shared_ptr<QAbstractProtobufSerializer> serializer)

Creates a new QGrpcSerializationFormat object with the custom content type suffix and serializer.

### QGrpcSerializationFormat::QGrpcSerializationFormat(const QGrpcSerializationFormat &other)

Constructs a copy of other.

### QGrpcSerializationFormat::QGrpcSerializationFormat(QGrpcSerializationFormat &&other)

Move-constructs a QGrpcSerializationFormat instance from other.

### `[noexcept]` QGrpcSerializationFormat::~QGrpcSerializationFormat()

Destroys the QGrpcSerializationFormat object.

### `[noexcept]` std::shared_ptr<QAbstractProtobufSerializer> QGrpcSerializationFormat::serializer() const

Returns the serializer for this serialization format.

/sa QAbstractProtobufSerializer

### `[noexcept]` QByteArray QGrpcSerializationFormat::suffix() const

Returns the content type suffix for this serialization format.

### QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(QGrpcSerializationFormat &&other)

Moves the other QGrpcSerializationFormat object to this one.

### QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(const QGrpcSerializationFormat &other)

Assigns the other QGrpcSerializationFormat object to this one.