CLI: Abstract adding new raw filter to a new helper method

This commit is contained in:
Tomas Babej 2015-02-21 15:45:38 +01:00 committed by Paul Beckingham
parent 09fe5be086
commit 1abda3900b
3 changed files with 16 additions and 9 deletions

View file

@ -374,6 +374,20 @@ void CLI::add (const std::string& arg)
analyze (); analyze ();
} }
////////////////////////////////////////////////////////////////////////////////
// Process raw string into parsed filter.
//
void CLI::addRawFilter (const std::string& arg)
{
std::string lexeme;
Lexer::Type type;
Lexer lex (arg);
lex.ambiguity (false);
while (lex.token (lexeme, type))
add (lexeme);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Intended to be called after ::initialize() and ::add(), to perform the final // Intended to be called after ::initialize() and ::add(), to perform the final
// analysis. Analysis is also performed directly after the above, because there // analysis. Analysis is also performed directly after the above, because there

View file

@ -77,6 +77,7 @@ public:
void entity (const std::string&, const std::string&); void entity (const std::string&, const std::string&);
void initialize (int, const char**); void initialize (int, const char**);
void add (const std::string&); void add (const std::string&);
void addRawFilter (const std::string& arg);
void analyze (bool parse = true, bool strict = false); void analyze (bool parse = true, bool strict = false);
void applyOverrides (); void applyOverrides ();
const std::string getFilter (); const std::string getFilter ();

View file

@ -82,15 +82,7 @@ int CmdCustom::execute (std::string& output)
validateSortColumns (sortOrder); validateSortColumns (sortOrder);
// Prepend the argument list with those from the report filter. // Prepend the argument list with those from the report filter.
std::string lexeme; context.cli.addRawFilter(reportFilter);
Lexer::Type type;
Lexer lex (reportFilter);
lex.ambiguity (false);
while (lex.token (lexeme, type))
context.cli.add (lexeme);
// Reparse after tree change.
context.cli.analyze ();
// Apply filter. // Apply filter.
handleRecurrence (); handleRecurrence ();