Variant
- ::operator_match and ::operator_nomatch now take a 'const Task&' argument to use for description/annotation matching. - Updated unit tests.
This commit is contained in:
@@ -287,8 +287,8 @@ void Eval::evaluatePostfixStack (
|
||||
else if (token->first == "^") left ^= right;
|
||||
else if (token->first == "%") left %= right;
|
||||
else if (token->first == "xor") left = left.operator_xor (right);
|
||||
else if (token->first == "~") left = left.operator_match (right);
|
||||
else if (token->first == "!~") left = left.operator_nomatch (right);
|
||||
else if (token->first == "~") left = left.operator_match (right, contextTask);
|
||||
else if (token->first == "!~") left = left.operator_nomatch (right, contextTask);
|
||||
else if (token->first == "_hastag_") left = left.operator_hastag (right, contextTask);
|
||||
else if (token->first == "_notag_") left = left.operator_notag (right, contextTask);
|
||||
else
|
||||
|
||||
@@ -766,8 +766,9 @@ bool Variant::operator!= (const Variant& other) const
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Variant::operator_match (const Variant& other) const
|
||||
bool Variant::operator_match (const Variant& other, const Task& task) const
|
||||
{
|
||||
// Simple matching case first.
|
||||
Variant left (*this);
|
||||
Variant right (other);
|
||||
|
||||
@@ -775,13 +776,29 @@ bool Variant::operator_match (const Variant& other) const
|
||||
right.cast (type_string);
|
||||
|
||||
RX r (right._string, searchCaseSensitive);
|
||||
return r.match (left._string);
|
||||
if (r.match (left._string))
|
||||
return true;
|
||||
|
||||
// If the above did not match, and the left source is "description", then
|
||||
// in the annotations.
|
||||
if (left.source () == "description")
|
||||
{
|
||||
std::map <std::string, std::string> annotations;
|
||||
task.getAnnotations (annotations);
|
||||
|
||||
std::map <std::string, std::string>::iterator a;
|
||||
for (a = annotations.begin (); a != annotations.end (); ++a)
|
||||
if (r.match (a->second))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Variant::operator_nomatch (const Variant& other) const
|
||||
bool Variant::operator_nomatch (const Variant& other, const Task& task) const
|
||||
{
|
||||
return ! operator_match (other);
|
||||
return ! operator_match (other, task);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
bool operator>= (const Variant&) const;
|
||||
bool operator== (const Variant&) const;
|
||||
bool operator!= (const Variant&) const;
|
||||
bool operator_match (const Variant&) const;
|
||||
bool operator_nomatch (const Variant&) const;
|
||||
bool operator_match (const Variant&, const Task&) const;
|
||||
bool operator_nomatch (const Variant&, const Task&) const;
|
||||
bool operator_partial (const Variant&) const;
|
||||
bool operator_nopartial (const Variant&) const;
|
||||
bool operator_hastag (const Variant&, const Task&) const;
|
||||
|
||||
Reference in New Issue
Block a user