- Converted ::modify to use CLI.
This commit is contained in:
Paul Beckingham 2014-10-31 22:30:39 -04:00
parent 9bc8e3bae3
commit 0a7d02787d

View file

@ -1908,28 +1908,24 @@ void Task::modify (modType type, bool text_required /* = false */)
{ {
std::string text = ""; std::string text = "";
Tree* tree = context.parser.tree ();
if (context.config.getInteger ("debug.parser") >= 1) if (context.config.getInteger ("debug.parser") >= 1)
{
context.debug (context.cli.dump ()); context.debug (context.cli.dump ());
context.debug (tree->dump ());
}
context.debug ("Task::modify"); context.debug ("Task::modify");
std::string label = " MODIFICATION "; std::string label = " MODIFICATION ";
int modCount = 0; int modCount = 0;
std::vector <Tree*>::iterator i; std::vector <A>::iterator a;
for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i) for (a = context.cli._args.begin (); a != context.cli._args.end (); ++a)
{ {
if ((*i)->hasTag ("MODIFICATION")) if (a->hasTag ("MODIFICATION"))
{ {
if ((*i)->hasTag ("ATTRIBUTE")) if (a->hasTag ("ATTRIBUTE"))
{ {
// 'name' is canonical. // 'name' is canonical.
// 'value' requires eval. // 'value' requires eval.
std::string name = (*i)->attribute ("name"); std::string name = a->attribute ("name");
std::string value = (*i)->attribute ("raw"); std::string value = a->attribute ("value");
if (value == "" || if (value == "" ||
value == "''" || value == "''" ||
value == "\"\"") value == "\"\"")
@ -2113,22 +2109,22 @@ void Task::modify (modType type, bool text_required /* = false */)
} }
// arg7 from='from' global='1' raw='/from/to/g' to='to' ORIGINAL SUBSTITUTION MODIFICATION // arg7 from='from' global='1' raw='/from/to/g' to='to' ORIGINAL SUBSTITUTION MODIFICATION
else if ((*i)->hasTag ("SUBSTITUTION")) else if (a->hasTag ("SUBSTITUTION"))
{ {
context.debug (label + "substitute " + (*i)->attribute ("raw")); context.debug (label + "substitute " + a->attribute ("raw"));
substitute ((*i)->attribute ("from"), substitute (a->attribute ("from"),
(*i)->attribute ("to"), a->attribute ("to"),
((*i)->attribute ("global") == "1")); (a->attribute ("global") == "1"));
++modCount; ++modCount;
} }
// Tags need special handling because they are essentially a vector stored // Tags need special handling because they are essentially a vector stored
// in a single string, therefore Task::{add,remove}Tag must be called as // in a single string, therefore Task::{add,remove}Tag must be called as
// appropriate. // appropriate.
else if ((*i)->hasTag ("TAG")) else if (a->hasTag ("TAG"))
{ {
std::string tag = (*i)->attribute ("tag"); std::string tag = a->attribute ("tag");
if ((*i)->attribute ("sign") == "+") if (a->attribute ("sign") == "+")
{ {
context.debug (label + "tags <-- add '" + tag + "'"); context.debug (label + "tags <-- add '" + tag + "'");
addTag (tag); addTag (tag);
@ -2144,12 +2140,12 @@ void Task::modify (modType type, bool text_required /* = false */)
} }
// WORD and TERMINATED args are accumulated. // WORD and TERMINATED args are accumulated.
else if ((*i)->hasTag ("WORD") || else if (a->hasTag ("WORD") ||
(*i)->hasTag ("TERMINATED")) a->hasTag ("TERMINATED"))
{ {
if (text != "") if (text != "")
text += ' '; text += ' ';
text += (*i)->attribute ("raw"); text += a->attribute ("raw");
} }
// Unknown args are accumulated as though they were WORDs. // Unknown args are accumulated as though they were WORDs.
@ -2157,7 +2153,7 @@ void Task::modify (modType type, bool text_required /* = false */)
{ {
if (text != "") if (text != "")
text += ' '; text += ' ';
text += (*i)->attribute ("raw"); text += a->attribute ("raw");
} }
} }
} }