summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-30 00:42:34 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-30 00:42:34 (GMT)
commit6b0cad7557454fe39635123eb85a95302a6d06d0 (patch)
tree86ca97ba416944162df0f5fefd158651bf58c00a /src/value.cc
parent1b31c32638faa0429ffb6af0751a2199b33c52a0 (diff)
Implemented string comparison for >, >=, <, <= operators
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index 53fd6dc..685bf81 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -193,6 +193,9 @@ Value Value::operator < (const Value &v) const
if (this->type == NUMBER && v.type == NUMBER) {
return Value(this->num < v.num);
}
+ else if (this->type == STRING && v.type == STRING) {
+ return Value(this->text < v.text);
+ }
return Value();
}
@@ -201,6 +204,9 @@ Value Value::operator <= (const Value &v) const
if (this->type == NUMBER && v.type == NUMBER) {
return Value(this->num <= v.num);
}
+ else if (this->type == STRING && v.type == STRING) {
+ return Value(this->text <= v.text);
+ }
return Value();
}
@@ -240,6 +246,9 @@ Value Value::operator >= (const Value &v) const
if (this->type == NUMBER && v.type == NUMBER) {
return Value(this->num >= v.num);
}
+ else if (this->type == STRING && v.type == STRING) {
+ return Value(this->text >= v.text);
+ }
return Value();
}
@@ -248,6 +257,9 @@ Value Value::operator > (const Value &v) const
if (this->type == NUMBER && v.type == NUMBER) {
return Value(this->num > v.num);
}
+ else if (this->type == STRING && v.type == STRING) {
+ return Value(this->text > v.text);
+ }
return Value();
}
contact: Jan Huwald // Impressum