Commit 28e306bc authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse

Add Value::operator==

parent 4b49e534
......@@ -72,6 +72,8 @@ public:
explicit Value();
// operator assignement
Value operator=(const Value &value);
// Equality operator
bool operator==(const Value &other) const;
/// Return the type of the value
Type type() const;
......
......@@ -144,6 +144,25 @@ Value Value::operator=(const Value &value) {
return *this;
}
bool Value::operator==(const Value &other) const {
if (type_ != other.type_) return false;
switch (type_) {
case Value::BOOL: return boolValue() == other.boolValue();
case Value::UNSIGNED: return unsignedValue() == other.unsignedValue();
case Value::INT: return intValue() == other.intValue();
case Value::DOUBLE: return doubleValue() == other.doubleValue();
case Value::FLOAT: return floatValue() == other.floatValue();
case Value::STRING: return stringValue() == other.stringValue();
case Value::VECTOR: return vectorValue() == other.vectorValue();
case Value::MATRIX: return matrixXdValue() == other.matrixXdValue();
case Value::MATRIX4D: return matrix4dValue() == other.matrix4dValue();
case Value::VALUES: return constValuesValue() == other.constValuesValue();
case Value::NONE: break;
default: break;
}
return false;
}
const EitherType Value::value() const { return EitherType(*this); }
Value::Type Value::type() const { return type_; }
......
......@@ -371,4 +371,5 @@ BOOST_AUTO_TEST_CASE(value_values) {
const Values& vs = vvalues.constValuesValue();
BOOST_CHECK_EQUAL(vs.size(), values.size());
BOOST_CHECK(vs == values);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment