| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QGRPCHANNELOPTIONS_H |
| 5 | #define QGRPCHANNELOPTIONS_H |
| 6 | |
| 7 | #include <QtGrpc/qtgrpcglobal.h> |
| 8 | |
| 9 | #if QT_CONFIG(ssl) |
| 10 | # include <QtNetwork/qsslconfiguration.h> |
| 11 | #endif |
| 12 | |
| 13 | #include <QtCore/qhash.h> |
| 14 | #include <QtCore/qshareddata.h> |
| 15 | #include <QtCore/qstringfwd.h> |
| 16 | #include <QtCore/qtclasshelpermacros.h> |
| 17 | #include <QtCore/qurl.h> |
| 18 | |
| 19 | #include <chrono> |
| 20 | #include <optional> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QDebug; |
| 25 | class QVariant; |
| 26 | class QGrpcSerializationFormat; |
| 27 | |
| 28 | class QGrpcChannelOptionsPrivate; |
| 29 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QGrpcChannelOptionsPrivate) |
| 30 | |
| 31 | class QGrpcChannelOptions final |
| 32 | { |
| 33 | public: |
| 34 | Q_GRPC_EXPORT QGrpcChannelOptions(); |
| 35 | Q_GRPC_EXPORT ~QGrpcChannelOptions(); |
| 36 | |
| 37 | Q_GRPC_EXPORT QGrpcChannelOptions(const QGrpcChannelOptions &other); |
| 38 | Q_GRPC_EXPORT QGrpcChannelOptions &operator=(const QGrpcChannelOptions &other); |
| 39 | |
| 40 | QGrpcChannelOptions(QGrpcChannelOptions &&other) noexcept = default; |
| 41 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGrpcChannelOptions) |
| 42 | |
| 43 | Q_GRPC_EXPORT Q_IMPLICIT operator QVariant() const; |
| 44 | |
| 45 | void swap(QGrpcChannelOptions &other) noexcept { d_ptr.swap(other&: other.d_ptr); } |
| 46 | |
| 47 | [[nodiscard]] Q_GRPC_EXPORT std::optional<std::chrono::milliseconds> |
| 48 | deadlineTimeout() const noexcept; |
| 49 | Q_GRPC_EXPORT QGrpcChannelOptions &setDeadlineTimeout(std::chrono::milliseconds timeout); |
| 50 | |
| 51 | [[nodiscard]] Q_GRPC_EXPORT const QHash<QByteArray, QByteArray> &metadata() const & noexcept; |
| 52 | [[nodiscard]] Q_GRPC_EXPORT QHash<QByteArray, QByteArray> metadata() &&; |
| 53 | Q_GRPC_EXPORT QGrpcChannelOptions &setMetadata(const QHash<QByteArray, QByteArray> &metadata); |
| 54 | Q_GRPC_EXPORT QGrpcChannelOptions &setMetadata(QHash<QByteArray, QByteArray> &&metadata); |
| 55 | |
| 56 | [[nodiscard]] Q_GRPC_EXPORT QGrpcSerializationFormat serializationFormat() const; |
| 57 | Q_GRPC_EXPORT QGrpcChannelOptions & |
| 58 | setSerializationFormat(const QGrpcSerializationFormat &format); |
| 59 | |
| 60 | #if QT_CONFIG(ssl) |
| 61 | [[nodiscard]] Q_GRPC_EXPORT std::optional<QSslConfiguration> sslConfiguration() const; |
| 62 | Q_GRPC_EXPORT QGrpcChannelOptions & |
| 63 | setSslConfiguration(const QSslConfiguration &sslConfiguration); |
| 64 | #endif |
| 65 | |
| 66 | private: |
| 67 | QExplicitlySharedDataPointer<QGrpcChannelOptionsPrivate> d_ptr; |
| 68 | |
| 69 | #ifndef QT_NO_DEBUG_STREAM |
| 70 | friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcChannelOptions &chOpts); |
| 71 | #endif |
| 72 | |
| 73 | Q_DECLARE_PRIVATE(QGrpcChannelOptions) |
| 74 | }; |
| 75 | |
| 76 | Q_DECLARE_SHARED(QGrpcChannelOptions) |
| 77 | |
| 78 | QT_END_NAMESPACE |
| 79 | |
| 80 | #endif // QGRPCHANNELOPTIONS_H |
| 81 |
