1 | // Copyright (C) 2017 Witekio. |
2 | // Copyright (C) 2018 The Qt Company Ltd. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
4 | |
5 | #ifndef QCOAPOPTION_H |
6 | #define QCOAPOPTION_H |
7 | |
8 | #include <QtCore/qglobal.h> |
9 | #include <QtCoap/qcoapglobal.h> |
10 | #include <QtCore/qobject.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QCoapOptionPrivate; |
15 | class Q_COAP_EXPORT QCoapOption |
16 | { |
17 | public: |
18 | enum OptionName { |
19 | Invalid = 0, |
20 | IfMatch = 1, |
21 | UriHost = 3, |
22 | Etag = 4, |
23 | IfNoneMatch = 5, |
24 | Observe = 6, |
25 | UriPort = 7, |
26 | LocationPath = 8, |
27 | UriPath = 11, |
28 | ContentFormat = 12, |
29 | MaxAge = 14, |
30 | UriQuery = 15, |
31 | Accept = 17, |
32 | LocationQuery = 20, |
33 | Block2 = 23, |
34 | Block1 = 27, |
35 | Size2 = 28, |
36 | ProxyUri = 35, |
37 | ProxyScheme = 39, |
38 | Size1 = 60 |
39 | }; |
40 | |
41 | QCoapOption(OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray()); |
42 | QCoapOption(OptionName name, const QString &stringValue); |
43 | QCoapOption(OptionName name, quint32 intValue); |
44 | QCoapOption(const QCoapOption &other); |
45 | QCoapOption(QCoapOption &&other); |
46 | ~QCoapOption(); |
47 | |
48 | QCoapOption &operator=(const QCoapOption &other); |
49 | QCoapOption &operator=(QCoapOption &&other) noexcept; |
50 | void swap(QCoapOption &other) noexcept; |
51 | |
52 | QByteArray opaqueValue() const; |
53 | quint32 uintValue() const; |
54 | QString stringValue() const; |
55 | int length() const; |
56 | OptionName name() const; |
57 | bool isValid() const; |
58 | |
59 | bool operator==(const QCoapOption &other) const; |
60 | bool operator!=(const QCoapOption &other) const; |
61 | |
62 | private: |
63 | QCoapOptionPrivate *d_ptr; |
64 | |
65 | // Q_DECLARE_PRIVATE equivalent for shared data pointers |
66 | inline QCoapOptionPrivate *d_func(); |
67 | const QCoapOptionPrivate *d_func() const { return d_ptr; } |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | Q_DECLARE_METATYPE(QCoapOption::OptionName) |
73 | Q_DECLARE_METATYPE(QCoapOption) |
74 | |
75 | #endif // QCOAPOPTION_H |
76 | |