QCoapOption Class

The QCoapOption class holds data about CoAP options. More...

Header: #include <QCoapOption>
qmake: QT += coap

Note: All functions in this class are reentrant.

Public Types

enum OptionName { Invalid, IfMatch, UriHost, Etag, IfNoneMatch, …, Size1 }

Public Functions

QCoapOption(QCoapOption &&other)
QCoapOption(const QCoapOption &other)
QCoapOption(QCoapOption::OptionName name, quint32 intValue)
QCoapOption(QCoapOption::OptionName name, const QString &stringValue)
QCoapOption(QCoapOption::OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray())
QCoapOption &operator=(QCoapOption &&other)
QCoapOption &operator=(const QCoapOption &other)
~QCoapOption()
bool isValid() const
int length() const
QCoapOption::OptionName name() const
QByteArray opaqueValue() const
QString stringValue() const
void swap(QCoapOption &other)
quint32 uintValue() const
bool operator!=(const QCoapOption &other) const
bool operator==(const QCoapOption &other) const

Detailed Description

CoAP defines a number of options that can be included in a message. Both requests and responses may include a list of one or more options. For example, the URI in a request is transported in several options, and metadata that would be carried in an HTTP header in HTTP is supplied as options as well.

An option contains a name, related to an option ID, and a value. The name is one of the values from the OptionName enumeration.

Member Type Documentation

enum QCoapOption::OptionName

Indicates the name of an option. The value of each ID is as specified by the CoAP standard, with the exception of Invalid. You can refer to RFC 7252 and RFC 7959 for more details.

ConstantValueDescription
QCoapOption::Invalid0An invalid option.
QCoapOption::IfMatch1If-Match option.
QCoapOption::UriHost3Uri-Host option.
QCoapOption::Etag4Etag option.
QCoapOption::IfNoneMatch5If-None-Match option.
QCoapOption::Observe6Observe option.
QCoapOption::UriPort7Uri-Port option.
QCoapOption::LocationPath8Location-path option.
QCoapOption::UriPath11Uri-Path option.
QCoapOption::ContentFormat12Content-Format option.
QCoapOption::MaxAge14Max-Age option.
QCoapOption::UriQuery15Uri-Query option.
QCoapOption::Accept17Accept option.
QCoapOption::LocationQuery20Location-Query option.
QCoapOption::Block223Block2 option.
QCoapOption::Block127Block1 option.
QCoapOption::Size228Size2 option.
QCoapOption::ProxyUri35Proxy-Uri option.
QCoapOption::ProxyScheme39Proxy-Scheme option.
QCoapOption::Size160Size1 option.

Member Function Documentation

QCoapOption::QCoapOption(QCoapOption &&other)

Move-constructs a QCoapOption, making it point to the same object as other was pointing to.

QCoapOption::QCoapOption(const QCoapOption &other)

Constructs a new CoAP option as a copy of other, making the two options identical.

See also isValid().

QCoapOption::QCoapOption(QCoapOption::OptionName name, quint32 intValue)

Constructs a new CoAP option with the given name and the unsigned integer intValue.

See also isValid().

QCoapOption::QCoapOption(QCoapOption::OptionName name, const QString &stringValue)

Constructs a new CoAP option with the given name and the QString stringValue.

See also isValid().

QCoapOption::QCoapOption(QCoapOption::OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray())

Constructs a new CoAP option with the given name and QByteArray opaqueValue. If no parameters are passed, constructs an Invalid object.

See also isValid().

QCoapOption &QCoapOption::operator=(QCoapOption &&other)

Move-assignment operator.

QCoapOption &QCoapOption::operator=(const QCoapOption &other)

Copies other into this option, making the two options identical. Returns a reference to this QCoapOption.

QCoapOption::~QCoapOption()

Destroys the QCoapOption object.

bool QCoapOption::isValid() const

Returns true if the option is valid.

int QCoapOption::length() const

Returns the length of the value of the option.

QCoapOption::OptionName QCoapOption::name() const

Returns the name of the option.

QByteArray QCoapOption::opaqueValue() const

Returns the value of the option.

QString QCoapOption::stringValue() const

Returns the QString value of the option.

void QCoapOption::swap(QCoapOption &other)

Swaps this option with other. This operation is very fast and never fails.

quint32 QCoapOption::uintValue() const

Returns the integer value of the option.

bool QCoapOption::operator!=(const QCoapOption &other) const

Returns true if this QCoapOption and other are different.

bool QCoapOption::operator==(const QCoapOption &other) const

Returns true if this QCoapOption and other are equals.

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.