mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Commands
- Promoted filtering code to the Command base class. - Added filtering short-circuit.
This commit is contained in:
parent
db17536266
commit
7762ee2f9e
14 changed files with 79 additions and 173 deletions
|
@ -27,7 +27,9 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <Expression.h>
|
||||
#include <Command.h>
|
||||
|
||||
#include <CmdAdd.h>
|
||||
#include <CmdAnnotate.h>
|
||||
#include <CmdAppend.h>
|
||||
|
@ -249,3 +251,20 @@ bool Command::displays_id () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
|
||||
{
|
||||
Arguments f = context.args.extract_read_only_filter ();
|
||||
if (f.size ())
|
||||
{
|
||||
Expression e (f);
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = input.begin (); task != input.end (); ++task)
|
||||
if (e.eval (*task))
|
||||
output.push_back (*task);
|
||||
}
|
||||
else
|
||||
output = input;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue