Skip to content

Commit

Permalink
Try forward declaring
Browse files Browse the repository at this point in the history
again
  • Loading branch information
gentlegiantJGC committed Feb 15, 2024
1 parent 544614d commit 902a7b9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 61 deletions.
53 changes: 13 additions & 40 deletions src/amulet_nbt/_nbt_encoding/_binary/_cpp/write_nbt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,18 @@ template<class... Ts>
struct overloaded : Ts... { using Ts::operator()...; };


template <
typename T,
std::enable_if_t<
std::is_same_v<T, TagNode> ||
std::is_same_v<T, CByteTag> ||
std::is_same_v<T, CShortTag> ||
std::is_same_v<T, CIntTag> ||
std::is_same_v<T, CLongTag> ||
std::is_same_v<T, CFloatTag> ||
std::is_same_v<T, CDoubleTag> ||
std::is_same_v<T, CByteArrayTagPtr> ||
std::is_same_v<T, CStringTag> ||
std::is_same_v<T, CListTagPtr> ||
std::is_same_v<T, CCompoundTagPtr> ||
std::is_same_v<T, CIntArrayTagPtr> ||
std::is_same_v<T, CLongArrayTagPtr>,
bool
>
>
void write_tag_payload(BinaryWriter& writer, const T& value);
void write_tag_payload(BinaryWriter& writer, const CByteTag& value);
void write_tag_payload(BinaryWriter& writer, const CShortTag& value);
void write_tag_payload(BinaryWriter& writer, const CIntTag& value);
void write_tag_payload(BinaryWriter& writer, const CLongTag& value);
void write_tag_payload(BinaryWriter& writer, const CFloatTag& value);
void write_tag_payload(BinaryWriter& writer, const CDoubleTag& value);
void write_tag_payload(BinaryWriter& writer, const CByteArrayTagPtr& value);
void write_tag_payload(BinaryWriter& writer, const CStringTag& value);
void write_tag_payload(BinaryWriter& writer, const CListTagPtr& value);
void write_tag_payload(BinaryWriter& writer, const CCompoundTagPtr& value);
void write_tag_payload(BinaryWriter& writer, const CIntArrayTagPtr& value);
void write_tag_payload(BinaryWriter& writer, const CLongArrayTagPtr& value);


template <
Expand Down Expand Up @@ -138,26 +130,7 @@ void write_tag_payload(BinaryWriter& writer, const CListTagPtr& value){
}


template <
typename T,
std::enable_if_t<
std::is_same_v<T, TagNode> ||
std::is_same_v<T, CByteTag> ||
std::is_same_v<T, CShortTag> ||
std::is_same_v<T, CIntTag> ||
std::is_same_v<T, CLongTag> ||
std::is_same_v<T, CFloatTag> ||
std::is_same_v<T, CDoubleTag> ||
std::is_same_v<T, CByteArrayTagPtr> ||
std::is_same_v<T, CStringTag> ||
std::is_same_v<T, CListTagPtr> ||
std::is_same_v<T, CCompoundTagPtr> ||
std::is_same_v<T, CIntArrayTagPtr> ||
std::is_same_v<T, CLongArrayTagPtr>,
bool
>
>
void write_named_tag(BinaryWriter& writer, const std::string& name, const T& tag);
void write_named_tag(BinaryWriter& writer, const std::string& name, const TagNode& tag);


template <
Expand Down
48 changes: 27 additions & 21 deletions src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,33 @@ inline void write_indent(std::string& snbt, const std::string& indent, size_t in
}


template <
typename T,
typename... Args,
std::enable_if_t<
std::is_same_v<T, TagNode> ||
std::is_same_v<T, CByteTag> ||
std::is_same_v<T, CShortTag> ||
std::is_same_v<T, CIntTag> ||
std::is_same_v<T, CLongTag> ||
std::is_same_v<T, CFloatTag> ||
std::is_same_v<T, CDoubleTag> ||
std::is_same_v<T, CByteArrayTagPtr> ||
std::is_same_v<T, CStringTag> ||
std::is_same_v<T, CListTagPtr> ||
std::is_same_v<T, CCompoundTagPtr> ||
std::is_same_v<T, CIntArrayTagPtr> ||
std::is_same_v<T, CLongArrayTagPtr>,
bool
>
>
void write_snbt(std::string& snbt, const T& tag, Args... args);
void write_snbt(std::string& snbt, const TagNode& tag);
void write_snbt(std::string& snbt, const CByteTag& tag);
void write_snbt(std::string& snbt, const CShortTag& tag);
void write_snbt(std::string& snbt, const CIntTag& tag);
void write_snbt(std::string& snbt, const CLongTag& tag);
void write_snbt(std::string& snbt, const CFloatTag& tag);
void write_snbt(std::string& snbt, const CDoubleTag& tag);
void write_snbt(std::string& snbt, const CByteArrayTagPtr& tag);
void write_snbt(std::string& snbt, const CStringTag& tag);
void write_snbt(std::string& snbt, const CListTagPtr& tag);
void write_snbt(std::string& snbt, const CCompoundTagPtr& tag);
void write_snbt(std::string& snbt, const CIntArrayTagPtr& tag);
void write_snbt(std::string& snbt, const CLongArrayTagPtr& tag);

void write_snbt(std::string& snbt, const TagNode& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CByteTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CShortTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CIntTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CLongTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CFloatTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CDoubleTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CByteArrayTagPtr& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CStringTag& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CListTagPtr& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CCompoundTagPtr& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CIntArrayTagPtr& tag, const std::string& indent, size_t indent_count);
void write_snbt(std::string& snbt, const CLongArrayTagPtr& tag, const std::string& indent, size_t indent_count);


template <
Expand Down

0 comments on commit 902a7b9

Please sign in to comment.