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 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) {
49 return const_cast<CompoundTagVariant&>(std::as_const(*this).operator[](index));
50 }
51 [[nodiscard]] CompoundTagVariant const& at(std::string_view index) const { return operator[](index); }
52
53 LLNDAPI static ll::Expected<CompoundTag>
54 fromSnbt(std::string_view snbt, optional_ref<size_t> parsedLength = std::nullopt) noexcept;
55
56 LLNDAPI std::string toBinaryNbt(bool isLittleEndian = true) const;
57 LLNDAPI static ll::Expected<CompoundTag>
58 fromBinaryNbt(std::string_view dataView, bool isLittleEndian = true) noexcept;
59
60 LLNDAPI std::string toNetworkNbt() const;
61 LLNDAPI static ll::Expected<CompoundTag> fromNetworkNbt(std::string const& data) noexcept;
62
63 [[nodiscard]] size_t size() const noexcept { return mTags.size(); }
64 [[nodiscard]] bool empty() const noexcept { return mTags.empty(); }
65
66 [[nodiscard]] auto begin() noexcept;
67 [[nodiscard]] auto begin() const noexcept;
68 [[nodiscard]] auto end() noexcept;
69 [[nodiscard]] auto end() const noexcept;
70 [[nodiscard]] auto rbegin() noexcept;
71 [[nodiscard]] auto rbegin() const noexcept;
72 [[nodiscard]] auto rend() noexcept;
73 [[nodiscard]] auto rend() const noexcept;
74 [[nodiscard]] auto cbegin() const noexcept;
75 [[nodiscard]] auto cend() const noexcept;
76 [[nodiscard]] auto crbegin() const noexcept;
77 [[nodiscard]] auto crend() const noexcept;
78
79 bool erase(std::string_view name);
80 void rename(std::string_view name, std::string_view newName);
81
82public:
83 // virtual functions
84 // NOLINTBEGIN
85 virtual ~CompoundTag() /*override*/ = default;
86
87 virtual void write(::IDataOutput& dos) const /*override*/;
88
89 virtual ::Bedrock::Result<void> load(::IDataInput& dis) /*override*/;
90
91 virtual ::Tag::Type getId() const /*override*/;
92
93 virtual ::std::string toString() const /*override*/;
94
95 virtual void print(::std::string const& prefix_, ::PrintStream& out) const /*override*/;
96
97 virtual ::std::unique_ptr<::Tag> copy() const /*override*/;
98
99 virtual uint64 hash() const /*override*/;
100
101 virtual bool equals(::Tag const& obj) const /*override*/;
102 // NOLINTEND
103
104public:
105 // member functions
106 // NOLINTBEGIN
107
108 MCAPI void append(::CompoundTag const& tag);
109
110 MCAPI ::std::unique_ptr<::CompoundTag> clone() const;
111
112 MCAPI bool contains(::std::string_view name) const;
113
114 MCAPI bool contains(::std::string_view name, ::Tag::Type type) const;
115 // NOLINTEND
116
117public:
118 // constructor thunks
119 // NOLINTBEGIN
120 MCAPI void* $ctor();
121
122 MCAPI void* $ctor(::CompoundTag&& rhs);
123 // NOLINTEND
124
125public:
126 // destructor thunk
127 // NOLINTBEGIN
128 MCFOLD void $dtor();
129 // NOLINTEND
130
131public:
132 // virtual function thunks
133 // NOLINTBEGIN
134 MCAPI void $write(::IDataOutput& dos) const;
135
136 MCAPI ::Bedrock::Result<void> $load(::IDataInput& dis);
137
138 MCFOLD ::Tag::Type $getId() const;
139
140 MCAPI ::std::string $toString() const;
141
142 MCAPI void $print(::std::string const& prefix_, ::PrintStream& out) const;
143
144 MCAPI ::std::unique_ptr<::Tag> $copy() const;
145
146 MCAPI uint64 $hash() const;
147
148 MCAPI bool $equals(::Tag const& obj) const;
149
150
151 // NOLINTEND
152
153public:
154 // vftables
155 // NOLINTBEGIN
156 MCNAPI static void** $vftable();
157 // NOLINTEND
158};
159
160#include "mc/deps/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:19
Definition PrintStream.h:5
Definition ShortTag.h:9
Definition StringTag.h:15
Definition optional_ref.h:10