| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QGRPCALLOPTIONS_H |
| 5 | #define QGRPCALLOPTIONS_H |
| 6 | |
| 7 | #include <QtGrpc/qtgrpcglobal.h> |
| 8 | #include <QtGrpc/qtgrpcnamespace.h> |
| 9 | |
| 10 | #include <QtCore/qhash.h> |
| 11 | #include <QtCore/qshareddata.h> |
| 12 | #include <QtCore/qstringfwd.h> |
| 13 | #include <QtCore/qtclasshelpermacros.h> |
| 14 | #include <QtCore/qtdeprecationdefinitions.h> |
| 15 | |
| 16 | #include <chrono> |
| 17 | #include <optional> |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class QDebug; |
| 22 | class QVariant; |
| 23 | |
| 24 | class QGrpcCallOptionsPrivate; |
| 25 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QGrpcCallOptionsPrivate) |
| 26 | |
| 27 | class QGrpcCallOptions final |
| 28 | { |
| 29 | public: |
| 30 | Q_GRPC_EXPORT QGrpcCallOptions(); |
| 31 | Q_GRPC_EXPORT ~QGrpcCallOptions(); |
| 32 | |
| 33 | Q_GRPC_EXPORT QGrpcCallOptions(const QGrpcCallOptions &other); |
| 34 | Q_GRPC_EXPORT QGrpcCallOptions &operator=(const QGrpcCallOptions &other); |
| 35 | |
| 36 | QGrpcCallOptions(QGrpcCallOptions &&other) noexcept = default; |
| 37 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGrpcCallOptions) |
| 38 | |
| 39 | Q_GRPC_EXPORT Q_IMPLICIT operator QVariant() const; |
| 40 | |
| 41 | void swap(QGrpcCallOptions &other) noexcept { d_ptr.swap(other&: other.d_ptr); } |
| 42 | |
| 43 | [[nodiscard]] Q_GRPC_EXPORT std::optional<std::chrono::milliseconds> |
| 44 | deadlineTimeout() const noexcept; |
| 45 | Q_GRPC_EXPORT QGrpcCallOptions &setDeadlineTimeout(std::chrono::milliseconds timeout); |
| 46 | |
| 47 | #if QT_DEPRECATED_SINCE(6, 13) |
| 48 | QT_DEPRECATED_VERSION_X_6_13("Use metadata(QtGrpc::MultiValue) for QMultiHash" ) |
| 49 | [[nodiscard]] Q_GRPC_EXPORT const QHash<QByteArray, QByteArray> &metadata() const & noexcept; |
| 50 | QT_DEPRECATED_VERSION_X_6_13("Use metadata(QtGrpc::MultiValue) for QMultiHash" ) |
| 51 | [[nodiscard]] Q_GRPC_EXPORT QHash<QByteArray, QByteArray> metadata() &&; |
| 52 | QT_DEPRECATED_VERSION_X_6_13("Use the QMultiHash overload" ) |
| 53 | Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QHash<QByteArray, QByteArray> &metadata); |
| 54 | QT_DEPRECATED_VERSION_X_6_13("Use the QMultiHash overload" ) |
| 55 | Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(QHash<QByteArray, QByteArray> &&metadata); |
| 56 | #endif |
| 57 | [[nodiscard]] Q_GRPC_EXPORT const QMultiHash<QByteArray, QByteArray> & |
| 58 | metadata(QtGrpc::MultiValue_t) const & noexcept; |
| 59 | [[nodiscard]] Q_GRPC_EXPORT QMultiHash<QByteArray, QByteArray> |
| 60 | metadata(QtGrpc::MultiValue_t) &&; |
| 61 | Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QMultiHash<QByteArray, QByteArray> &metadata); |
| 62 | Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(QMultiHash<QByteArray, QByteArray> &&metadata); |
| 63 | Q_GRPC_EXPORT QGrpcCallOptions & |
| 64 | setMetadata(std::initializer_list<std::pair<QByteArray, QByteArray>> list); |
| 65 | Q_GRPC_EXPORT QGrpcCallOptions &addMetadata(QByteArrayView key, QByteArrayView value); |
| 66 | |
| 67 | [[nodiscard]] Q_GRPC_EXPORT std::optional<bool> filterServerMetadata() const noexcept; |
| 68 | Q_GRPC_EXPORT QGrpcCallOptions &setFilterServerMetadata(bool value); |
| 69 | |
| 70 | private: |
| 71 | QExplicitlySharedDataPointer<QGrpcCallOptionsPrivate> d_ptr; |
| 72 | |
| 73 | #ifndef QT_NO_DEBUG_STREAM |
| 74 | friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts); |
| 75 | #endif |
| 76 | |
| 77 | Q_DECLARE_PRIVATE(QGrpcCallOptions) |
| 78 | }; |
| 79 | |
| 80 | Q_DECLARE_SHARED(QGrpcCallOptions) |
| 81 | |
| 82 | QT_END_NAMESPACE |
| 83 | |
| 84 | #endif // QGRPCALLOPTIONS_H |
| 85 | |