7#include <unordered_map>
17template <
typename Array>
19template <
typename String,
typename StringView>
21template <
typename List>
23template <
typename Compound>
30 NBT_Type(
void) =
delete;
32 ~NBT_Type(
void) =
delete;
47 using End = std::monostate;
78 template<
typename... Ts>
101 constexpr static inline const char *
const cstrTypeName[] =
131 return cstrTypeName[tagRaw];
170 template <
typename T,
typename List>
173 template <
typename T,
typename... Ts>
174 struct IsValidType<T,
_TypeList<Ts...>> : std::bool_constant<(std::is_same_v<T, Ts> || ...)>
181 template <
typename T>
185 template <
typename T,
typename... Ts>
189 bool bFound = ((std::is_same_v<T, Ts> ? true : (++tagIndex,
false)) || ...);
193 template <
typename T,
typename List>
196 template <
typename T,
typename... Ts>
197 struct TypeTagImpl<T, _TypeList<Ts...>>
207 template <
typename T>
211 template <
typename List>
214 template <
typename... Ts>
217 static constexpr size_t value =
sizeof...(Ts);
229 template <NBT_TAG_RAW_TYPE I,
typename List>
struct TypeAt;
234 using type = std::tuple_element_t<I, std::tuple<Ts...>>;
237 template <NBT_TAG Tag>
249 template <NBT_TAG Tag>
259 template <
typename T>
261 std::is_same_v<T, Byte> ||
262 std::is_same_v<T, Short> ||
263 std::is_same_v<T, Int> ||
264 std::is_same_v<T, Long> ||
265 std::is_same_v<T, Float> ||
266 std::is_same_v<T, Double>;
271 template <
typename T>
273 std::is_same_v<T, Byte> ||
274 std::is_same_v<T, Short> ||
275 std::is_same_v<T, Int> ||
276 std::is_same_v<T, Long>;
281 template <
typename T>
283 std::is_same_v<T, Float> ||
284 std::is_same_v<T, Double>;
289 template <
typename T>
291 std::is_same_v<T, ByteArray> ||
292 std::is_same_v<T, IntArray> ||
293 std::is_same_v<T, LongArray>;
298 template <
typename T>
300 std::is_same_v<T, ByteArray> ||
301 std::is_same_v<T, IntArray> ||
302 std::is_same_v<T, LongArray> ||
303 std::is_same_v<T, List> ||
304 std::is_same_v<T, Compound>;
309 template <
typename T>
315 template <
typename T>
321 template <
typename T>
329 struct BuiltinRawType
464 using Type = Float_Raw;
465 static_assert(
sizeof(Type) ==
sizeof(
Float),
"Type size does not match!");
471 using Type = Double_Raw;
472 static_assert(
sizeof(Type) ==
sizeof(
Double),
"Type size does not match!");
uint8_t NBT_TAG_RAW_TYPE
NBT_TAG的原始类型,用于二进制读写或判断等
定义 NBT_TAG.hpp:12
NBT_TAG
枚举NBT类型对应的类型标签值
定义 NBT_TAG.hpp:17
@ Int
对应NBT_Type::Int
定义 NBT_TAG.hpp:21
@ Float
对应NBT_Type::Float
定义 NBT_TAG.hpp:23
@ Compound
对应NBT_Type::Compound
定义 NBT_TAG.hpp:28
@ String
对应NBT_Type::String
定义 NBT_TAG.hpp:26
@ ByteArray
对应NBT_Type::ByteArray
定义 NBT_TAG.hpp:25
@ Short
对应NBT_Type::Short
定义 NBT_TAG.hpp:20
@ List
对应NBT_Type::List
定义 NBT_TAG.hpp:27
@ Long
对应NBT_Type::Long
定义 NBT_TAG.hpp:22
@ LongArray
对应NBT_Type::LongArray
定义 NBT_TAG.hpp:30
@ Byte
对应NBT_Type::Byte
定义 NBT_TAG.hpp:19
@ IntArray
对应NBT_Type::IntArray
定义 NBT_TAG.hpp:29
@ Double
对应NBT_Type::Double
定义 NBT_TAG.hpp:24
@ ENUM_END
枚举结束标记,用于计算enum元素个数,范围判断等
定义 NBT_TAG.hpp:31
继承自标准库std::vector的代理类。 无特殊成员,构造与使用方式与标准库std::vector一致。
定义 NBT_Array.hpp:18
继承自标准库std::unordered_map的代理类,用于存储和管理NBT键值对
定义 NBT_Compound.hpp:65
继承自标准库容器的代理类,用于存储和管理NBT列表
定义 NBT_List.hpp:23
NBT节点,用于存储NBT格式的各种数据类型
定义 NBT_Node.hpp:37
继承自标准库std::basic_string的代理类,用于存储、处理与转换Modified-UTF-8字符串
定义 NBT_String.hpp:114
提供NBT类型定义,包括NBT格式中的所有数据类型,以及部分辅助功能,比如静态类型与Tag映射,类型存在查询,类型列表大小,类型最大小值等
定义 NBT_Type.hpp:28
static constexpr StringLength StringLength_Min
字符串长度类型最小值
定义 NBT_Type.hpp:147
int8_t Byte
8位有符号整数
定义 NBT_Type.hpp:48
static constexpr bool IsStringType_V
判断类型是否为NBT String类型
定义 NBT_Type.hpp:310
static constexpr Int Int_Min
整数类型最小值
定义 NBT_Type.hpp:163
typename TagToType< Tag >::type TagToType_T
从NBT_TAG获取对应的类型:编译期从NBT_TAG的enum值获取类型
定义 NBT_Type.hpp:250
static constexpr bool IsNumericType_V
判断类型是否为NBT数值类型(包含所有整数和浮点数类型)
定义 NBT_Type.hpp:260
std::monostate End
结束标记类型,无数据
定义 NBT_Type.hpp:47
static constexpr Byte Byte_Min
字节类型最小值
定义 NBT_Type.hpp:157
static constexpr Short Short_Min
短整数类型形最小值
定义 NBT_Type.hpp:160
int32_t ArrayLength
数组长度类型
定义 NBT_Type.hpp:136
int16_t Short
16位有符号整数
定义 NBT_Type.hpp:49
_TypeList< End, Byte, Short, Int, Long, Float, Double, ByteArray, String, List, Compound, IntArray, LongArray > TypeList
完整的NBT类型列表定义
定义 NBT_Type.hpp:82
static constexpr bool IsContainerTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应容器类型(包含List、Compound和所有数组类型)
定义 NBT_Type.hpp:416
static constexpr size_t TypeListSize_V
类型列表大小:获取NBT类型的个数
定义 NBT_Type.hpp:223
static constexpr StringLength StringLength_Max
字符串长度类型最大值
定义 NBT_Type.hpp:146
static constexpr Byte Byte_Max
字节类型最大值
定义 NBT_Type.hpp:156
static constexpr bool IsIntegerType_V
判断类型是否为NBT整数类型(包含所有整数类型)
定义 NBT_Type.hpp:272
static constexpr bool IsCompoundType_V
判断类型是否为NBT Compound类型
定义 NBT_Type.hpp:322
static constexpr bool IsContainerType_V
判断类型是否为NBT容器类型(包含List、Compound和所有数组类型)
定义 NBT_Type.hpp:299
uint64_t Double_Raw
Double 类型的原始表示,用于在平台不支持或需要二进制读写时使用
定义 NBT_Type.hpp:39
static constexpr ArrayLength ArrayLength_Min
数组长度类型最小值
定义 NBT_Type.hpp:144
static constexpr bool IsFloatingTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应浮点数类型(包含所有浮点数类型)
定义 NBT_Type.hpp:385
static constexpr bool IsValidType_V
类型存在检查:用于编译期检查一个给定类型是否为NBT中的类型
定义 NBT_Type.hpp:182
uint32_t Float_Raw
Float 类型的原始表示,用于在平台不支持或需要二进制读写时使用
定义 NBT_Type.hpp:38
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
static constexpr bool IsStringTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应String类型
定义 NBT_Type.hpp:434
std::conditional_t<(sizeof(float)==sizeof(Float_Raw)), float, Float_Raw > Float
单精度浮点类型
定义 NBT_Type.hpp:55
static constexpr Long Long_Max
长整数类型最大值
定义 NBT_Type.hpp:165
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
typename BuiltinRawType< T >::Type BuiltinRawType_T
映射内建类型到方便读写的raw类型:编译期获得内建类型到可以进行二进制读写的原始类型
定义 NBT_Type.hpp:341
static constexpr bool IsCompoundTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应Compound类型
定义 NBT_Type.hpp:450
int32_t ListLength
列表长度类型
定义 NBT_Type.hpp:138
uint16_t StringLength
字符串长度类型
定义 NBT_Type.hpp:137
std::conditional_t<(sizeof(double)==sizeof(Double_Raw)), double, Double_Raw > Double
双精度浮点类型
定义 NBT_Type.hpp:56
static constexpr bool IsNumericTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应数值类型(包含所有整数和浮点数类型)
定义 NBT_Type.hpp:349
static constexpr bool IsArrayType_V
判断类型是否为NBT数组类型(包含所有数组类型)
定义 NBT_Type.hpp:290
static constexpr Int Int_Max
整数类型最大值
定义 NBT_Type.hpp:162
static constexpr ListLength ListLength_Max
列表长度类型最大值
定义 NBT_Type.hpp:149
static constexpr bool IsListType_V
判断类型是否为NBT List类型
定义 NBT_Type.hpp:316
static constexpr bool IsFloatingType_V
判断类型是否为NBT浮点数类型(包含所有浮点数类型)
定义 NBT_Type.hpp:282
static constexpr ArrayLength ArrayLength_Max
数组长度类型最大值
定义 NBT_Type.hpp:143
static constexpr NBT_TAG TypeTag_V
类型枚举值查询:用于在编译期,通过类型查询它在NBT_TAG中对应的enum值
定义 NBT_Type.hpp:208
static constexpr Short Short_Max
短整数类型形最大值
定义 NBT_Type.hpp:159
static constexpr bool IsArrayTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应数组类型(包含所有数组类型)
定义 NBT_Type.hpp:400
static constexpr bool IsListTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应List类型
定义 NBT_Type.hpp:442
static constexpr bool IsIntegerTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应整数类型(包含所有整数类型)
定义 NBT_Type.hpp:368
static constexpr const char * GetTypeName(NBT_TAG tag) noexcept
通过类型标签获取类型名称
定义 NBT_Type.hpp:123
static constexpr Long Long_Min
长整数类型最小值
定义 NBT_Type.hpp:166
static constexpr ListLength ListLength_Min
列表长度类型最小值
定义 NBT_Type.hpp:150
int32_t Int
32位有符号整数
定义 NBT_Type.hpp:50