Skip to content

Commit

Permalink
comment: add comments to CompoundTagVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Dec 6, 2023
1 parent bb22afd commit ffe216b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mc/nbt/CompoundTagVariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CompoundTagVariant {
[[nodiscard]] bool hold() const noexcept {
return std::holds_alternative<T>(mTagStorage);
}

// consistency with json
[[nodiscard]] bool is_array() const noexcept { return hold<ListTag>(); }
[[nodiscard]] bool is_binary() const noexcept { return hold<ByteArrayTag>() || hold<IntArrayTag>(); }
[[nodiscard]] bool is_boolean() const noexcept { return hold<ByteTag>(); }
Expand All @@ -114,9 +114,9 @@ class CompoundTagVariant {
[[nodiscard]] bool is_number_integer() const noexcept {
return hold<ByteTag>() || hold<ShortTag>() || hold<IntTag>() || hold<Int64Tag>();
}
[[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); }
[[nodiscard]] bool is_object() const noexcept { return hold<CompoundTag>(); }
[[nodiscard]] bool is_string() const noexcept { return hold<StringTag>(); }
[[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); }
[[nodiscard]] bool is_primitive() const noexcept { return is_null() || is_string() || is_number() || is_binary(); }
[[nodiscard]] bool is_structured() const noexcept { return is_array() || is_object(); }

Expand Down Expand Up @@ -183,7 +183,7 @@ class CompoundTagVariant {
}

[[nodiscard]] CompoundTagVariant& operator[](std::string const& index) {
if (hold<EndTag>()) {
if (is_null()) {
mTagStorage = CompoundTag{};
}
if (!hold<CompoundTag>()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ class CompoundTagVariant {
}

void push_back(CompoundTagVariant val) {
if (hold<EndTag>()) {
if (is_null()) {
mTagStorage = ListTag{};
}
if (!hold<ListTag>()) {
Expand Down

0 comments on commit ffe216b

Please sign in to comment.