LeviLamina
Loading...
Searching...
No Matches
CompoundTag.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "ll/api/Expected.h"
5
6// auto generated inclusion list
7#include "mc/nbt/Tag.h"
8#include "mc/platform/Result.h"
9
10// auto generated forward declare list
11// clang-format off
13class IDataInput;
14class IDataOutput;
15class Int64Tag;
16class IntTag;
17class ListTag;
18class PrintStream;
19class ShortTag;
20class StringTag;
21// clang-format on
22
23class CompoundTag : public ::Tag {
24public:
25 using TagMap = std::map<std::string, CompoundTagVariant, std::less<void>>;
26
27 TagMap mTags;
28
29 using iterator = TagMap::iterator;
30 using const_iterator = TagMap::const_iterator;
31 using reverse_iterator = TagMap::reverse_iterator;
32 using const_reverse_iterator = TagMap::const_reverse_iterator;
33
34 CompoundTag() = default;
35
36 CompoundTag(TagMap tags) : mTags(std::move(tags)) {}
37
38 CompoundTag(std::initializer_list<TagMap::value_type> tagPairs) : mTags(tagPairs) {}
39
40 CompoundTag(CompoundTag const&) = default;
41 CompoundTag& operator=(CompoundTag const&) = default;
42 CompoundTag(CompoundTag&&) = default;
43 CompoundTag& operator=(CompoundTag&&) = default;
44
45 [[nodiscard]] CompoundTagVariant& operator[](std::string_view index);
46 [[nodiscard]] CompoundTagVariant const& operator[](std::string_view index) const;
47
48 [[nodiscard]] CompoundTagVariant& at(std::string_view index) { return operator[](index); }
49 [[nodiscard]] CompoundTagVariant const& at(std::string_view index) const { return operator[](index); }
50
51 LLNDAPI static ll::Expected<CompoundTag>
52 fromSnbt(std::string_view snbt, optional_ref<size_t> parsedLength = std::nullopt) noexcept;
53
54 LLNDAPI std::string toBinaryNbt(bool isLittleEndian = true) const;
55 LLNDAPI static ll::Expected<CompoundTag>
56 fromBinaryNbt(std::string_view dataView, bool isLittleEndian = true) noexcept;
57
58 LLNDAPI std::string toNetworkNbt() const;
59 LLNDAPI static ll::Expected<CompoundTag> fromNetworkNbt(std::string const& data) noexcept;
60
61 [[nodiscard]] size_t size() const noexcept { return mTags.size(); }
62 [[nodiscard]] bool empty() const noexcept { return mTags.empty(); }
63
64 [[nodiscard]] auto begin() noexcept;
65 [[nodiscard]] auto begin() const noexcept;
66 [[nodiscard]] auto end() noexcept;
67 [[nodiscard]] auto end() const noexcept;
68 [[nodiscard]] auto rbegin() noexcept;
69 [[nodiscard]] auto rbegin() const noexcept;
70 [[nodiscard]] auto rend() noexcept;
71 [[nodiscard]] auto rend() const noexcept;
72 [[nodiscard]] auto cbegin() const noexcept;
73 [[nodiscard]] auto cend() const noexcept;
74 [[nodiscard]] auto crbegin() const noexcept;
75 [[nodiscard]] auto crend() const noexcept;
76
77 bool erase(std::string_view name);
78 void rename(std::string_view name, std::string_view newName);
79
80public:
81 // virtual functions
82 // NOLINTBEGIN
83 virtual ~CompoundTag() /*override*/ = default;
84
85 virtual void write(::IDataOutput& dos) const /*override*/;
86
87 virtual ::Bedrock::Result<void> load(::IDataInput& dis) /*override*/;
88
89 virtual ::Tag::Type getId() const /*override*/;
90
91 virtual ::std::string toString() const /*override*/;
92
93 virtual void print(::std::string const& prefix, ::PrintStream& out) const /*override*/;
94
95 virtual ::std::unique_ptr<::Tag> copy() const /*override*/;
96
97 virtual uint64 hash() const /*override*/;
98
99 virtual bool equals(::Tag const& obj) const /*override*/;
100 // NOLINTEND
101
102public:
103 // member functions
104 // NOLINTBEGIN
105
106 MCAPI void append(::CompoundTag const& tag);
107
108 MCAPI ::std::unique_ptr<::CompoundTag> clone() const;
109
110 MCAPI bool contains(::std::string_view name) const;
111
112 MCAPI bool contains(::std::string_view name, ::Tag::Type type) const;
113 // NOLINTEND
114
115public:
116 // constructor thunks
117 // NOLINTBEGIN
118 MCAPI void* $ctor();
119
120 MCAPI void* $ctor(::CompoundTag&& rhs);
121 // NOLINTEND
122
123public:
124 // destructor thunk
125 // NOLINTBEGIN
126 MCFOLD void $dtor();
127 // NOLINTEND
128
129public:
130 // virtual function thunks
131 // NOLINTBEGIN
132 MCAPI void $write(::IDataOutput& dos) const;
133
134 MCAPI ::Bedrock::Result<void> $load(::IDataInput& dis);
135
136 MCFOLD ::Tag::Type $getId() const;
137
138 MCAPI ::std::string $toString() const;
139
140 MCAPI void $print(::std::string const& prefix, ::PrintStream& out) const;
141
142 MCAPI ::std::unique_ptr<::Tag> $copy() const;
143
144 MCAPI uint64 $hash() const;
145
146 MCAPI bool $equals(::Tag const& obj) const;
147
148
149 // NOLINTEND
150
151public:
152 // vftables
153 // NOLINTBEGIN
154 MCNAPI static void** $vftable();
155 // NOLINTEND
156};
157
158#include "mc/nbt/CompoundTagVariant.h"
Definition CompoundTagVariant.h:28
static MCAPI void ** $vftable()
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition Int64Tag.h:9
Definition IntTag.h:15
Definition ListTag.h:20
Definition PrintStream.h:5
Definition ShortTag.h:9
Definition StringTag.h:15
Definition optional_ref.h:10