Expressions

- Broke out expression handling into two distinct flavors: filter
  and expression.  Filters need lots of preparation and mapping,
  which includes implicit 'AND' operators, expansion of syntactic
  sugar like /pattern/ etc and evaluate to a Boolean.  Expressions
  are simpler wiht less preparation, and evaluate to a Variant.
This commit is contained in:
Paul Beckingham 2011-07-17 12:04:38 -04:00
parent d66729adf3
commit e08d840ba1
6 changed files with 150 additions and 85 deletions

View file

@ -69,8 +69,9 @@ int CmdAdd::execute (std::string& output)
if (context.verbose ("new-id"))
output = format (STRING_CMD_ADD_FEEDBACK, context.tdb.nextId ()) + "\n";
*/
/*
context.footnote (onProjectChange (task));
*/
context.tdb2.commit ();
return rc;
}

View file

@ -78,7 +78,9 @@ int CmdLog::execute (std::string& output)
task.validate ();
context.tdb2.add (task);
/*
context.footnote (onProjectChange (task));
*/
context.tdb2.commit ();
if (context.config.getBoolean ("echo.command"))

View file

@ -279,7 +279,7 @@ void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
std::vector <Task>::iterator task;
for (task = input.begin (); task != input.end (); ++task)
if (e.eval (*task))
if (e.evalFilter (*task))
output.push_back (*task);
}
else
@ -306,14 +306,14 @@ void Command::filter (std::vector <Task>& output)
output.clear ();
std::vector <Task>::const_iterator task;
for (task = pending.begin (); task != pending.end (); ++task)
if (e.eval (*task))
if (e.evalFilter (*task))
output.push_back (*task);
if (! filter_shortcut (f))
{
const std::vector <Task>& completed = context.tdb2.completed.get_tasks (); // TODO Optional
for (task = completed.begin (); task != completed.end (); ++task)
if (e.eval (*task))
if (e.evalFilter (*task))
output.push_back (*task);
}
else