Auf dieser Seite

QGrpcSerializationFormat Class

Die Klasse „QGrpcSerializationFormat“ enthält den Protobuf-Nachrichtenserialisierer und das zugehörige Content-Type-Suffix. Mehr...

Header: #include <QGrpcSerializationFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Seit: Qt 6.8

Vergleiche von QGrpcSerializationFormat

KategorieVergleichbare Typen
GleichheitQGrpcSerializationFormat

Öffentliche Funktionen

QGrpcSerializationFormat(QtGrpc::SerializationFormat format = {})
QGrpcSerializationFormat(QByteArrayView suffix, std::shared_ptr<QAbstractProtobufSerializer> serializer)
QGrpcSerializationFormat(const QGrpcSerializationFormat &other)
QGrpcSerializationFormat(QGrpcSerializationFormat &&other)
~QGrpcSerializationFormat()
std::shared_ptr<QAbstractProtobufSerializer> serializer() const
QByteArrayView suffix() const
(since 6.8) void swap(QGrpcSerializationFormat &other)
(since 6.8) operator QVariant() const
QGrpcSerializationFormat &operator=(QGrpcSerializationFormat &&other)
QGrpcSerializationFormat &operator=(const QGrpcSerializationFormat &other)
(since 6.8) size_t qHash(const QGrpcSerializationFormat &key)
(since 6.8) size_t qHash(const QGrpcSerializationFormat &key, size_t seed)
(since 6.8) bool operator!=(const QGrpcSerializationFormat &lhs, const QGrpcSerializationFormat &rhs)
(since 6.8) QDebug operator<<(QDebug debug, const QGrpcSerializationFormat &sfmt)
(since 6.8) bool operator==(const QGrpcSerializationFormat &lhs, const QGrpcSerializationFormat &rhs)

Ausführliche Beschreibung

Die Klasse „QGrpcSerializationFormat“ enthält das „ serializer “, das zum Serialisieren und Deserialisieren von Protobuf-Nachrichten verwendet wird, sowie den zugehörigen Content-Type „ suffix “, der die Kodierung der Nachricht beim Transport angibt. Spezifische Details zu HTTP/2 finden Sie im Abschnitt „ Content-Type “.

Hinweis: Der Content-Type ist transport-spezifisch und daher implementierungsabhängig.

Die Klasse kann mithilfe einer der Voreinstellungen unter „ SerializationFormat “ oder mit einem benutzerdefinierten Suffix und Serializer erstellt werden:

QGrpcSerializationFormat jsonFormat(QtGrpc::SerializationFormat::Json);

Dadurch wird ein „ QProtobufJsonSerializer “ mit dem Suffix „ json “ erstellt. Für den HTTP/2-Transport ergibt sich daraus der Content-Type „ application/grpc+json “.

class DummySerializer : public QAbstractProtobufSerializer
{
    ...
};
QGrpcSerializationFormat dummyFormat("dummy", std::make_shared<DummySerializer>());

Hierbei wird „ DummySerializer “ zum Kodieren und Dekodieren von Nachrichten mit dem Suffix „ dummy “ verwendet. Bei der HTTP/2-Übertragung ergibt sich daraus der Content-Type „ application/grpc+dummy “.

Hinweis: Benutzerdefinierte Serializer erfordern Serverunterstützung für das angegebene Format.

Siehe auch QGrpcChannelOptions::serializationFormat.

Dokumentation zu Mitgliedsfunktionen

QGrpcSerializationFormat::QGrpcSerializationFormat(QtGrpc::SerializationFormat format = {})

Erstellt ein neues `QGrpcSerializationFormat` mit der angegebenen Voreinstellung „ format “.

Das standardmäßig verwendete Format ist „ SerializationFormat::Default “.

[explicit] QGrpcSerializationFormat::QGrpcSerializationFormat(QByteArrayView suffix, std::shared_ptr<QAbstractProtobufSerializer> serializer)

