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

source code of qtcoap/src/coap/qcoapoption.h