3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/platform/Result.h"
12enum class SnbtFormat : uint {
14 CompoundLineFeed = 1 << 0,
15 ArrayLineFeed = 1 << 1,
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,
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)
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)
41 constexpr Tag() =
default;
45 enum class Type : uchar {
61 template <std::derived_from<Tag> T>
62 T
const* as_ptr()
const {
63 return static_cast<T const*
>(
this);
65 template <std::derived_from<Tag> T>
67 return static_cast<T*
>(
this);
69 template <std::derived_from<Tag> T>
71 return *
static_cast<T const*
>(
this);
73 template <std::derived_from<Tag> T>
75 return *
static_cast<T*
>(
this);
78 [[nodiscard]]
bool operator==(
Tag const& other)
const {
return equals(other); }
80 LLNDAPI std::string toSnbt(SnbtFormat snbtFormat = SnbtFormat::PrettyFilePrint, uchar indent = 4)
const noexcept;
86 virtual ~Tag() =
default;
89 virtual void deleteChildren();
98 virtual ::std::string toString()
const = 0;
101 virtual ::Tag::Type getId()
const = 0;
104 virtual bool equals(
::Tag const& rhs)
const;
110 virtual void print(::std::string
const& prefix,
::PrintStream& out)
const;
113 virtual ::std::unique_ptr<::Tag> copy()
const = 0;
116 virtual uint64 hash()
const = 0;
122 MCAPI static ::std::string getTagName(::Tag::Type type);
124 MCAPI static ::Bedrock::Result<::std::unique_ptr<::Tag>> newTag(::Tag::Type type);
130 MCAPI static ::std::string
const& NullString();
142 MCFOLD
void $deleteChildren();
144 MCFOLD
bool $equals(
::Tag const& rhs)
const;
148 MCAPI
void $print(::std::string
const& prefix,
::PrintStream& out)
const;
154 MCAPI
static void** $vftable();
Definition IDataOutput.h:5
Definition PrintStream.h:5