Command Line

- Added a method for extracting unstructured text from the command line.
This commit is contained in:
Paul Beckingham 2011-07-06 22:47:47 -04:00
parent 5e693b2530
commit 7a544489ae
2 changed files with 57 additions and 0 deletions

View file

@ -1502,6 +1502,62 @@ Arguments Arguments::extract_modifications ()
return modifications;
}
////////////////////////////////////////////////////////////////////////////////
Arguments Arguments::extract_simple_words ()
{
Arguments filter;
std::vector <Triple>::iterator arg;
for (arg = this->begin (); arg != this->end (); ++arg)
{
// Excluded.
if (arg->_third == "program" ||
arg->_third == "command" ||
arg->_third == "rc" ||
arg->_third == "override" ||
arg->_third == "attr" ||
arg->_third == "attmod")
{
;
}
// Included.
else if (arg->_third == "tag" ||
arg->_third == "pattern" ||
arg->_third == "seq" ||
arg->_third == "op" ||
arg->_third == "exp" ||
arg->_third == "word")
{
// "limit" is special - it is recognized but not included in filters.
if (arg->_first.find ("limit:") == std::string::npos)
filter.push_back (*arg);
}
// Error.
else
{
if (arg->_third == "tag")
throw std::string ("A tag '") + arg->_first + "' is not allowed "
"with this command.";
else if (arg->_third == "pattern")
throw std::string ("A pattern '") + arg->_first + "' is not allowed "
"with this command.";
else if (arg->_third == "substitution")
throw std::string ("A substitution '") + arg->_first + "' is not allowed "
"with this command.";
else
throw std::string ("Argument '") + arg->_first + "' is not allowed "
"with this command.";
}
}
return filter;
}
////////////////////////////////////////////////////////////////////////////////
bool Arguments::valid_modifier (const std::string& modifier)
{

View file

@ -132,6 +132,7 @@ public:
Arguments extract_read_only_filter ();
Arguments extract_write_filter ();
Arguments extract_modifications ();
Arguments extract_simple_words ();
static bool valid_modifier (const std::string&);