diff options
| -rw-r--r-- | include/tag_compound.h | 3 | ||||
| -rw-r--r-- | include/tag_primitive.h | 17 | ||||
| -rw-r--r-- | include/tag_string.h | 3 | ||||
| -rw-r--r-- | src/tag_compound.cpp | 12 | ||||
| -rw-r--r-- | src/tag_string.cpp | 12 |
5 files changed, 44 insertions, 3 deletions
diff --git a/include/tag_compound.h b/include/tag_compound.h index 435fdbdff6..fb2d27123a 100644 --- a/include/tag_compound.h +++ b/include/tag_compound.h @@ -115,6 +115,9 @@ private: std::map<std::string, value> tags; bool equals(const tag& rhs) const override; + + friend bool operator==(const tag_compound& lhs, const tag_compound& rhs); + friend bool operator!=(const tag_compound& lhs, const tag_compound& rhs); }; template<class T, class... Args> diff --git a/include/tag_primitive.h b/include/tag_primitive.h index e35d462c48..73c7b1e727 100644 --- a/include/tag_primitive.h +++ b/include/tag_primitive.h @@ -61,6 +61,9 @@ private: bool equals(const tag& rhs) const override; }; +template<class T> bool operator==(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs); +template<class T> bool operator!=(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs); + //Typedefs that should be used instead of the template tag_primitive. typedef tag_primitive<int8_t> tag_byte; typedef tag_primitive<int16_t> tag_short; @@ -120,7 +123,19 @@ std::unique_ptr<tag> tag_primitive<T>::move_clone() && template<class T> bool tag_primitive<T>::equals(const tag& rhs) const { - return value == static_cast<const tag_primitive<T>&>(rhs).value; + return *this == static_cast<const tag_primitive<T>&>(rhs); +} + +template<class T> +bool operator==(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs) +{ + return lhs.get() == rhs.get(); +} + +template<class T> +bool operator!=(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs) +{ + return !(lhs == rhs); } } diff --git a/include/tag_string.h b/include/tag_string.h index 456fa8ad08..f1b622eee9 100644 --- a/include/tag_string.h +++ b/include/tag_string.h @@ -55,6 +55,9 @@ private: bool equals(const tag& rhs) const override; }; +bool operator==(const tag_string& lhs, const tag_string& rhs); +bool operator!=(const tag_string& lhs, const tag_string& rhs); + } #endif // TAG_STRING_H_INCLUDED diff --git a/src/tag_compound.cpp b/src/tag_compound.cpp index 20cb021df8..53fd9df8ac 100644 --- a/src/tag_compound.cpp +++ b/src/tag_compound.cpp @@ -91,7 +91,17 @@ std::unique_ptr<tag> tag_compound::move_clone() && bool tag_compound::equals(const tag& rhs) const { - return tags == static_cast<const tag_compound&>(rhs).tags; + return *this == static_cast<const tag_compound&>(rhs); +} + +bool operator==(const tag_compound& lhs, const tag_compound& rhs) +{ + return lhs.tags == rhs.tags; +} + +bool operator!=(const tag_compound& lhs, const tag_compound& rhs) +{ + return !(lhs == rhs); } } diff --git a/src/tag_string.cpp b/src/tag_string.cpp index 6322d4a42c..b3ef075cd3 100644 --- a/src/tag_string.cpp +++ b/src/tag_string.cpp @@ -79,7 +79,17 @@ std::unique_ptr<tag> tag_string::move_clone() && bool tag_string::equals(const tag& rhs) const { - return value == static_cast<const tag_string&>(rhs).value; + return *this == static_cast<const tag_string&>(rhs); +} + +bool operator==(const tag_string& lhs, const tag_string& rhs) +{ + return lhs.get() == rhs.get(); +} + +bool operator!=(const tag_string& lhs, const tag_string& rhs) +{ + return !(lhs == rhs); } } |
