From 3096364352faf35f6f7215b6f1871a72dea9d071 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 28 Jun 2011 00:35:15 -0400 Subject: [PATCH] Expressions - Implemented type-specific <, <=, >, <= for "priority". Untested. --- src/Expression.cpp | 62 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/src/Expression.cpp b/src/Expression.cpp index 527736fcc..95656f0a0 100644 --- a/src/Expression.cpp +++ b/src/Expression.cpp @@ -183,22 +183,46 @@ bool Expression::eval (Task& task) else if (arg->first == "<=") { // std::cout << "# " << left.dump () << " <= " << right.dump () << "\n"; - bool result = (left <= right); + bool result = false; + if (left._raw == "priority") + { + left.cast (Variant::v_string); + right.cast (Variant::v_string); + + if (left._string == right._string ) result = true; + else if ( right._string == "H") result = true; + else if (left._string == "L" && right._string == "M") result = true; + else if (left._string == "" ) result = true; + } + else + result = (left <= right); + left = Variant (result); left._raw_type = "bool"; -// std::cout << "# --> " << left.dump () << "\n"; value_stack.push_back (left); } else if (arg->first == ">=") { // std::cout << "# " << left.dump () << " >= " << right.dump () << "\n"; - bool result = (left >= right); + bool result = false; + if (left._raw == "priority") + { + left.cast (Variant::v_string); + right.cast (Variant::v_string); + + if (left._string == right._string ) result = true; + else if (left._string == "H" ) result = true; + else if (left._string == "M" && right._string == "L") result = true; + else if ( right._string == "" ) result = true; + } + else + result = (left >= right); + left = Variant (result); left._raw_type = "bool"; -// std::cout << "# --> " << left.dump () << "\n"; value_stack.push_back (left); } @@ -260,11 +284,22 @@ bool Expression::eval (Task& task) else if (arg->first == ">") { // std::cout << "# " << left.dump () << " > " << right.dump () << "\n"; - bool result = (left > right); + bool result = false; + if (left._raw == "priority") + { + left.cast (Variant::v_string); + right.cast (Variant::v_string); + + if (left._string == "H" && right._string != "H") result = true; + else if (left._string == "M" && right._string == "L") result = true; + else if (left._string != "" && right._string == "") result = true; + } + else + result = (left > right); + left = Variant (result); left._raw_type = "bool"; -// std::cout << "# --> " << left.dump () << "\n"; value_stack.push_back (left); } @@ -321,11 +356,22 @@ bool Expression::eval (Task& task) else if (arg->first == "<") { // std::cout << "# " << left.dump () << " < " << right.dump () << "\n"; - bool result = (left < right); + bool result = false; + if (left._raw == "priority") + { + left.cast (Variant::v_string); + right.cast (Variant::v_string); + + if (left._string != "H" && right._string == "H") result = true; + else if (left._string == "L" && right._string == "M") result = true; + else if (left._string == "" && right._string != "") result = true; + } + else + result = (left < right); + left = Variant (result); left._raw_type = "bool"; -// std::cout << "# --> " << left.dump () << "\n"; value_stack.push_back (left); }