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
9#include <QtCore/qhash.h>
10#include <QtCore/qshareddata.h>
11#include <QtCore/qstringfwd.h>
12#include <QtCore/qtclasshelpermacros.h>
13
14#include <chrono>
15#include <optional>
16
17QT_BEGIN_NAMESPACE
18
19class QDebug;
20class QVariant;
21
22class QGrpcCallOptionsPrivate;
23QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QGrpcCallOptionsPrivate)
24
25class QGrpcCallOptions final
26{
27public:
28 Q_GRPC_EXPORT QGrpcCallOptions();
29 Q_GRPC_EXPORT ~QGrpcCallOptions();
30
31 Q_GRPC_EXPORT QGrpcCallOptions(const QGrpcCallOptions &other);
32 Q_GRPC_EXPORT QGrpcCallOptions &operator=(const QGrpcCallOptions &other);
33
34 QGrpcCallOptions(QGrpcCallOptions &&other) noexcept = default;
35 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGrpcCallOptions)
36
37 Q_GRPC_EXPORT Q_IMPLICIT operator QVariant() const;
38
39 void swap(QGrpcCallOptions &other) noexcept { d_ptr.swap(other&: other.d_ptr); }
40
41 [[nodiscard]] Q_GRPC_EXPORT std::optional<std::chrono::milliseconds>
42 deadlineTimeout() const noexcept;
43 Q_GRPC_EXPORT QGrpcCallOptions &setDeadlineTimeout(std::chrono::milliseconds timeout);
44
45 [[nodiscard]] Q_GRPC_EXPORT const QHash<QByteArray, QByteArray> &metadata() const & noexcept;
46 [[nodiscard]] Q_GRPC_EXPORT QHash<QByteArray, QByteArray> metadata() &&;
47 Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(const QHash<QByteArray, QByteArray> &metadata);
48 Q_GRPC_EXPORT QGrpcCallOptions &setMetadata(QHash<QByteArray, QByteArray> &&metadata);
49
50private:
51 QExplicitlySharedDataPointer<QGrpcCallOptionsPrivate> d_ptr;
52
53#ifndef QT_NO_DEBUG_STREAM
54 friend Q_GRPC_EXPORT QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts);
55#endif
56
57 Q_DECLARE_PRIVATE(QGrpcCallOptions)
58};
59
60Q_DECLARE_SHARED(QGrpcCallOptions)
61
62QT_END_NAMESPACE
63
64#endif // QGRPCALLOPTIONS_H
65

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtgrpc/src/grpc/qgrpccalloptions.h