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