LeviLamina
Loading...
Searching...
No Matches
Tag.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/platform/Result.h"
7
8class IDataOutput;
9class IDataInput;
10class PrintStream;
11
12enum class SnbtFormat : uint {
13 Minimize = 0,
14 CompoundLineFeed = 1 << 0,
15 ArrayLineFeed = 1 << 1,
16 Colored = 1 << 2,
17 Console = 1 << 3,
18 ForceAscii = 1 << 4,
19 ForceQuote = 1 << 5,
20 CommentMarks = 1 << 6,
21 Jsonify = ForceQuote | CommentMarks,
22 PartialLineFeed = CompoundLineFeed,
23 AlwaysLineFeed = CompoundLineFeed | ArrayLineFeed,
24 PrettyFilePrint = PartialLineFeed,
25 PrettyChatPrint = PrettyFilePrint | Colored,
26 PrettyConsolePrint = PrettyFilePrint | Colored | Console,
27};
28[[nodiscard]] constexpr SnbtFormat operator|(const SnbtFormat l, const SnbtFormat r) noexcept {
29 return static_cast<SnbtFormat>(
30 static_cast<std::underlying_type_t<SnbtFormat>>(l) | static_cast<std::underlying_type_t<SnbtFormat>>(r)
31 );
32}
33[[nodiscard]] constexpr SnbtFormat operator&(const SnbtFormat l, const SnbtFormat r) noexcept {
34 return static_cast<SnbtFormat>(
35 static_cast<std::underlying_type_t<SnbtFormat>>(l) & static_cast<std::underlying_type_t<SnbtFormat>>(r)
36 );
37}
38
39class Tag {
40protected:
41 constexpr Tag() = default;
42
43public:
44 // Tag inner types define
45 enum class Type : uchar {
46 End = 0x0,
47 Byte = 0x1,
48 Short = 0x2,
49 Int = 0x3,
50 Int64 = 0x4,
51 Float = 0x5,
52 Double = 0x6,
53 ByteArray = 0x7,
54 String = 0x8,
55 List = 0x9,
56 Compound = 0xA,
57 IntArray = 0xB,
58 };
59 using enum Type;
60
61 template <std::derived_from<Tag> T>
62 T const* as_ptr() const {
63 return static_cast<T const*>(this);
64 }
65 template <std::derived_from<Tag> T>
66 T* as_ptr() {
67 return static_cast<T*>(this);
68 }
69 template <std::derived_from<Tag> T>
70 T const& as() const {
71 return *static_cast<T const*>(this);
72 }
73 template <std::derived_from<Tag> T>
74 T& as() {
75 return *static_cast<T*>(this);
76 }
77
78 [[nodiscard]] bool operator==(Tag const& other) const { return equals(other); }
79
80 LLNDAPI std::string toSnbt(SnbtFormat snbtFormat = SnbtFormat::PrettyFilePrint, uchar indent = 4) const noexcept;
81
82public:
83 // virtual functions
84 // NOLINTBEGIN
85 // vIndex: 0
86 virtual ~Tag() = default;
87
88 // vIndex: 1
89 virtual void deleteChildren();
90
91 // vIndex: 2
92 virtual void write(::IDataOutput&) const = 0;
93
94 // vIndex: 3
95 virtual ::Bedrock::Result<void> load(::IDataInput&) = 0;
96
97 // vIndex: 4
98 virtual ::std::string toString() const = 0;
99
100 // vIndex: 5
101 virtual ::Tag::Type getId() const = 0;
102
103 // vIndex: 6
104 virtual bool equals(::Tag const& rhs) const;
105
106 // vIndex: 8
107 virtual void print(::PrintStream& out) const;
108
109 // vIndex: 7
110 virtual void print(::std::string const& prefix, ::PrintStream& out) const;
111
112 // vIndex: 9
113 virtual ::std::unique_ptr<::Tag> copy() const = 0;
114
115 // vIndex: 10
116 virtual uint64 hash() const = 0;
117 // NOLINTEND
118
119public:
120 // static functions
121 // NOLINTBEGIN
122 MCAPI static ::std::string getTagName(::Tag::Type type);
123
124 MCAPI static ::Bedrock::Result<::std::unique_ptr<::Tag>> newTag(::Tag::Type type);
125 // NOLINTEND
126
127public:
128 // static variables
129 // NOLINTBEGIN
130 MCAPI static ::std::string const& NullString();
131 // NOLINTEND
132
133public:
134 // destructor thunk
135 // NOLINTBEGIN
136 MCFOLD void $dtor();
137 // NOLINTEND
138
139public:
140 // virtual function thunks
141 // NOLINTBEGIN
142 MCFOLD void $deleteChildren();
143
144 MCFOLD bool $equals(::Tag const& rhs) const;
145
146 MCAPI void $print(::PrintStream& out) const;
147
148 MCAPI void $print(::std::string const& prefix, ::PrintStream& out) const;
149 // NOLINTEND
150
151public:
152 // vftables
153 // NOLINTBEGIN
154 MCAPI static void** $vftable();
155 // NOLINTEND
156};
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition PrintStream.h:5
Definition Tag.h:39