QCoapResource Class
QCoapResource 类保存有关已发现资源的信息。更多
头文件: | #include <QCoapResource> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Coap) target_link_libraries(mytarget PRIVATE Qt6::Coap) |
qmake: | QT += coap |
注意:该类中的所有函数都是可重入的。
公共函数
QCoapResource() | |
QCoapResource(const QCoapResource &other) | |
~QCoapResource() | |
uint | contentFormat() const |
QHostAddress | host() const |
QString | interface() const |
int | maximumSize() const |
bool | observable() const |
QString | path() const |
QString | resourceType() const |
void | setContentFormat(uint contentFormat) |
void | setHost(const QHostAddress &host) |
void | setInterface(const QString &interface) |
void | setMaximumSize(int maximumSize) |
void | setObservable(bool observable) |
void | setPath(const QString &path) |
void | setResourceType(const QString &resourceType) |
void | setTitle(const QString &title) |
void | swap(QCoapResource &other) |
QString | title() const |
QCoapResource & | operator=(const QCoapResource &other) |
详细说明
QCoapRequest 包含资源的路径和标题等数据以及其他辅助信息。
另请参阅 QCoapResourceDiscoveryReply 。
成员函数文档
QCoapResource::QCoapResource()
构造一个新的 QCoapResource。
QCoapResource::QCoapResource(const QCoapResource &other)
构建一个新的 CoAP 资源,作为other 的副本,使两个资源完全相同。
[noexcept]
QCoapResource::~QCoapResource()
摧毁QCoapResource 。
uint QCoapResource::contentFormat() const
返回资源的内容格式代码。
Content-Format 代码与 "ct "属性相对应,提供了有关该资源返回的内容格式的提示。RFC 7252 对其进行了规定。
另请参见 setContentFormat()。
QHostAddress QCoapResource::host() const
返回资源的主机。
另请参见 setHost()。
QString QCoapResource::interface() const
返回资源的接口描述。
接口描述 "if "属性是一个不透明字符串,用于提供一个名称或 URI,指示用于与目标资源交互的特定接口定义。RFC 6690 对其进行了规定。
另请参见 setInterface()。
int QCoapResource::maximumSize() const
返回资源的最大大小。
最大尺寸估计属性 "sz "给出了对目标 URI 执行 GET 所返回资源表示的最大尺寸。它在RFC 6690 中作了规定。
另请参见 setMaximumSize()。
bool QCoapResource::observable() const
如果资源是可观测的,则返回true
另请参见 setObservable()。
QString QCoapResource::path() const
返回资源的路径。
另请参见 setPath()。
QString QCoapResource::resourceType() const
返回资源的类型。
另请参见 setResourceType()。
void QCoapResource::setContentFormat(uint contentFormat)
将资源的内容格式设置为contentFormat 。内容格式可以是CoAP 内容格式注册表中定义的内容格式之一。
注: CoAP 支持 XML、JSON 等常见内容格式,但这些格式都是基于文本的,因此有效载荷和处理量都很大。建议与 CoAP 一起使用的内容格式之一是 CBOR,它就是为在这种情况下使用而设计的。
另请参阅 contentFormat(),QCborStreamWriter, 和QCborStreamReader 。
void QCoapResource::setHost(const QHostAddress &host)
将资源的主机设置为host 。
另请参阅 host() 。
void QCoapResource::setInterface(const QString &interface)
将资源的接口设置为interface 。
另请参阅 interface() 。
void QCoapResource::setMaximumSize(int maximumSize)
将资源的最大大小设置为maximumSize 。
另请参阅 maximumSize() 。
void QCoapResource::setObservable(bool observable)
如果observable 参数为true
,则使资源可被观测。
另请参阅 observable() 。
void QCoapResource::setPath(const QString &path)
将资源路径设置为path 。
另请参阅 path() 。
void QCoapResource::setResourceType(const QString &resourceType)
将资源类型设置为resourceType 。
另请参阅 resourceType() 。
void QCoapResource::setTitle(const QString &title)
将资源的标题设置为title 。
另请参阅 title() 。
[noexcept]
void QCoapResource::swap(QCoapResource &other)
将此资源与other 互换。该操作速度非常快,从未出现过故障。
QString QCoapResource::title() const
返回资源的标题。
另请参阅 setTitle()。
QCoapResource &QCoapResource::operator=(const QCoapResource &other)
将other 复制到此资源中,使两个资源完全相同。返回对QCoapResource 的引用。
© 2025 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.