In questa pagina

QCoapOption Class

La classe QCoapOption contiene dati relativi alle opzioni CoAP. Maggiori informazioni...

Intestazione: #include <QCoapOption>
CMake: find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)
qmake: QT += coap

Nota: tutte le funzioni di questa classe sono rientranti.

Tipi pubblici

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

Funzioni pubbliche

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

Descrizione dettagliata

CoAP definisce una serie di opzioni che possono essere incluse in un messaggio. Sia le richieste che le risposte possono includere un elenco di una o più opzioni. Ad esempio, l'URI in una richiesta viene trasportato in diverse opzioni, e anche i metadati che in HTTP verrebbero trasportati in un'intestazione HTTP vengono forniti come opzioni.

Un'opzione contiene un nome, associato a un ID opzione, e un valore. Il nome è uno dei valori dell'enumerazione OptionName.

Documentazione sui tipi di membro

enum QCoapOption::OptionName

Indica il nome di un'opzione. Il valore di ciascun ID è quello specificato dallo standard CoAP, ad eccezione di "Invalid". Per ulteriori dettagli, consultare le RFC 7252 e RFC 7959.

CostanteValoreDescrizione
QCoapOption::Invalid0Un'opzione non valida.
QCoapOption::IfMatch1Opzione If-Match.
QCoapOption::UriHost3Opzione Uri-Host.
QCoapOption::Etag4Opzione Etag.
QCoapOption::IfNoneMatch5Opzione If-None-Match.
QCoapOption::Observe6Opzione Observe.
QCoapOption::UriPort7Opzione Uri-Port.
QCoapOption::LocationPath8Opzione Location-path.
QCoapOption::UriPath11Opzione Uri-Path.
QCoapOption::ContentFormat12Opzione Content-Format.
QCoapOption::MaxAge14Opzione Max-Age.
QCoapOption::UriQuery15Opzione Uri-Query.
QCoapOption::Accept17Opzione Accept.
QCoapOption::LocationQuery20Opzione Location-Query.
QCoapOption::Block223Opzione Block2.
QCoapOption::Block127Opzione Block1.
QCoapOption::Size228Opzione Size2.
QCoapOption::ProxyUri35Opzione Proxy-Uri.
QCoapOption::ProxyScheme39Opzione Proxy-Scheme.
QCoapOption::Size160Opzione Size1.

Documentazione delle funzioni membro

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

Crea una nuova opzione CoAP con i valori specificati per name, QByteArray e opaqueValue. Se non vengono passati parametri, crea un oggetto Invalid.

Vedi anche isValid().

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

Crea una nuova opzione CoAP con l'name specificato e l'QString stringValue .

Vedi anche isValid().

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

Crea una nuova opzione CoAP con l'name specificato e l'intero senza segno intValue.

Vedi anche isValid().

QCoapOption::QCoapOption(const QCoapOption &other)

Crea una nuova opzione CoAP come copia di other, rendendo le due opzioni identiche.

Vedi anche isValid().

QCoapOption::QCoapOption(QCoapOption &&other)

Crea un oggetto `QCoapOption` tramite `move-construct`, facendo sì che esso punti allo stesso oggetto a cui puntava ` other `.

[noexcept] QCoapOption::~QCoapOption()

Elimina l'oggetto ` QCoapOption `.

bool QCoapOption::isValid() const

Restituisce ` true ` se l'opzione è valida.

int QCoapOption::length() const

Restituisce la lunghezza del valore dell'opzione.

QCoapOption::OptionName QCoapOption::name() const

Restituisce il nome dell'opzione.

QByteArray QCoapOption::opaqueValue() const

Restituisce il valore dell'opzione.

QString QCoapOption::stringValue() const

Restituisce il valore " QString " dell'opzione.

[noexcept] void QCoapOption::swap(QCoapOption &other)

Scambia questa opzione con " other". Questa operazione è molto veloce e non fallisce mai.

quint32 QCoapOption::uintValue() const

Restituisce il valore intero dell'opzione.

Nota: un'opzione di tipo uint può contenere al massimo 4 byte. Se il valore dell'opzione è più lungo, per calcolare il risultato vengono utilizzati solo i 4 byte meno significativi; utilizzare length() per rilevare un valore troppo lungo.

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

Restituisce ` true ` se ` QCoapOption ` e ` other ` sono diversi.

[noexcept] QCoapOption &QCoapOption::operator=(QCoapOption &&other)

Sposta ` other ` in questa opzione e restituisce un riferimento a questa ` QCoapOption`.

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

Copia other in questa opzione, rendendo le due opzioni identiche. Restituisce un riferimento a questo QCoapOption.

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

Restituisce " true " se " QCoapOption " e " other " sono uguali.

© 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.