LeviLamina
Loading...
Searching...
No Matches
CompoundTag.h
1#pragma once
2
3#include "ll/api/Expected.h"
4#include "mc/_HeaderOutputPredefine.h"
5
6// auto generated inclusion list
7#include "mc/deps/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 PrintStream;
16// clang-format on
17
18class CompoundTag : public ::Tag {
19public:
20 using TagMap = std::map<std::string, CompoundTagVariant, std::less<void>>;
21
22 TagMap mTags;
23
24 using iterator = TagMap::iterator;
25 using const_iterator = TagMap::const_iterator;
26 using reverse_iterator = TagMap::reverse_iterator;
27 using const_reverse_iterator = TagMap::const_reverse_iterator;
28
29 CompoundTag() = default;
30
31 CompoundTag(TagMap tags) : mTags(std::move(tags)) {}
32
33 CompoundTag(std::initializer_list<TagMap::value_type> tagPairs) : mTags(tagPairs) {}
34
35 CompoundTag(CompoundTag const&) = default;
36 CompoundTag& operator=(CompoundTag const&) = default;
37 CompoundTag(CompoundTag&&) = default;
38 CompoundTag& operator=(CompoundTag&&) = default;
39
40 [[nodiscard]] CompoundTagVariant& operator[](std::string_view index);
41 [[nodiscard]] CompoundTagVariant const& operator[](std::string_view index) const;
42
43 [[nodiscard]] CompoundTagVariant& at(std::string_view index) {
44 return const_cast<CompoundTagVariant&>(std::as_const(*this).operator[](index));
45 }
46 [[nodiscard]] CompoundTagVariant const& at(std::string_view index) const { return operator[](index); }
47
48 LLNDAPI static ll::Expected<CompoundTag>
49 fromSnbt(std::string_view snbt, optional_ref<size_t> parsedLength = std::nullopt) noexcept;
50
51 LLNDAPI std::string toBinaryNbt(bool isLittleEndian = true) const;
52 LLNDAPI static ll::Expected<CompoundTag>
53 fromBinaryNbt(std::string_view dataView, bool isLittleEndian = true) noexcept;
54
55 LLNDAPI std::string toNetworkNbt() const;
56 LLNDAPI static ll::Expected<CompoundTag> fromNetworkNbt(std::string const& data) noexcept;
57
58 [[nodiscard]] size_t size() const noexcept { return mTags.size(); }
59 [[nodiscard]] bool empty() const noexcept { return mTags.empty(); }
60
61 [[nodiscard]] auto begin() noexcept;
62 [[nodiscard]] auto begin() const noexcept;
63 [[nodiscard]] auto end() noexcept;
64 [[nodiscard]] auto end() const noexcept;
65 [[nodiscard]] auto rbegin() noexcept;
66 [[nodiscard]] auto rbegin() const noexcept;
67 [[nodiscard]] auto rend() noexcept;
68 [[nodiscard]] auto rend() const noexcept;
69 [[nodiscard]] auto cbegin() const noexcept;
70 [[nodiscard]] auto cend() const noexcept;
71 [[nodiscard]] auto crbegin() const noexcept;
72 [[nodiscard]] auto crend() const noexcept;
73
74 bool erase(std::string_view name);
75 void rename(std::string_view name, std::string_view newName);
76 [[nodiscard]] bool contains(std::string_view name) const { return mTags.contains(name); }
77 LLNDAPI bool contains(std::string_view name, Type type) const;
78
79public:
80 // virtual functions
81 // NOLINTBEGIN
82 virtual ~CompoundTag() /*override*/ = default;
83
84 virtual void write(::IDataOutput& dos) const /*override*/;
85
86 virtual ::Bedrock::Result<void> load(::IDataInput& dis) /*override*/;
87
88 virtual ::Tag::Type getId() const /*override*/;
89
90 virtual ::std::string toString() const /*override*/;
91
92 virtual void print(::std::string const& prefix_, ::PrintStream& out) const /*override*/;
93
94 virtual ::std::unique_ptr<::Tag> copy() const /*override*/;
95
96 virtual uint64 hash() const /*override*/;
97
98 virtual bool equals(::Tag const& obj) const /*override*/;
99 // NOLINTEND
100
101public:
102 // member functions
103 // NOLINTBEGIN
104 MCAPI void append(::CompoundTag const& tag);
105
106 MCAPI ::std::unique_ptr<::CompoundTag> clone() const;
107
108 MCAPI void deepCopy(::CompoundTag const& other);
109
110 MCFOLD ::Tag const* get(::std::string_view name) const;
111
112 MCFOLD ::Tag* get(::std::string_view name);
113
114 MCAPI ::std::vector<uchar> const& getByteArray(::std::string_view name) const;
115
116 MCAPI ::Bedrock::Result<void> load(::IDataInput& dis, int depth);
117
118 MCAPI ::Tag& put(::std::string name, ::Tag&& tag);
119
120 MCAPI ::Tag* put(::std::string name, ::std::unique_ptr<::Tag> tag);
121
122 MCAPI void putBoolean(::std::string name, bool val);
123
124 MCAPI uchar& putByte(::std::string name, uchar value);
125
126 MCAPI ::std::vector<uchar>& putByteArray(::std::string name, ::std::vector<uchar> mem);
127
128 MCAPI ::CompoundTag& putCompound(::std::string name, ::CompoundTag value);
129
130 MCAPI ::CompoundTag* putCompound(::std::string name, ::std::unique_ptr<::CompoundTag> value);
131
132 MCAPI float& putFloat(::std::string name, float value);
133
134 MCAPI int& putInt(::std::string name, int value);
135
136 MCAPI int64& putInt64(::std::string name, int64 value);
137
138 MCAPI short& putShort(::std::string name, short value);
139
140 MCAPI ::std::string& putString(::std::string name, ::std::string value);
141
142 MCAPI bool remove(::std::string_view name);
143
144 MCAPI void rename(::std::string_view name, ::std::string newName);
145
146 MCAPI void write(::IDataOutput& dos, int depth) const;
147 // NOLINTEND
148
149public:
150 // constructor thunks
151 // NOLINTBEGIN
152 MCAPI void* $ctor();
153
154 MCAPI void* $ctor(::CompoundTag&& rhs);
155 // NOLINTEND
156
157public:
158 // destructor thunk
159 // NOLINTBEGIN
160 MCAPI void $dtor();
161 // NOLINTEND
162
163public:
164 // virtual function thunks
165 // NOLINTBEGIN
166 MCAPI void $write(::IDataOutput& dos) const;
167
168 MCAPI ::Bedrock::Result<void> $load(::IDataInput& dis);
169
170 MCFOLD ::Tag::Type $getId() const;
171
172 MCAPI ::std::string $toString() const;
173
174 MCAPI void $print(::std::string const& prefix_, ::PrintStream& out) const;
175
176 MCAPI ::std::unique_ptr<::Tag> $copy() const;
177
178 MCAPI uint64 $hash() const;
179
180 MCAPI bool $equals(::Tag const& obj) const;
181
182
183 // NOLINTEND
184
185public:
186 // vftables
187 // NOLINTBEGIN
188 MCNAPI static void** $vftable();
189 // NOLINTEND
190};
191
192#include "mc/deps/nbt/CompoundTagVariant.h"
Definition CompoundTagVariant.h:28
static MCAPI void ** $vftable()
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition PrintStream.h:5
Definition optional_ref.h:10