QCoapOption Class
Die Klasse „QCoapOption“ enthält Daten zu CoAP-Optionen. Mehr...
| Header: | #include <QCoapOption> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Coap) target_link_libraries(mytarget PRIVATE Qt6::Coap) |
| qmake: | QT += coap |
Hinweis: Alle Funktionen dieser Klasse sind reentrant.
Öffentliche Typen
| enum | OptionName { Invalid, IfMatch, UriHost, Etag, IfNoneMatch, …, Size1 } |
Öffentliche Funktionen
| QCoapOption(QCoapOption::OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray()) | |
| QCoapOption(QCoapOption::OptionName name, const QString &stringValue) | |
| QCoapOption(QCoapOption::OptionName name, quint32 intValue) | |
| QCoapOption(const QCoapOption &other) | |
| QCoapOption(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 |
| QCoapOption & | operator=(QCoapOption &&other) |
| QCoapOption & | operator=(const QCoapOption &other) |
| bool | operator==(const QCoapOption &other) const |
Ausführliche Beschreibung
CoAP definiert eine Reihe von Optionen, die in eine Nachricht aufgenommen werden können. Sowohl Anfragen als auch Antworten können eine Liste mit einer oder mehreren Optionen enthalten. Beispielsweise wird die URI in einer Anfrage in mehreren Optionen übertragen, und Metadaten, die bei HTTP in einem HTTP-Header enthalten wären, werden ebenfalls als Optionen bereitgestellt.
Eine Option enthält einen Namen, der mit einer Options-ID verknüpft ist, sowie einen Wert. Der Name ist einer der Werte aus der Aufzählung „ OptionName “.
Dokumentation zum Mitgliedstyp
enum QCoapOption::OptionName
Bezeichnet den Namen einer Option. Der Wert jeder ID entspricht den Vorgaben des CoAP-Standards, mit Ausnahme von „Invalid“. Weitere Einzelheiten finden Sie in RFC 7252 und RFC 7959.
| Konstante | Wert | Beschreibung |
|---|---|---|
QCoapOption::Invalid | 0 | Eine ungültige Option. |
QCoapOption::IfMatch | 1 | „If-Match“-Option. |
QCoapOption::UriHost | 3 | Option „Uri-Host“. |
QCoapOption::Etag | 4 | Option „Etag“. |
QCoapOption::IfNoneMatch | 5 | Option „If-None-Match“. |
QCoapOption::Observe | 6 | Option „Observe“. |
QCoapOption::UriPort | 7 | Option „Uri-Port“. |
QCoapOption::LocationPath | 8 | Option „Location-path“. |
QCoapOption::UriPath | 11 | Option „Uri-Path“. |
QCoapOption::ContentFormat | 12 | Option „Content-Format“. |
QCoapOption::MaxAge | 14 | Option „Max-Age“. |
QCoapOption::UriQuery | 15 | Option „Uri-Query“. |
QCoapOption::Accept | 17 | Option „Accept“. |
QCoapOption::LocationQuery | 20 | Option „Location-Query“. |
QCoapOption::Block2 | 23 | Option „Block2“. |
QCoapOption::Block1 | 27 | Option „Block1“. |
QCoapOption::Size2 | 28 | Option „Size2“. |
QCoapOption::ProxyUri | 35 | Option „Proxy-Uri“. |
QCoapOption::ProxyScheme | 39 | Option „Proxy-Scheme“. |
QCoapOption::Size1 | 60 | Option „Size1“. |
Dokumentation zu den Mitgliedsfunktionen
QCoapOption::QCoapOption(QCoapOption::OptionName name = Invalid, const QByteArray &opaqueValue = QByteArray())
Erstellt eine neue CoAP-Option mit den angegebenen Werten für „ name “, „ QByteArray “ und „ opaqueValue “. Werden keine Parameter übergeben, wird ein „Invalid“-Objekt erstellt.
Siehe auch isValid().
QCoapOption::QCoapOption(QCoapOption::OptionName name, const QString &stringValue)
Erstellt eine neue CoAP-Option mit dem angegebenen „ name “ und dem „ QString “ stringValue.
Siehe auch isValid().
QCoapOption::QCoapOption(QCoapOption::OptionName name, quint32 intValue)
Erstellt eine neue CoAP-Option mit dem angegebenen „ name “ und der vorzeichenlosen Ganzzahl „ intValue “.
Siehe auch ` isValid()`.
QCoapOption::QCoapOption(const QCoapOption &other)
Erstellt eine neue CoAP-Option als Kopie von other, wodurch die beiden Optionen identisch werden.
Siehe auch isValid().
QCoapOption::QCoapOption(QCoapOption &&other)
Erstellt ein „QCoapOption“-Objekt per Move-Konstruktion, sodass es auf dasselbe Objekt verweist wie zuvor „ other “.
[noexcept] QCoapOption::~QCoapOption()
Löscht das „ QCoapOption “-Objekt.
bool QCoapOption::isValid() const
Gibt „ true “ zurück, wenn die Option gültig ist.
int QCoapOption::length() const
Gibt die Länge des Wertes der Option zurück.
QCoapOption::OptionName QCoapOption::name() const
Gibt den Namen der Option zurück.
QByteArray QCoapOption::opaqueValue() const
Gibt den Wert der Option zurück.
QString QCoapOption::stringValue() const
Gibt den Wert „ QString “ der Option zurück.
[noexcept] void QCoapOption::swap(QCoapOption &other)
Tauscht diese Option mit „ other “ aus. Dieser Vorgang ist sehr schnell und schlägt niemals fehl.
quint32 QCoapOption::uintValue() const
Gibt den ganzzahligen Wert der Option zurück.
Hinweis: Eine uint-Option kann maximal 4 Bytes enthalten. Ist der Optionswert länger, werden zur Berechnung des Ergebnisses nur die unteren 4 Bytes verwendet; verwenden Sie length(), um einen zu langen Wert zu erkennen.
bool QCoapOption::operator!=(const QCoapOption &other) const
Gibt „ true “ zurück, wenn „ QCoapOption “ und „ other “ unterschiedlich sind.
[noexcept] QCoapOption &QCoapOption::operator=(QCoapOption &&other)
Verschiebt „ other “ in diese Option und gibt eine Referenz auf „ QCoapOption “ zurück.
QCoapOption &QCoapOption::operator=(const QCoapOption &other)
Kopiert „ other “ in diese Option, wodurch die beiden Optionen identisch werden. Gibt eine Referenz auf „ QCoapOption “ zurück.
bool QCoapOption::operator==(const QCoapOption &other) const
Gibt „ true “ zurück, wenn „ QCoapOption “ und „ other “ identisch sind.
© 2026 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.