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

提供NBT类型定义,包括NBT格式中的所有数据类型,以及部分辅助功能,比如静态类型与Tag映射,类型存在查询,类型列表大小,类型最大小值等 更多...

#include <NBT_Type.hpp>

struct  _TypeList
 类型列表模板 更多...

Public 类型

using TypeList
 完整的NBT类型列表定义
template<NBT_TAG Tag>
using TagToType_T = typename TagToType<Tag>::type
 从NBT_TAG获取对应的类型:编译期从NBT_TAG的enum值获取类型
template<typename T>
using BuiltinRawType_T = typename BuiltinRawType<T>::Type
 映射内建类型到方便读写的raw类型:编译期获得内建类型到可以进行二进制读写的原始类型
原始数据类型定义
using Float_Raw = uint32_t
 Float 类型的原始表示,用于在平台不支持或需要二进制读写时使用
using Double_Raw = uint64_t
 Double 类型的原始表示,用于在平台不支持或需要二进制读写时使用
NBT数据类型定义
using End = std::monostate
 结束标记类型,无数据
using Byte = int8_t
 8位有符号整数
using Short = int16_t
 16位有符号整数
using Int = int32_t
 32位有符号整数
using Long = int64_t
 64位有符号整数
using Float = std::conditional_t<(sizeof(float) == sizeof(Float_Raw)), float, Float_Raw>
 单精度浮点类型
using Double = std::conditional_t<(sizeof(double) == sizeof(Double_Raw)), double, Double_Raw>
 双精度浮点类型
using ByteArray = NBT_Array<std::vector<Byte>>
 存储 8位有符号整数的数组类型
using IntArray = NBT_Array<std::vector<Int>>
 存储32位有符号整数的数组类型
using LongArray = NBT_Array<std::vector<Long>>
 存储64位有符号整数的数组类型
using String = NBT_String<std::basic_string<uint8_t>, std::basic_string_view<uint8_t>>
 字符串类型,存储Java M-UTF-8字符串
using List = NBT_List<std::vector<NBT_Node>>
 列表类型,可顺序存储任意相同的NBT类型
using Compound = NBT_Compound<std::unordered_map<String, NBT_Node>>
 集合类型,可存储任意不同的NBT类型,通过名称映射值
部分结构的长度类型
using ArrayLength = int32_t
 数组长度类型
using StringLength = uint16_t
 字符串长度类型
using ListLength = int32_t
 列表长度类型

静态 Public 成员函数

static constexpr const char * GetTypeName (NBT_TAG tag) noexcept
 通过类型标签获取类型名称
类型判断函数(可动态)
static constexpr bool IsNumericTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应数值类型(包含所有整数和浮点数类型)
static constexpr bool IsIntegerTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应整数类型(包含所有整数类型)
static constexpr bool IsFloatingTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应浮点数类型(包含所有浮点数类型)
static constexpr bool IsArrayTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应数组类型(包含所有数组类型)
static constexpr bool IsContainerTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应容器类型(包含List、Compound和所有数组类型)
static constexpr bool IsStringTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应String类型
static constexpr bool IsListTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应List类型
static constexpr bool IsCompoundTag (NBT_TAG tag) noexcept
 判断给定的NBT_TAG是否对应Compound类型

静态 Public 属性

template<typename T>
static constexpr bool IsValidType_V = IsValidType<T, TypeList>::value
 类型存在检查:用于编译期检查一个给定类型是否为NBT中的类型
template<typename T>
static constexpr NBT_TAG TypeTag_V = (NBT_TAG)TypeTagImpl<T, TypeList>::value
 类型枚举值查询:用于在编译期,通过类型查询它在NBT_TAG中对应的enum值
static constexpr size_t TypeListSize_V = TypeListSize<TypeList>::value
 类型列表大小:获取NBT类型的个数
部分结构的长度类型的极值定义
static constexpr ArrayLength ArrayLength_Max = INT32_MAX
 数组长度类型最大值
static constexpr ArrayLength ArrayLength_Min = INT32_MIN
 数组长度类型最小值
static constexpr StringLength StringLength_Max = UINT16_MAX
 字符串长度类型最大值
static constexpr StringLength StringLength_Min = 0
 字符串长度类型最小值
