::operator_hastag now uses contextTask for resolution.
This commit is contained in:
Paul Beckingham 2014-06-03 01:10:58 -04:00
parent 56a70b00c4
commit ca6940ba2e
3 changed files with 12 additions and 21 deletions

View file

@ -28,10 +28,12 @@
#include <map> #include <map>
#include <time.h> #include <time.h>
#include <Context.h> #include <Context.h>
#include <Task.h>
#include <Color.h> #include <Color.h>
#include <Eval.h> #include <Eval.h>
extern Context context; extern Context context;
extern Task& contextTask;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Supported operators, borrowed from C++, particularly the precedence. // Supported operators, borrowed from C++, particularly the precedence.
@ -287,8 +289,8 @@ void Eval::evaluatePostfixStack (
else if (token->first == "xor") left = left.operator_xor (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_match (right);
else if (token->first == "!~") left = left.operator_nomatch (right); else if (token->first == "!~") left = left.operator_nomatch (right);
else if (token->first == "_hastag_") left = left.operator_hastag (right); else if (token->first == "_hastag_") left = left.operator_hastag (right, contextTask);
else if (token->first == "_notag_") left = left.operator_notag (right); else if (token->first == "_notag_") left = left.operator_notag (right, contextTask);
else else
std::cout << "# Unrecognized operator '" << token->first << "'\n"; std::cout << "# Unrecognized operator '" << token->first << "'\n";

View file

@ -917,29 +917,17 @@ bool Variant::operator_nopartial (const Variant& other) const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Variant::operator_hastag (const Variant& other) const bool Variant::operator_hastag (const Variant& other, const Task& task) const
{ {
Variant left (*this); // tags Variant right (other);
Variant right (other); // tag
left.cast (type_string);
right.cast (type_string); right.cast (type_string);
return task.hasTag (right._string);
std::vector <std::string> individual;
split (individual, left._string, ',');
std::vector <std::string>::iterator i;
for (i = individual.begin (); i != individual.end (); ++i)
if (*i == right._string)
return true;
return false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Variant::operator_notag (const Variant& other) const bool Variant::operator_notag (const Variant& other, const Task& task) const
{ {
return ! operator_hastag (other); return ! operator_hastag (other, task);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -29,6 +29,7 @@
#include <string> #include <string>
#include <time.h> #include <time.h>
#include <Task.h>
class Variant class Variant
{ {
@ -67,8 +68,8 @@ public:
bool operator_nomatch (const Variant&) const; bool operator_nomatch (const Variant&) const;
bool operator_partial (const Variant&) const; bool operator_partial (const Variant&) const;
bool operator_nopartial (const Variant&) const; bool operator_nopartial (const Variant&) const;
bool operator_hastag (const Variant&) const; bool operator_hastag (const Variant&, const Task&) const;
bool operator_notag (const Variant&) const; bool operator_notag (const Variant&, const Task&) const;
bool operator! () const; bool operator! () const;
Variant& operator^= (const Variant&); Variant& operator^= (const Variant&);