| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QGRPCSERIALIZATIONFORMAT_H |
| 5 | #define QGRPCSERIALIZATIONFORMAT_H |
| 6 | |
| 7 | #include <QtGrpc/qtgrpcglobal.h> |
| 8 | #include <QtGrpc/qtgrpcnamespace.h> |
| 9 | |
| 10 | #include <QtCore/qbytearrayview.h> |
| 11 | #include <QtCore/qshareddata.h> |
| 12 | #include <QtCore/qtclasshelpermacros.h> |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | QT_BEGIN_NAMESPACE |
| 17 | |
| 18 | class QAbstractProtobufSerializer; |
| 19 | class QDebug; |
| 20 | class QVariant; |
| 21 | |
| 22 | class QGrpcSerializationFormatPrivate; |
| 23 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QGrpcSerializationFormatPrivate) |
| 24 | |
| 25 | class QGrpcSerializationFormat final |
| 26 | { |
| 27 | public: |
| 28 | Q_GRPC_EXPORT Q_IMPLICIT QGrpcSerializationFormat(QtGrpc::SerializationFormat format = {}); |
| 29 | Q_GRPC_EXPORT explicit QGrpcSerializationFormat(QByteArrayView suffix, |
| 30 | std::shared_ptr<QAbstractProtobufSerializer> |
| 31 | serializer); |
| 32 | Q_GRPC_EXPORT ~QGrpcSerializationFormat(); |
| 33 | |
| 34 | Q_GRPC_EXPORT QGrpcSerializationFormat(const QGrpcSerializationFormat &); |
| 35 | Q_GRPC_EXPORT QGrpcSerializationFormat &operator=(const QGrpcSerializationFormat &); |
| 36 | |
| 37 | QGrpcSerializationFormat(QGrpcSerializationFormat &&other) noexcept = default; |
| 38 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGrpcSerializationFormat) |
| 39 | |
| 40 | Q_GRPC_EXPORT Q_IMPLICIT operator QVariant() const; |
| 41 | |
| 42 | void swap(QGrpcSerializationFormat &other) noexcept { d_ptr.swap(other&: other.d_ptr); } |
| 43 | |
| 44 | [[nodiscard]] Q_GRPC_EXPORT QByteArrayView suffix() const noexcept; |
| 45 | |
| 46 | [[nodiscard]] Q_GRPC_EXPORT std::shared_ptr<QAbstractProtobufSerializer> serializer() const; |
| 47 | |
| 48 | private: |
| 49 | QExplicitlySharedDataPointer<QGrpcSerializationFormatPrivate> d_ptr; |
| 50 | |
| 51 | Q_GRPC_EXPORT friend bool comparesEqual(const QGrpcSerializationFormat &lhs, |
| 52 | const QGrpcSerializationFormat &rhs) noexcept; |
| 53 | Q_DECLARE_EQUALITY_COMPARABLE(QGrpcSerializationFormat) |
| 54 | |
| 55 | Q_GRPC_EXPORT friend size_t qHash(const QGrpcSerializationFormat &key, size_t seed) noexcept; |
| 56 | friend size_t qHash(const QGrpcSerializationFormat &key) noexcept { return qHash(key, seed: 0); } |
| 57 | |
| 58 | #ifndef QT_NO_DEBUG_STREAM |
| 59 | friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcSerializationFormat &sfmt); |
| 60 | #endif |
| 61 | |
| 62 | Q_DECLARE_PRIVATE(QGrpcSerializationFormat) |
| 63 | }; |
| 64 | |
| 65 | Q_DECLARE_SHARED(QGrpcSerializationFormat) |
| 66 | |
| 67 | QT_END_NAMESPACE |
| 68 | |
| 69 | #endif // QGRPCSERIALIZATIONFORMAT_H |
| 70 |
