7#include <unordered_map>
18template <
typename Array>
20template <
typename String,
typename StringView>
24template <
typename List>
26template <
typename Compound>
33 NBT_Type(
void) =
delete;
35 ~NBT_Type(
void) =
delete;
50 using End = std::monostate;
81 template<
typename... Ts>
104 constexpr static inline const char *
const cstrTypeName[] =
134 return cstrTypeName[tagRaw];
173 template <
typename T,
typename List>
176 template <
typename T,
typename... Ts>
177 struct IsValidType<T,
_TypeList<Ts...>> : std::bool_constant<(std::is_same_v<T, Ts> || ...)>
184 template <
typename T>
188 template <
typename T,
typename... Ts>
192 bool bFound = ((std::is_same_v<T, Ts> ? true : (++tagIndex,
false)) || ...);
196 template <
typename T,
typename List>
199 template <
typename T,
typename... Ts>
200 struct TypeTagImpl<T, _TypeList<Ts...>>
210 template <
typename T>
214 template <
typename List>
217 template <
typename... Ts>
220 static constexpr size_t value =
sizeof...(Ts);
232 template <NBT_TAG_RAW_TYPE I,
typename List>
struct TypeAt;
237 using type = std::tuple_element_t<I, std::tuple<Ts...>>;
240 template <NBT_TAG Tag>
252 template <NBT_TAG Tag>
262 template <
typename T>
264 std::is_same_v<std::remove_cvref_t<T>,
Byte> ||
265 std::is_same_v<std::remove_cvref_t<T>,
Short> ||
266 std::is_same_v<std::remove_cvref_t<T>,
Int> ||
267 std::is_same_v<std::remove_cvref_t<T>,
Long> ||
268 std::is_same_v<std::remove_cvref_t<T>,
Float> ||
269 std::is_same_v<std::remove_cvref_t<T>,
Double>;
274 template <
typename T>
276 std::is_same_v<std::remove_cvref_t<T>,
Byte> ||
277 std::is_same_v<std::remove_cvref_t<T>,
Short> ||
278 std::is_same_v<std::remove_cvref_t<T>,
Int> ||
279 std::is_same_v<std::remove_cvref_t<T>,
Long>;
284 template <
typename T>
286 std::is_same_v<std::remove_cvref_t<T>,
Float> ||
287 std::is_same_v<std::remove_cvref_t<T>,
Double>;
292 template <
typename T>
294 std::is_same_v<std::remove_cvref_t<T>,
ByteArray> ||
295 std::is_same_v<std::remove_cvref_t<T>,
IntArray> ||
296 std::is_same_v<std::remove_cvref_t<T>,
LongArray>;
301 template <
typename T>
303 std::is_same_v<std::remove_cvref_t<T>,
ByteArray> ||
304 std::is_same_v<std::remove_cvref_t<T>,
IntArray> ||
305 std::is_same_v<std::remove_cvref_t<T>,
LongArray> ||
306 std::is_same_v<std::remove_cvref_t<T>,
List> ||
307 std::is_same_v<std::remove_cvref_t<T>,
Compound>;
312 template <
typename T>
314 std::is_same_v<std::remove_cvref_t<T>,
String>;
319 template <
typename T>
321 std::is_same_v<std::remove_cvref_t<T>,
List>;
326 template <
typename T>
328 std::is_same_v<std::remove_cvref_t<T>,
Compound>;
335 struct BuiltinRawType
470 using Type = Float_Raw;
471 static_assert(
sizeof(Type) ==
sizeof(
Float),
"Type size does not match!");
477 using Type = Double_Raw;
478 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:23
继承自标准库容器的代理类,用于存储和管理NBT列表
定义 NBT_List.hpp:23
NBT节点,用于存储NBT格式的各种数据类型
定义 NBT_Node.hpp:37
继承自标准库std::basic_string的代理类,用于存储、处理与转换Modified-UTF-8字符串
定义 NBT_String.hpp:129
提供NBT类型定义,包括NBT格式中的所有数据类型,以及部分辅助功能,比如静态类型与Tag映射,类型存在查询,类型列表大小,类型最大小值等
定义 NBT_Type.hpp:31
static constexpr StringLength StringLength_Min
字符串长度类型最小值
定义 NBT_Type.hpp:150
int8_t Byte
8位有符号整数
定义 NBT_Type.hpp:51
static constexpr bool IsStringType_V
判断类型是否为NBT String类型
定义 NBT_Type.hpp:313
static constexpr Int Int_Min
整数类型最小值
定义 NBT_Type.hpp:166
typename TagToType< Tag >::type TagToType_T
从NBT_TAG获取对应的类型:编译期从NBT_TAG的enum值获取类型
定义 NBT_Type.hpp:253
static constexpr bool IsNumericType_V
判断类型是否为NBT数值类型(包含所有整数和浮点数类型)
定义 NBT_Type.hpp:263
std::monostate End
结束标记类型,无数据
定义 NBT_Type.hpp:50
static constexpr Byte Byte_Min
字节类型最小值
定义 NBT_Type.hpp:160
static constexpr Short Short_Min
短整数类型形最小值
定义 NBT_Type.hpp:163
int32_t ArrayLength
数组长度类型
定义 NBT_Type.hpp:139
int16_t Short
16位有符号整数
定义 NBT_Type.hpp:52
static constexpr bool IsContainerTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应容器类型(包含List、Compound和所有数组类型)
定义 NBT_Type.hpp:422
static constexpr size_t TypeListSize_V
类型列表大小:获取NBT类型的个数
定义 NBT_Type.hpp:226
static constexpr StringLength StringLength_Max
字符串长度类型最大值
定义 NBT_Type.hpp:149
static constexpr Byte Byte_Max
字节类型最大值
定义 NBT_Type.hpp:159
static constexpr bool IsIntegerType_V
判断类型是否为NBT整数类型(包含所有整数类型)
定义 NBT_Type.hpp:275
static constexpr bool IsCompoundType_V
判断类型是否为NBT Compound类型
定义 NBT_Type.hpp:327
static constexpr bool IsContainerType_V
判断类型是否为NBT容器类型(包含List、Compound和所有数组类型)
定义 NBT_Type.hpp:302
uint64_t Double_Raw
Double 类型的原始表示,用于在平台不支持或需要二进制读写时使用
定义 NBT_Type.hpp:42
NBT_String< MUTF8_String, MUTF8_String_View > String
字符串类型,存储Java M-UTF-8字符串
定义 NBT_Type.hpp:67
static constexpr ArrayLength ArrayLength_Min
数组长度类型最小值
定义 NBT_Type.hpp:147
static constexpr bool IsFloatingTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应浮点数类型(包含所有浮点数类型)
定义 NBT_Type.hpp:391
static constexpr bool IsValidType_V
类型存在检查:用于编译期检查一个给定类型是否为NBT中的类型
定义 NBT_Type.hpp:185
uint32_t Float_Raw
Float 类型的原始表示,用于在平台不支持或需要二进制读写时使用
定义 NBT_Type.hpp:41
int64_t Long
64位有符号整数
定义 NBT_Type.hpp:54
NBT_List< std::vector< NBT_Node > > List
列表类型,可顺序存储任意相同的NBT类型
定义 NBT_Type.hpp:71
static constexpr bool IsStringTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应String类型
定义 NBT_Type.hpp:440
std::conditional_t<(sizeof(float)==sizeof(Float_Raw)), float, Float_Raw > Float
单精度浮点类型
定义 NBT_Type.hpp:58
static constexpr Long Long_Max
长整数类型最大值
定义 NBT_Type.hpp:168
NBT_Array< std::vector< Byte > > ByteArray
存储 8位有符号整数的数组类型
定义 NBT_Type.hpp:62
_TypeList< End, Byte, Short, Int, Long, Float, Double, ByteArray, String, List, Compound, IntArray, LongArray > TypeList
完整的NBT类型列表定义
定义 NBT_Type.hpp:85
NBT_Array< std::vector< Int > > IntArray
存储32位有符号整数的数组类型
定义 NBT_Type.hpp:63
NBT_Array< std::vector< Long > > LongArray
存储64位有符号整数的数组类型
定义 NBT_Type.hpp:64
typename BuiltinRawType< T >::Type BuiltinRawType_T
映射内建类型到方便读写的raw类型:编译期获得内建类型到可以进行二进制读写的原始类型
定义 NBT_Type.hpp:347
static constexpr bool IsCompoundTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应Compound类型
定义 NBT_Type.hpp:456
int32_t ListLength
列表长度类型
定义 NBT_Type.hpp:141
uint16_t StringLength
字符串长度类型
定义 NBT_Type.hpp:140
std::conditional_t<(sizeof(double)==sizeof(Double_Raw)), double, Double_Raw > Double
双精度浮点类型
定义 NBT_Type.hpp:59
static constexpr bool IsNumericTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应数值类型(包含所有整数和浮点数类型)
定义 NBT_Type.hpp:355
static constexpr bool IsArrayType_V
判断类型是否为NBT数组类型(包含所有数组类型)
定义 NBT_Type.hpp:293
static constexpr Int Int_Max
整数类型最大值
定义 NBT_Type.hpp:165
static constexpr ListLength ListLength_Max
列表长度类型最大值
定义 NBT_Type.hpp:152
NBT_Compound< std::unordered_map< String, NBT_Node, NBT_String_Transparent_Hash, NBT_String_Transparent_Equal > > Compound
集合类型,可存储任意不同的NBT类型,通过名称映射值
定义 NBT_Type.hpp:75
static constexpr bool IsListType_V
判断类型是否为NBT List类型
定义 NBT_Type.hpp:320
static constexpr bool IsFloatingType_V
判断类型是否为NBT浮点数类型(包含所有浮点数类型)
定义 NBT_Type.hpp:285
static constexpr ArrayLength ArrayLength_Max
数组长度类型最大值
定义 NBT_Type.hpp:146
static constexpr NBT_TAG TypeTag_V
类型枚举值查询:用于在编译期,通过类型查询它在NBT_TAG中对应的enum值
定义 NBT_Type.hpp:211
static constexpr Short Short_Max
短整数类型形最大值
定义 NBT_Type.hpp:162
static constexpr bool IsArrayTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应数组类型(包含所有数组类型)
定义 NBT_Type.hpp:406
static constexpr bool IsListTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应List类型
定义 NBT_Type.hpp:448
static constexpr bool IsIntegerTag(NBT_TAG tag) noexcept
判断给定的NBT_TAG是否对应整数类型(包含所有整数类型)
定义 NBT_Type.hpp:374
static constexpr const char * GetTypeName(NBT_TAG tag) noexcept
通过类型标签获取类型名称
定义 NBT_Type.hpp:126
static constexpr Long Long_Min
长整数类型最小值
定义 NBT_Type.hpp:169
static constexpr ListLength ListLength_Min
列表长度类型最小值
定义 NBT_Type.hpp:153
int32_t Int
32位有符号整数
定义 NBT_Type.hpp:53
透明相等比较函数对象,用于 unordered 容器的异构查找
定义 NBT_String.hpp:569
透明哈希函数对象,用于 unordered 容器的异构查找
定义 NBT_String.hpp:551