summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tag.h6
-rw-r--r--include/tag_compound.h2
-rw-r--r--include/tag_primitive.h8
-rw-r--r--include/tag_string.h2
-rw-r--r--test/nbttest.cpp2
5 files changed, 19 insertions, 1 deletions
diff --git a/include/tag.h b/include/tag.h
index 56d3594474..2bca595f9d 100644
--- a/include/tag.h
+++ b/include/tag.h
@@ -51,6 +51,12 @@ public:
///Returns the type of the tag
virtual tag_type get_type() const noexcept = 0;
+
+ friend bool operator==(const tag& lhs, const tag& rhs);
+ friend bool operator!=(const tag& lhs, const tag& rhs);
+
+private:
+ virtual bool equals(const tag& rhs) const = 0;
};
}
diff --git a/include/tag_compound.h b/include/tag_compound.h
index 8fdc2f6617..51f0cd2709 100644
--- a/include/tag_compound.h
+++ b/include/tag_compound.h
@@ -92,6 +92,8 @@ public:
private:
+
+ bool equals(const tag& rhs) const override;
};
}
diff --git a/include/tag_primitive.h b/include/tag_primitive.h
index 5704da4430..4c210ff0a8 100644
--- a/include/tag_primitive.h
+++ b/include/tag_primitive.h
@@ -55,6 +55,8 @@ public:
private:
T value;
+
+ bool equals(const tag& rhs) const override;
};
//Typedefs that should be used instead of the template tag_primitive.
@@ -107,6 +109,12 @@ tag_type tag_primitive<T>::get_type() const noexcept
return type;
}
+template<class T>
+bool tag_primitive<T>::equals(const tag& rhs) const
+{
+ return value == static_cast<const tag_primitive<T>&>(rhs).value;
+}
+
}
#endif // TAG_PRIMITIVE_H_INCLUDED
diff --git a/include/tag_string.h b/include/tag_string.h
index 28d1b77085..1daa0c2c6b 100644
--- a/include/tag_string.h
+++ b/include/tag_string.h
@@ -52,6 +52,8 @@ public:
private:
std::string value;
+
+ bool equals(const tag& rhs) const override;
};
}
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
index b77c9b85bf..a596259050 100644
--- a/test/nbttest.cpp
+++ b/test/nbttest.cpp
@@ -112,7 +112,7 @@ void test_tag_compound()
{"baz", -2.0},
{"quux", tag_compound{{"Hello", "World"}, {"zero", 0}}}
}*/;
- //ASSERT(comp == comp2);
+ ASSERT(comp == comp2);
ASSERT(comp != (const tag_compound&)comp2["quux"]);
ASSERT(comp != comp2["quux"]);
}