From 6b0cad7557454fe39635123eb85a95302a6d06d0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:42:34 +0200 Subject: Implemented string comparison for >, >=, <, <= operators 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(); } -- cgit v0.10.1