diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-30 00:42:34 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-30 00:42:34 (GMT) |
commit | 6b0cad7557454fe39635123eb85a95302a6d06d0 (patch) | |
tree | 86ca97ba416944162df0f5fefd158651bf58c00a /src/value.cc | |
parent | 1b31c32638faa0429ffb6af0751a2199b33c52a0 (diff) |
Implemented string comparison for >, >=, <, <= operators
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 12 |
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(); } |