static constexpr ListLength ListLength_Max = INT32_MAX
 列表长度类型最大值
static constexpr ListLength ListLength_Min = INT32_MIN
 列表长度类型最小值
内置类型的极值定义
static constexpr Byte Byte_Max = INT8_MAX
 字节类型最大值
static constexpr Byte Byte_Min = INT8_MIN
 字节类型最小值
static constexpr Short Short_Max = INT16_MAX
 短整数类型形最大值
static constexpr Short Short_Min = INT16_MIN
 短整数类型形最小值
static constexpr Int Int_Max = INT32_MAX
 整数类型最大值
static constexpr Int Int_Min = INT32_MIN
 整数类型最小值
static constexpr Long Long_Max = INT64_MAX
 长整数类型最大值
static constexpr Long Long_Min = INT64_MIN
 长整数类型最小值
类型判断模板
template<typename T>
static constexpr bool IsNumericType_V
 判断类型是否为NBT数值类型(包含所有整数和浮点数类型)
template<typename T>
static constexpr bool IsIntegerType_V
 判断类型是否为NBT整数类型(包含所有整数类型)
template<typename T>
static constexpr bool IsFloatingType_V
 判断类型是否为NBT浮点数类型(包含所有浮点数类型)
template<typename T>
static constexpr bool IsArrayType_V
 判断类型是否为NBT数组类型(包含所有数组类型)
template<typename T>
static constexpr bool IsContainerType_V
 判断类型是否为NBT容器类型(包含List、Compound和所有数组类型)
template<typename T>
static constexpr bool IsStringType_V = std::is_same_v<T, String>
 判断类型是否为NBT String类型
template<typename T>
static constexpr bool IsListType_V = std::is_same_v<T, List>
 判断类型是否为NBT List类型
template<typename T>
static constexpr bool IsCompoundType_V = std::is_same_v<T, Compound>
 判断类型是否为NBT Compound类型

详细描述

提供NBT类型定义,包括NBT格式中的所有数据类型,以及部分辅助功能,比如静态类型与Tag映射,类型存在查询,类型列表大小,类型最大小值等

成员类型定义说明

◆ BuiltinRawType_T

template<typename T>
using NBT_Type::BuiltinRawType_T = typename BuiltinRawType<T>::Type

映射内建类型到方便读写的raw类型:编译期获得内建类型到可以进行二进制读写的原始类型

模板参数
T需要映射的类型
注解
返回对应类型的原始Raw类型,如果类型不存在于类型列表中或不是内建类型,则静态断言失败,编译错误
浮点数会被映射到对应大小的无符号整数类型,其它内建类型保持不变, 部分平台对浮点数支持不完整的情况下,映射类型可能与原始类型相同,因为原始类型被声明为映射类型

◆ Double

using NBT_Type::Double = std::conditional_t<(sizeof(double) == sizeof(Double_Raw)), double, Double_Raw>

双精度浮点类型

注解
如果平台不支持,则替换为同等大小的原始数据类型

◆ Float

using NBT_Type::Float = std::conditional_t<(sizeof(float) == sizeof(Float_Raw)), float, Float_Raw>

单精度浮点类型

注解
如果平台不支持,则替换为同等大小的原始数据类型

◆ TagToType_T

template<NBT_TAG Tag>
using NBT_Type::TagToType_T = typename TagToType<Tag>::type

从NBT_TAG获取对应的类型:编译期从NBT_TAG的enum值获取类型

模板参数
Tag用于查询类型的NBT_TAG中的enum值
注解
返回NBT_TAG中的enum对应的类型,如果enum值非法,则静态断言失败,编译错误
类似于一种静态反射

◆ TypeList

