Expression reboot

- More integration of A3 into Context.
- Now ready for filter/modification/word extraction.
This commit is contained in:
Paul Beckingham 2011-07-23 17:03:44 -04:00
parent 4fc4e0f637
commit abcda0bcfa
4 changed files with 41 additions and 22 deletions

View file

@ -495,6 +495,34 @@ const std::vector <std::string> A3::list () const
return all; return all;
} }
////////////////////////////////////////////////////////////////////////////////
bool A3::find_command (std::string& command) const
{
std::vector <Arg>::const_iterator arg;
for (arg = this->begin (); arg != this->end (); ++arg)
{
if (arg->_category == "command")
{
command = arg->_raw;
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
const std::string A3::find_limit () const
{
std::vector <Arg>::const_reverse_iterator arg;
for (arg = this->rbegin (); arg != this->rend (); ++arg)
if (arg->_raw.find ("limit:") != std::string::npos)
return arg->_raw.substr (6);
return "";
}
@ -519,22 +547,6 @@ std::vector <std::string> A3::operator_list ()
return all; return all;
} }
////////////////////////////////////////////////////////////////////////////////
bool A3::find_command (std::string& command)
{
std::vector <Arg>::iterator arg;
for (arg = this->begin (); arg != this->end (); ++arg)
{
if (arg->_third == "command")
{
command = arg->_first;
return true;
}
}
return false;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string A3::find_limit () std::string A3::find_limit ()
{ {

View file

@ -95,12 +95,12 @@ public:
const std::string combine () const; const std::string combine () const;
const std::vector <std::string> list () const; const std::vector <std::string> list () const;
bool find_command (std::string&) const;
const std::string find_limit () const;
/* /*
static std::vector <std::string> operator_list (); static std::vector <std::string> operator_list ();
bool find_command (std::string&);
std::string find_limit ();
static bool is_multipart (const std::string&, std::vector <std::string>&); static bool is_multipart (const std::string&, std::vector <std::string>&);
static bool is_attr (const std::string&); static bool is_attr (const std::string&);

View file

@ -98,7 +98,6 @@ int Context::initialize (int argc, const char** argv)
// location (~/.task), or set by data.location in the config file, or // location (~/.task), or set by data.location in the config file, or
// overridden by rc.data.location on the command line. // overridden by rc.data.location on the command line.
std::string location; std::string location;
// args.get_data_location (location);
a3.get_data_location (location); a3.get_data_location (location);
data_dir = Directory (location); data_dir = Directory (location);
extension_dir = data_dir.data + "/extensions"; extension_dir = data_dir.data + "/extensions";
@ -112,7 +111,6 @@ int Context::initialize (int argc, const char** argv)
a3.resolve_aliases (); a3.resolve_aliases ();
// Apply rc overrides to Context::config, capturing raw args for later use. // Apply rc overrides to Context::config, capturing raw args for later use.
// args.apply_overrides ();
a3.apply_overrides (); a3.apply_overrides ();
// Initialize the color rules, if necessary. // Initialize the color rules, if necessary.
@ -279,7 +277,7 @@ int Context::dispatch (std::string &out)
// Autocomplete args against keywords. // Autocomplete args against keywords.
std::string command; std::string command;
if (args.find_command (command)) if (a3.find_command (command))
{ {
updateXtermTitle (); updateXtermTitle ();
@ -292,7 +290,13 @@ int Context::dispatch (std::string &out)
tdb2.gc (); tdb2.gc ();
} }
// args.dump ("Argument Categorization"); // Only read-only commands can be run when TDB2 is read-only.
// TODO Implement TDB2::read_only
/*
if (tdb2.read_only () && !c->read_only ())
throw std::string ("");
*/
return c->execute (out); return c->execute (out);
} }

View file

@ -86,7 +86,10 @@ int CmdCustom::execute (std::string& output)
split (filterArgs, reportFilter, ' '); split (filterArgs, reportFilter, ' ');
std::vector <std::string>::iterator arg; std::vector <std::string>::iterator arg;
for (arg = filterArgs.begin (); arg != filterArgs.end (); ++ arg) for (arg = filterArgs.begin (); arg != filterArgs.end (); ++ arg)
{
context.args.capture_first (*arg); context.args.capture_first (*arg);
context.a3.capture_first (*arg);
}
// Load the data. // Load the data.
// TODO Replace with TDB2. // TODO Replace with TDB2.