本页内容

QCborError Struct

QCborError 类用于存储在解析或验证 CBOR 流时发现的错误情况。更多内容...

头文件: #include <QtCborCommon>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

注意:该结构体中的所有函数均为可重入函数。

公共类型

enum Code { NoError, UnknownError, AdvancePastEnd, InputOutputError, GarbageAtEnd, …, UnsupportedType }

公共函数

QString toString() const
operator QCborError::Code() const

详细说明

另请参阅 QCborStreamReader 、QCborValue 、QCborParserError 、解析和显示 CBOR 数据、序列化转换器以及保存和加载游戏。

成员类型文档

enum QCborError::Code

该枚举包含可能的错误状态代码。

常量值描述
QCborError::NoError0未检测到错误。
QCborError::UnknownError1发生了一个未知错误,且没有更多详细信息。
QCborError::AdvancePastEnd3QCborStreamReader::next已调用(),但当前上下文中已无更多元素。
QCborError::InputOutputError4QIODevice 发生 I/O 错误。
QCborError::GarbageAtEnd256在最后一个元素之后,在输入流中发现了数据。
QCborError::EndOfFile257在处理一个元素时意外到达了输入流的末尾。
QCborError::UnexpectedBreak258CBOR 流中包含了一个不允许的断点(数据已损坏,且该错误无法恢复)。
QCborError::UnknownType259CBOR 流中包含一个未知/无法解析的类型(数据已损坏,且该错误无法恢复)。
QCborError::IllegalType260CBOR 流中包含一个已知类型,但该类型出现在不允许的位置(数据已损坏,且该错误无法恢复)。
QCborError::IllegalNumber261CBOR 流似乎编码了一个大于 64 位的数字(数据已损坏,且该错误无法恢复)。
QCborError::IllegalSimpleType262CBOR 流中包含一个编码不正确的简单类型(数据已损坏,且该错误无法恢复)。
QCborError::InvalidUtf8String516CBOR 流中包含一个无法正确解码为 UTF-8 的文本字符串(数据已损坏且错误无法恢复)。
QCborError::DataTooLarge1024CBOR 字符串、映射或数组过大,无法由 Qt 解析(内部限制,但该错误无法恢复)。
QCborError::NestingTooDeep1025在处理输入时遇到过多级别的数组或映射(内部限制,但该错误无法恢复)。
QCborError::UnsupportedType1026CBOR 流中包含一种实现不支持的已知类型(内部限制,但该错误无法恢复)。

成员函数文档

QString QCborError::toString() const

返回一个与该QCborError 对象中的错误代码相对应的文本字符串。

注意:该字符串不会被翻译。对于其界面允许用户解析 CBOR 流的应用程序,需要自行提供已翻译的字符串。

另请参阅 QCborError::Code 。

QCborError::operator QCborError::Code() const

返回此QCborError 对象所存储的错误代码。

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