summaryrefslogtreecommitdiff
path: root/value.cc
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-14 10:15:22 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-14 10:15:22 (GMT)
commitb81d72acb0e63dc0ef81cf8ef972c40719d3674e (patch)
treec918cf03c17b5d45a66ccddcc70a2b508cf1b875 /value.cc
parentf1240de7f06166b4857c419b2b617629ebf95c46 (diff)
Clifford Wolf:
Added == support for all value types git-svn-id: http://svn.clifford.at/openscad/trunk@286 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'value.cc')
-rw-r--r--value.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/value.cc b/value.cc
index 2778e58..f51b057 100644
--- a/value.cc
+++ b/value.cc
@@ -203,18 +203,27 @@ Value Value::operator == (const Value &v) const
if (type == NUMBER && v.type == NUMBER) {
return Value(num == v.num);
}
- return Value();
+ if (type == RANGE && v.type == RANGE) {
+ return Value(range_begin == v.range_begin && range_step == v.range_step && range_end == v.range_end);
+ }
+ if (type == VECTOR && v.type == VECTOR) {
+ if (vec.size() != v.vec.size())
+ return Value(false);
+ for (int i=0; i<vec.size(); i++)
+ if (!(*vec[i] == *v.vec[i]).b)
+ return Value(false);
+ return Value(true);
+ }
+ if (type == STRING && v.type == STRING) {
+ return Value(text == v.text);
+ }
+ return Value(false);
}
Value Value::operator != (const Value &v) const
{
- if (type == BOOL && v.type == BOOL) {
- return Value(b != v.b);
- }
- if (type == NUMBER && v.type == NUMBER) {
- return Value(num != v.num);
- }
- return Value();
+ Value eq = *this == v;
+ return Value(!eq.b);
}
Value Value::operator >= (const Value &v) const
contact: Jan Huwald // Impressum