初始值:
<
End,
Int,
>
int8_t Byte
8位有符号整数
定义 NBT_Type.hpp:48
std::monostate End
结束标记类型,无数据
定义 NBT_Type.hpp:47
int16_t Short
16位有符号整数
定义 NBT_Type.hpp:49
int64_t Long
64位有符号整数
定义 NBT_Type.hpp:51
NBT_String< std::basic_string< uint8_t >, std::basic_string_view< uint8_t > > String
字符串类型,存储Java M-UTF-8字符串
定义 NBT_Type.hpp:64
NBT_List< std::vector< NBT_Node > > List
列表类型,可顺序存储任意相同的NBT类型
定义 NBT_Type.hpp:68
std::conditional_t<(sizeof(float)==sizeof(Float_Raw)), float, Float_Raw > Float
单精度浮点类型
定义 NBT_Type.hpp:55
NBT_Array< std::vector< Byte > > ByteArray
存储 8位有符号整数的数组类型
定义 NBT_Type.hpp:59
NBT_Array< std::vector< Int > > IntArray
存储32位有符号整数的数组类型
定义 NBT_Type.hpp:60
NBT_Compound< std::unordered_map< String, NBT_Node > > Compound
集合类型,可存储任意不同的NBT类型,通过名称映射值
定义 NBT_Type.hpp:72
NBT_Array< std::vector< Long > > LongArray
存储64位有符号整数的数组类型
定义 NBT_Type.hpp:61
std::conditional_t<(sizeof(double)==sizeof(Double_Raw)), double, Double_Raw > Double
双精度浮点类型
定义 NBT_Type.hpp:56
int32_t Int
32位有符号整数
定义 NBT_Type.hpp:50
类型列表模板
定义 NBT_Type.hpp:79

完整的NBT类型列表定义

成员函数说明

◆ GetTypeName()

constexpr const char * NBT_Type::GetTypeName ( NBT_TAG tag)
inlinestaticconstexprnoexcept

通过类型标签获取类型名称

参数
tagNBT_TAG枚举的类型标签
返回
类型标签对应的名称的以0结尾的C风格字符串地址,如果类型标签不存在,则返回"Unknown"
注解
返回的是全局静态字符串地址,请不要直接修改,需要修改请拷贝

◆ IsArrayTag()

constexpr bool NBT_Type::IsArrayTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应数组类型(包含所有数组类型)

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应ByteArray、IntArray、LongArray中的一种,则返回true,否则返回false

◆ IsCompoundTag()

constexpr bool NBT_Type::IsCompoundTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应Compound类型

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应Compound,则返回true,否则返回false

◆ IsContainerTag()

constexpr bool NBT_Type::IsContainerTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应容器类型(包含List、Compound和所有数组类型)

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应List、Compound或任何数组类型,则返回true,否则返回false

◆ IsFloatingTag()

constexpr bool NBT_Type::IsFloatingTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应浮点数类型(包含所有浮点数类型)

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应Float、Double中的一种,则返回true,否则返回false

◆ IsIntegerTag()

constexpr bool NBT_Type::IsIntegerTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应整数类型(包含所有整数类型)

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应Byte、Short、Int、Long中的一种,则返回true,否则返回false

◆ IsListTag()

constexpr bool NBT_Type::IsListTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应List类型

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应List,则返回true,否则返回false

◆ IsNumericTag()

constexpr bool NBT_Type::IsNumericTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应数值类型(包含所有整数和浮点数类型)

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应Byte、Short、Int、Long、Float、Double中的一种,则返回true,否则返回false

◆ IsStringTag()

constexpr bool NBT_Type::IsStringTag ( NBT_TAG tag)
inlinestaticconstexprnoexcept

判断给定的NBT_TAG是否对应String类型

参数
tag需要判断的NBT_TAG枚举值
返回
如果tag对应String,则返回true,否则返回false

类成员变量说明

◆ ArrayLength_Min

ArrayLength NBT_Type::ArrayLength_Min = INT32_MIN
inlinestaticconstexpr

数组长度类型最小值

注解
实际数组长度最小值为0,这里是长度类型的最小值

◆ IsArrayType_V

template<typename T>
bool NBT_Type::IsArrayType_V
staticconstexpr
初始值:
=
std::is_same_v<T, ByteArray> ||
std::is_same_v<T, IntArray> ||
std::is_same_v<T, LongArray>

判断类型是否为NBT数组类型(包含所有数组类型)

模板参数
T需要检查的类型
注解
如果类型是ByteArray、IntArray、LongArray中的一种,则返回true,否则返回false

◆ IsCompoundType_V

template<typename T>
bool NBT_Type::IsCompoundType_V = std::is_same_v<T, Compound>
staticconstexpr

判断类型是否为NBT Compound类型

模板参数
T需要检查的类型
返回
如果类型是Compound,则返回true,否则返回false

◆ IsContainerType_V

template<typename T>
bool NBT_Type::IsContainerType_V
staticconstexpr
初始值:
=
std::is_same_v<T, ByteArray> ||
std::is_same_v<T, IntArray> ||
std::is_same_v<T, LongArray> ||
std::is_same_v<T, List> ||
std::is_same_v<T, Compound>

判断类型是否为NBT容器类型(包含List、Compound和所有数组类型)

模板参数
T需要检查的类型
注解
如果类型是ByteArray、IntArray、LongArray、List、Compound中的一种,则返回true,否则返回false

◆ IsFloatingType_V

template<typename T>
bool NBT_Type::IsFloatingType_V
staticconstexpr
初始值:
=
std::is_same_v<T, Float> ||
std::is_same_v<T, Double>

判断类型是否为NBT浮点数类型(包含所有浮点数类型)

模板参数
T需要检查的类型
注解
如果类型是Float、Double中的一种,则返回true,否则返回false

◆ IsIntegerType_V

template<typename T>
bool NBT_Type::IsIntegerType_V
staticconstexpr
初始值:
=
std::is_same_v<T, Byte> ||
std::is_same_v<T, Short> ||
std::is_same_v<T, Int> ||
std::is_same_v<T, Long>

判断类型是否为NBT整数类型(包含所有整数类型)

模板参数
T需要检查的类型
注解
如果类型是Byte、Short、Int、Long中的一种,则返回true,否则返回false

◆ IsListType_V

template<typename T>
bool NBT_Type::IsListType_V = std::is_same_v<T, List>
staticconstexpr

判断类型是否为NBT List类型

模板参数
T需要检查的类型
返回
如果类型是List,则返回true,否则返回false

◆ IsNumericType_V

template<typename T>
bool NBT_Type::IsNumericType_V
staticconstexpr
初始值:
=
std::is_same_v<T, Byte> ||
std::is_same_v<T, Short> ||
std::is_same_v<T, Int> ||
std::is_same_v<T, Long> ||
std::is_same_v<T, Float> ||
std::is_same_v<T, Double>

判断类型是否为NBT数值类型(包含所有整数和浮点数类型)

模板参数
T需要检查的类型
注解
如果类型是Byte、Short、Int、Long、Float、Double中的一种,则返回true,否则返回false

◆ IsStringType_V

template<typename T>
bool NBT_Type::IsStringType_V = std::is_same_v<T, String>
staticconstexpr

判断类型是否为NBT String类型

模板参数
T需要检查的类型
返回
如果类型是String,则返回true,否则返回false

◆ IsValidType_V

template<typename T>
bool NBT_Type::IsValidType_V = IsValidType<T, TypeList>::value
staticconstexpr

类型存在检查:用于编译期检查一个给定类型是否为NBT中的类型

模板参数
T需要检查的类型
注解
如果类型存在于NBT类型列表中,则返回true,否则返回false

◆ ListLength_Min

ListLength NBT_Type::ListLength_Min = INT32_MIN
inlinestaticconstexpr

列表长度类型最小值

注解
实际列表长度最小值为0,这里是长度类型的最小值

◆ StringLength_Min

StringLength NBT_Type::StringLength_Min = 0
inlinestaticconstexpr

字符串长度类型最小值

注解
实际字符串长度最小值为0,这里与长度类型的最小值相同

◆ TypeListSize_V

size_t NBT_Type::TypeListSize_V = TypeListSize<TypeList>::value
staticconstexpr

类型列表大小:获取NBT类型的个数

注解
它的值代表一共存在多少种NBT类型

◆ TypeTag_V

template<typename T>
NBT_TAG NBT_Type::TypeTag_V = (NBT_TAG)TypeTagImpl<T, TypeList>::value
staticconstexpr

类型枚举值查询:用于在编译期,通过类型查询它在NBT_TAG中对应的enum值

模板参数
T需要检查的类型
注解
如果类型存在于NBT类型列表中,则返回它在NBT_TAG中对应的Enum值,否则返回-1
类似于一种静态反射

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