chenjunfu2-nbt-cpp v2.1.0
一个基于CPP20的NBT(Named Binary Tag)库
载入中...
搜索中...
未找到
NBT_Reader类 参考

这个类用于提供从NBT二进制流读取到NBT_Type::Compound对象的反序列化功能 更多...

#include <NBT_Reader.hpp>

静态 Public 成员函数

template<bool bUnwrapMixedList = true, typename InputStream, typename InfoFunc = NBT_Print>
static bool ReadNBT (InputStream &IptStream, NBT_Type::Compound &tCompound, size_t szStackDepth=512, InfoFunc funcInfo=NBT_Print{}) noexcept
 从输入流中读取NBT数据到NBT_Type::Compound对象中
template<bool bUnwrapMixedList = true, typename DataType = std::vector<uint8_t>, typename InfoFunc = NBT_Print>
static bool ReadNBT (const DataType &tDataInput, size_t szStartIdx, NBT_Type::Compound &tCompound, size_t szStackDepth=512, InfoFunc funcInfo=NBT_Print{}) noexcept
 从数据容器中读取NBT数据到NBT_Type::Compound对象中

详细描述

这个类用于提供从NBT二进制流读取到NBT_Type::Compound对象的反序列化功能

成员函数说明

◆ ReadNBT() [1/2]

template<bool bUnwrapMixedList = true, typename DataType = std::vector<uint8_t>, typename InfoFunc = NBT_Print>
bool NBT_Reader::ReadNBT ( const DataType & tDataInput,
size_t szStartIdx,
NBT_Type::Compound & tCompound,
size_t szStackDepth = 512,
InfoFunc funcInfo = NBT_Print{} )
inlinestaticnoexcept

从数据容器中读取NBT数据到NBT_Type::Compound对象中

模板参数
bUnwrapMixedList是否自动解包列表中的打包Compound
DataType数据容器类型
InfoFunc错误信息输出仿函数类型
参数
tDataInput输入数据容器
szStartIdx数据起始索引,会忽略tDataInput中长度为szStartIndex的数据
[out]tCompound用于返回读取结果的对象
szStackDepth递归最大深度深度,防止栈溢出
funcInfo错误信息处理仿函数
返回
读取成功返回true,失败返回false
注解
此函数是ReadNBT的标准库容器版本,其它信息请参考ReadNBT(InputStream)版本的详细说明

◆ ReadNBT() [2/2]

template<bool bUnwrapMixedList = true, typename InputStream, typename InfoFunc = NBT_Print>
bool NBT_Reader::ReadNBT ( InputStream & IptStream,
NBT_Type::Compound & tCompound,
size_t szStackDepth = 512,
InfoFunc funcInfo = NBT_Print{} )
inlinestaticnoexcept

从输入流中读取NBT数据到NBT_Type::Compound对象中

模板参数
bUnwrapMixedList是否自动解包列表中的打包Compound
InputStream输入流类型,必须符合DefaultInputStream类型的接口
InfoFunc错误信息输出仿函数类型
参数
IptStream输入流对象
[out]tCompound用于返回读取结果的对象
szStackDepth递归最大深度深度,防止栈溢出
funcInfo错误信息处理仿函数
返回
读取成功返回true,失败返回false
注解
错误与警告信息都输出到funcInfo,错误会导致函数结束剩下的写出任务,并进行栈回溯输出,最终返回false。警告则只会输出一次信息,然后继续执行,如果没有任何错误但是存在警告,函数仍将返回true。 函数不会清除tCompound对象的数据,所以可以通过多次调用此函数,把多个NBT数据流合并到同一个tCompound对象内, 但是如果多个流中有重复、同名的NBT键,则会产生冲突,为了保证键的唯一性,后来的值会替换原先的值,并通过funcInfo产生一个警告信息。

该类的文档由以下文件生成: