QGrpcSerializationFormat Class
Die Klasse QGrpcSerializationFormat enthält den Protobuf-Nachrichtenserialisierer und das zugehörige Content-Type-Suffix. Mehr...
Kopfzeile: | #include <QGrpcSerializationFormat> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc) |
Seit: | Qt 6.8 |
Diese Klasse ist gleichwertig vergleichbar.
Ö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) QVariant | operator QVariant() const |
QGrpcSerializationFormat & | operator=(QGrpcSerializationFormat &&other) |
QGrpcSerializationFormat & | operator=(const QGrpcSerializationFormat &other) |
Verwandte Nicht-Mitglieder
(since 6.8) QDebug | operator<<(QDebug debug, const QGrpcSerializationFormat &sfmt) |
Detaillierte Beschreibung
Die Klasse QGrpcSerializationFormat enthält die serializer, die für die Serialisierung und Deserialisierung von Protobuf-Nachrichten verwendet wird, sowie den zugehörigen Content-Type suffix, der die Nachrichtenkodierung beim Transport angibt. Für HTTP/2-spezifische Details siehe den Abschnitt Content-Type.
Hinweis: Der Content-Type ist transport- und damit implementierungsspezifisch.
Die Klasse kann mit einem der SerializationFormat Presets oder einem benutzerdefinierten Suffix und Serializer erstellt werden:
QGrpcSerializationFormat jsonFormat(QtGrpc::SerializationFormat::Json);
Dadurch wird eine QProtobufJsonSerializer mit dem Suffix json
erstellt. Für den HTTP/2-Transport ergibt dies den Inhaltstyp application/grpc+json
.
class DummySerializer : public QAbstractProtobufSerializer { ... }; QGrpcSerializationFormat dummyFormat("dummy", std::make_shared<DummySerializer>());
Dies verwendet DummySerializer
für die Kodierung und Dekodierung von Nachrichten mit dem Suffix dummy
. Für den HTTP/2-Transport ergibt sich daraus der Content-Type application/grpc+dummy
.
Hinweis: Benutzerdefinierte Serialisierer erfordern Serverunterstützung für das angegebene Format.
Siehe auch QGrpcChannelOptions::serializationFormat.
Dokumentation der Mitgliedsfunktionen
QGrpcSerializationFormat::QGrpcSerializationFormat(QtGrpc::SerializationFormat format = {})
Konstruiert ein neues QGrpcSerializationFormat mit der angegebenen Voreinstellung format.
Das verwendete Standardformat ist SerializationFormat::Default.
[explicit]
QGrpcSerializationFormat::QGrpcSerializationFormat(QByteArrayView suffix, std::shared_ptr<QAbstractProtobufSerializer> serializer)
Konstruiert ein neues QGrpcSerializationFormat mit einem benutzerdefinierten Inhaltstyp, der durch suffix angegeben wird, und einer protobuf-Nachricht serializer.
QGrpcSerializationFormat::QGrpcSerializationFormat(const QGrpcSerializationFormat &other)
Konstruiert eine Kopie von other.
[noexcept]
QGrpcSerializationFormat::QGrpcSerializationFormat(QGrpcSerializationFormat &&other)
Move-konstruiert ein neues QGrpcSerializationFormat aus other.
Hinweis: Das verschobene Objekt other wird in einen teilweise gebildeten Zustand versetzt, in dem die einzigen gültigen Operationen die Zerstörung und die Zuweisung eines neuen Wertes sind.
[noexcept]
QGrpcSerializationFormat::~QGrpcSerializationFormat()
Zerstört die QGrpcSerializationFormat.
std::shared_ptr<QAbstractProtobufSerializer> QGrpcSerializationFormat::serializer() const
Gibt den Serialisierer 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 mit diesem Objekt aus. Dieser Vorgang ist sehr schnell und schlägt nie fehl.
Diese Funktion wurde in Qt 6.8 eingeführt.
[since 6.8]
QVariant QGrpcSerializationFormat::operator QVariant() const
Konstruiert ein neues QVariant aus diesem Objekt.
Diese Funktion wurde in Qt 6.8 eingeführt.
[noexcept]
QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(QGrpcSerializationFormat &&other)
Move weist other dieser Instanz QGrpcSerializationFormat zu und gibt einen Verweis auf sie zurück.
Hinweis: Das verschobene Objekt other wird in einen teilweise gebildeten Zustand versetzt, in dem die einzigen gültigen Operationen Zerstörung und Zuweisung eines neuen Wertes sind.
QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(const QGrpcSerializationFormat &other)
Weist diesem das Objekt other QGrpcSerializationFormat zu.
Verwandte Nicht-Mitglieder
[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.
© 2025 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.