QHttpHeaderRangeSet Class
QHttpHeaderRangeSet 表示 HTTPRange 头中的字节范围。更多内容...
| 标头: | #include <QHttpHeaderRangeSet> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
| 自: | Qt 6.12 |
| 状态: | 技术预览版 |
该类处于技术预览阶段,内容可能会有变动。
QHttpHeaderRangeSet 比较
| 类别 | 可比较类型 |
|---|---|
| 相等性 | QHttpHeaderRangeSet |
公共函数
| QHttpHeaderRangeSet() | |
| QHttpHeaderRangeSet(QSpan<const QHttpHeaderRangeSpec> r) | |
| QHttpHeaderRangeSet(std::initializer_list<QHttpHeaderRangeSpec> r) | |
| QHttpHeaderRangeSet(const QHttpHeaderRangeSet &other) | |
| QHttpHeaderRangeSet(QHttpHeaderRangeSet &&other) | |
| ~QHttpHeaderRangeSet() | |
| QSpan<const QHttpHeaderRangeSpec> | ranges() const |
| void | setRanges(QSpan<const QHttpHeaderRangeSpec> r) |
| void | swap(QHttpHeaderRangeSet &other) |
| QHttpHeaderRangeSet & | operator=(QHttpHeaderRangeSet &&other) |
| QHttpHeaderRangeSet & | operator=(const QHttpHeaderRangeSet &other) |
相关的非成员
| size_t | qHash(const QHttpHeaderRangeSet &key, size_t seed) |
| bool | operator!=(const QHttpHeaderRangeSet &lhs, const QHttpHeaderRangeSet &rhs) |
(since 6.12) QDebug | operator<<(QDebug debug, const QHttpHeaderRangeSet &ranges) |
| bool | operator==(const QHttpHeaderRangeSet &lhs, const QHttpHeaderRangeSet &rhs) |
详细说明
QHttpHeaderRangeSet 包含一序列的 `QHttpHeaderRangeSpec ` 对象,这些对象按照其在该标头中的出现顺序排列,RFC 9110 将其称为“范围集”。
这些范围按给定顺序保存,因为这是请求服务器发送它们的顺序。该类不会对它们进行解释:既不会拒绝重叠或无效的范围,也不会将它们合并。
每个范围都是一个字节范围,定义见RFC 9110 第 14.1.1 节:
- 如果指定了起始值但未指定结束值(例如,“bytes=500-”),则QHttpHeaderRangeSpec 的属性将为
start=500和end=std::nullopt。 - 如果指定了结束位置但未指定起始位置(例如,“bytes=-500”),则QHttpHeaderRangeSpec 将包含
start=std::nullopt和end=500,代表最后500字节。 - 如果两者都指定了(例如,“bytes=0-499”),则QHttpHeaderRangeSpec 将包含
start=0和end=499。
另请参阅 QHttpHeaderRangeSpec 、QHttpHeaders::rangeValues()和QHttpHeaders::setRangeValues()。
成员函数文档
QHttpHeaderRangeSet::QHttpHeaderRangeSet()
创建一个不包含任何范围的 QHttpHeaderRangeSet 对象。
QHttpHeaderRangeSet::QHttpHeaderRangeSet(QSpan<const QHttpHeaderRangeSpec> r)
构建一个 QHttpHeaderRangeSet 对象,其中包含按给定顺序排列的r 。
另请参阅 setRanges()。
QHttpHeaderRangeSet::QHttpHeaderRangeSet(std::initializer_list<QHttpHeaderRangeSpec> r)
构建一个 QHttpHeaderRangeSet 对象,用于存储r 中按给定顺序排列的范围。
这是一个重载函数。
QHttpHeaderRangeSet::QHttpHeaderRangeSet(const QHttpHeaderRangeSet &other)
创建other 的副本。
[constexpr noexcept default] QHttpHeaderRangeSet::QHttpHeaderRangeSet(QHttpHeaderRangeSet &&other)
从 `other` 移动构造该对象,该对象随后将不再具有任何范围。
[noexcept] QHttpHeaderRangeSet::~QHttpHeaderRangeSet()
销毁该对象。
[noexcept] QSpan<const QHttpHeaderRangeSpec> QHttpHeaderRangeSet::ranges() const
返回该对象所包含的范围视图。
返回的视图在该对象被修改或销毁之前一直有效。
另请参阅 setRanges()。
void QHttpHeaderRangeSet::setRanges(QSpan<const QHttpHeaderRangeSpec> r)
将该对象持有的范围设置为r 。保留r 的顺序。
另请参阅 ranges()。
[noexcept] void QHttpHeaderRangeSet::swap(QHttpHeaderRangeSet &other)
将此范围对象与other 互换。此操作速度非常快,且绝不会失败。
[noexcept] QHttpHeaderRangeSet &QHttpHeaderRangeSet::operator=(QHttpHeaderRangeSet &&other)
该操作将other 赋值给该对象,并返回该对象的引用。此时,other 中已不包含任何范围。
QHttpHeaderRangeSet &QHttpHeaderRangeSet::operator=(const QHttpHeaderRangeSet &other)
将other 的内容赋值给该对象,并返回对该对象的引用。
相关的非成员
[noexcept] size_t qHash(const QHttpHeaderRangeSet &key, size_t seed)
返回key 的哈希值,并使用seed 作为计算的种子。
[noexcept] bool operator!=(const QHttpHeaderRangeSet &lhs, const QHttpHeaderRangeSet &rhs)
返回lhs 和rhs 是否包含不同的数组范围,或者它们的数组范围顺序是否不同。
另请参阅 operator==()。
[since 6.12] QDebug operator<<(QDebug debug, const QHttpHeaderRangeSet &ranges)
将ranges 写入流debug 。
该函数于 Qt 6.12 中引入。
[noexcept] bool operator==(const QHttpHeaderRangeSet &lhs, const QHttpHeaderRangeSet &rhs)
返回lhs 和rhs 是否包含相同范围且顺序一致。
与其他序列容器类似,范围是按元素逐个比较的,因此,即使两个对象表示的是同一组字节,但如果它们持有的范围不同,或者顺序不同,则不会被视为相等。
另请参阅 operator!=()。
© 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.