Erstellt ein neues `QGrpcSerializationFormat` mit einem benutzerdefinierten Inhaltstyp, der durch ` suffix ` angegeben wird, und einer Protobuf-Nachricht ` serializer`.

QGrpcSerializationFormat::QGrpcSerializationFormat(const QGrpcSerializationFormat &other)

Erstellt eine Kopie von „ other “.

[constexpr noexcept default] QGrpcSerializationFormat::QGrpcSerializationFormat(QGrpcSerializationFormat &&other)

Erstellt ein neues `QGrpcSerializationFormat` aus ` other`.

Hinweis: Das Objekt, aus dem die Verschiebung erfolgte ( other ), befindet sich in einem teilweise initialisierten Zustand, in dem die einzigen zulässigen Operationen die Zerstörung und die Zuweisung eines neuen Werts sind.

[noexcept] QGrpcSerializationFormat::~QGrpcSerializationFormat()

Zerstört die „ QGrpcSerializationFormat “.

std::shared_ptr<QAbstractProtobufSerializer> QGrpcSerializationFormat::serializer() const

Gibt den Serializer für dieses Serialisierungsformat zurück.

/sa QAbstractProtobufSerializer

[noexcept] QByteArrayView QGrpcSerializationFormat::suffix() const

Gibt das Content-Type-Suffix für dieses Serialisierungsformat zurück.

[noexcept, since 6.8] void QGrpcSerializationFormat::swap(QGrpcSerializationFormat &other)

Tauscht „ other “ gegen dieses Objekt aus. Dieser Vorgang ist sehr schnell und schlägt niemals fehl.

Diese Funktion wurde in Qt 6.8 eingeführt.

[since 6.8] QGrpcSerializationFormat::operator QVariant() const

Erstellt aus diesem Objekt ein neues ` QVariant `.

Diese Funktion wurde in Qt 6.8 eingeführt.

[noexcept] QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(QGrpcSerializationFormat &&other)

Die Move-Zuweisung weist other dieser Instanz von QGrpcSerializationFormat zu und gibt eine Referenz darauf zurück.

Hinweis: Das Objekt „ other “, aus dem die Zuweisung erfolgt, wird in einen teilweise initialisierten Zustand versetzt, in dem die einzigen zulässigen Operationen die Zerstörung und die Zuweisung eines neuen Werts sind.

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

Weist diesem Objekt das Objekt „ other “ QGrpcSerializationFormat zu.

Verwandte Nicht-Mitglieder

[noexcept, since 6.8] size_t qHash(const QGrpcSerializationFormat &key)

Gibt den Hash-Wert von key zurück, wobei 0 als Startwert für die Berechnung verwendet wird.

Diese Funktion wurde in Qt 6.8 eingeführt.

[noexcept, since 6.8] size_t qHash(const QGrpcSerializationFormat &key, size_t seed)

Gibt den Hash-Wert von key zurück, wobei seed als Startwert für die Berechnung verwendet wird.

Diese Funktion wurde in Qt 6.8 eingeführt.

[noexcept, since 6.8] bool operator!=(const QGrpcSerializationFormat &lhs, const QGrpcSerializationFormat &rhs)

Gibt „ true “ zurück, wenn die Werte von „ suffix “ und „ serializer “ in „ lhs “ und „ rhs “ nicht übereinstimmen.

Diese Funktion wurde in Qt 6.8 eingeführt.

[since 6.8] QDebug operator<<(QDebug debug, const QGrpcSerializationFormat &sfmt)

Schreibt „ sfmt “ in den angegebenen Stream „ debug “.

Diese Funktion wurde in Qt 6.8 eingeführt.

[noexcept, since 6.8] bool operator==(const QGrpcSerializationFormat &lhs, const QGrpcSerializationFormat &rhs)

Gibt „ true “ zurück, wenn die Werte von „ suffix “ und „ serializer “ in „ lhs “ und „ rhs “ identisch sind.

Diese Funktion wurde in Qt 6.8 eingeführt.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.