21#define MU8STR(charLiteralString) (NBT_Type::String(U8TOMU8STR(u8##charLiteralString)))
28#define MU8STRV(charLiteralString) (NBT_Type::String::View(U8TOMU8STR(u8##charLiteralString)))
30template <
bool bIsConst>
38 template <
bool bIsConst>
39 friend class NBT_Node_View;
45 struct TypeListToVariant;
47 template <
typename... Ts>
48 struct TypeListToVariant<
NBT_Type::_TypeList<Ts...>>
50 using type = std::variant<Ts...>;
55 using VariantData = TypeListToVariant<NBT_Type::TypeList>::type;
67 template <
typename T,
typename... Args>
69 explicit NBT_Node(std::in_place_type_t<T>, Args&&... args) :
data(std::in_place_type<T>, std::forward<Args>(args)...)
77 template <
typename T,
typename U>
79 explicit NBT_Node(std::in_place_type_t<T>, std::initializer_list<U> init_list) :
data(std::in_place_type<T>, init_list)
97 template <
typename T,
typename... Args>
99 T &
Set(Args&&... args)
101 return data.emplace<T>(std::forward<Args>(args)...);
113 data = std::forward<T>(value);
162 data = std::move(_NBT_Node.data);
171 return data == _Right.data;
179 return data != _Right.data;
211 return std::get<T>(
data);
221 return std::get<T>(
data);
230 return std::get_if<T>(&
data);
239 return std::get_if<T>(&
data);
248 return std::holds_alternative<T>(
data);
257#define TYPE_GET_FUNC(type)\
263const NBT_Type::type &Get##type() const\
265 return std::get<NBT_Type::type>(data);\
273NBT_Type::type &Get##type()\
275 return std::get<NBT_Type::type>(data);\
283const NBT_Type::type *GetIf##type() const noexcept\
285 return std::get_if<NBT_Type::type>(&data);\
293NBT_Type::type *GetIf##type() noexcept\
295 return std::get_if<NBT_Type::type>(&data);\
302bool Is##type() const\
304 return std::holds_alternative<NBT_Type::type>(data);\
313friend NBT_Type::type &Get##type(NBT_Node & node)\
315 return node.Get##type();\
324friend const NBT_Type::type &Get##type(const NBT_Node & node)\
326 return node.Get##type();\
335friend NBT_Type::type *GetIf##type(NBT_Node & node) noexcept\
337 return node.GetIf##type();\
346friend const NBT_Type::type *GetIf##type(const NBT_Node & node) noexcept\
348 return node.GetIf##type();\
356friend bool Is##type(const NBT_Node &node)\
358 return node.Is##type();\
388#define TYPE_SET_FUNC(type)\
394NBT_Type::type &Set##type(const NBT_Type::type &value)\
396 return Set<NBT_Type::type>(value);\
404NBT_Type::type &Set##type(NBT_Type::type &&value)\
406 return Set<NBT_Type::type>(std::move(value));\
413NBT_Type::type &Set##type(void)\
415 return Set<NBT_Type::type>();\
#define TYPE_SET_FUNC(type)
不同类型名接口生成宏
定义 NBT_Node.hpp:345
#define TYPE_GET_FUNC(type)
不同类型名获取接口生成宏
定义 NBT_Node.hpp:257
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
@ ByteArray
对应NBT_Type::ByteArray
定义 NBT_TAG.hpp:25
@ Short
对应NBT_Type::Short
定义 NBT_TAG.hpp:20
@ Long
对应NBT_Type::Long
定义 NBT_TAG.hpp:22
@ End
对应NBT_Type::End
定义 NBT_TAG.hpp:18
@ 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
NBT节点的视图,用于指向而不持有对象,类似于标准库的std::string与std::string_view的关系
定义 NBT_Node_View.hpp:24
NBT节点,用于存储NBT格式的各种数据类型
定义 NBT_Node.hpp:37
NBT_Node(const NBT_Node &_NBT_Node)
拷贝构造函数
定义 NBT_Node.hpp:126
T & Set(Args &&... args)
原位放置新对象并替换当前对象
定义 NBT_Node.hpp:99
T & Get()
通过指定类型获取当前存储的数据对象
定义 NBT_Node.hpp:219
NBT_Node(std::in_place_type_t< T >, std::initializer_list< U > init_list)
显式类型列表构造函数(通过in_place_type_t指定目标类型)
定义 NBT_Node.hpp:79
TypeListToVariant< NBT_Type::TypeList >::type VariantData
用于存储NBT数据的具体变体类型
定义 NBT_Node.hpp:55
NBT_TAG GetTag() const noexcept
获取当前存储的NBT类型的枚举值
定义 NBT_Node.hpp:198
const T * GetIf() const noexcept
通过指定类型获取当前存储的数据对象指针
定义 NBT_Node.hpp:228
bool operator!=(const NBT_Node &_Right) const noexcept
不等比较运算符
定义 NBT_Node.hpp:177
NBT_Node()
默认构造函数(构造为TAG_End类型)
定义 NBT_Node.hpp:118
NBT_Node & operator=(const NBT_Node &_NBT_Node)
拷贝赋值运算符
定义 NBT_Node.hpp:151
~NBT_Node()=default
默认析构函数
VariantData & GetData(void) noexcept
获取底层容器数据的引用
定义 NBT_Node.hpp:143
NBT_Node(NBT_Node &&_NBT_Node) noexcept
移动构造函数
定义 NBT_Node.hpp:131
VariantData data
数据对象(要求必须持有数据)
定义 NBT_Node.hpp:59
const VariantData & GetData(void) const noexcept
获取底层容器数据的常量引用
定义 NBT_Node.hpp:136
NBT_Node & operator=(NBT_Node &&_NBT_Node) noexcept
移动赋值运算符
定义 NBT_Node.hpp:160
bool TypeHolds() const
类型判断
定义 NBT_Node.hpp:246
NBT_Node(T &&value) noexcept
通用类型构造函数,可以拷贝或移动元素到对象内
定义 NBT_Node.hpp:88
std::partial_ordering operator<=>(const NBT_Node &_Right) const noexcept
三路比较运算符
定义 NBT_Node.hpp:185
const T & Get() const
通过指定类型获取当前存储的数据对象
定义 NBT_Node.hpp:209
T * GetIf() noexcept
通过指定类型获取当前存储的数据对象指针
定义 NBT_Node.hpp:237
bool operator==(const NBT_Node &_Right) const noexcept
相等比较运算符
定义 NBT_Node.hpp:169
NBT_Node(std::in_place_type_t< T >, Args &&... args)
显式类型构造函数(通过in_place_type_t指定目标类型)
定义 NBT_Node.hpp:69
void Clear(void)
清除所有数据,重置为TAG_End类型
定义 NBT_Node.hpp:191
提供NBT类型定义,包括NBT格式中的所有数据类型,以及部分辅助功能,比如静态类型与Tag映射,类型存在查询,类型列表大小,类型最大小值等
定义 NBT_Type.hpp:29
std::monostate End
结束标记类型,无数据
定义 NBT_Type.hpp:48
static constexpr bool IsValidType_V
类型存在检查:用于编译期检查一个给定类型是否为NBT中的类型
定义 NBT_Type.hpp:183