Report Filters

- Report filters are now properly loaded and injected into the argument
  list.
This commit is contained in:
Paul Beckingham 2011-06-25 21:56:57 -04:00
parent b58438bdd4
commit 42ead6b34d
4 changed files with 47 additions and 3 deletions

View file

@ -168,7 +168,7 @@ void Arguments::capture (int argc, const char** argv)
}
////////////////////////////////////////////////////////////////////////////////
// Add a pair with a category of "".
// Append a pair with a category of "".
void Arguments::capture (const std::string& arg)
{
std::vector <std::string> parts;
@ -184,6 +184,36 @@ void Arguments::capture (const std::string& arg)
categorize ();
}
////////////////////////////////////////////////////////////////////////////////
// Prepend a pair with a category of "".
void Arguments::capture_first (const std::string& arg)
{
// Break the new argument into parts that comprise a series.
std::vector <std::pair <std::string, std::string> > series;
std::vector <std::string> parts;
if (is_multipart (arg, parts))
{
std::vector <std::string>::iterator part;
for (part = parts.begin (); part != parts.end (); ++part)
series.push_back (std::make_pair (*part, ""));
}
else
series.push_back (std::make_pair (arg, ""));
// Locate an appropriate place to insert the series. This would be
// immediately after the program and command arguments.
std::vector <std::pair <std::string, std::string> >::iterator position;
for (position = this->begin (); position != this->end (); ++position)
if (position->second != "program" &&
position->second != "command")
break;
this->insert (position, series.begin (), series.end ());
categorize ();
}
////////////////////////////////////////////////////////////////////////////////
// Add a pair for every word from std::cin, with a category of "".
void Arguments::append_stdin ()

View file

@ -42,6 +42,7 @@ public:
void capture (int, const char**);
void capture (const std::string&);
void capture_first (const std::string&);
void categorize ();
void append_stdin ();

View file

@ -82,6 +82,13 @@ int CmdCustom::execute (std::string& output)
split (sortOrder, reportSort, ',');
validateSortColumns (sortOrder);
// Prepend the argument list with those from the report filter.
std::vector <std::string> filterArgs;
split (filterArgs, reportFilter, ' ');
std::vector <std::string>::iterator arg;
for (arg = filterArgs.begin (); arg != filterArgs.end (); ++ arg)
context.args.capture_first (*arg);
// Load the data.
// TODO Replace with TDB2.
std::vector <Task> tasks;