- ::findUUIDList now safely removes nodes out of the iterator loop.
This commit is contained in:
Paul Beckingham 2014-08-24 12:53:50 -04:00
parent f6c422385b
commit df80050c13

View file

@ -1432,73 +1432,85 @@ void Parser::findIdSequence ()
void Parser::findUUIDList () void Parser::findUUIDList ()
{ {
context.debug ("Parser::findUUIDList"); context.debug ("Parser::findUUIDList");
bool action = false; bool action = true;
std::vector <Tree*> nodes; do
collect (nodes);
std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
std::string raw = (*i)->attribute ("raw"); action = false;
Nibbler n (raw);
std::vector <std::string> sequence; std::vector <Tree*> nodes;
std::string uuid; collect (nodes, collectAll);
if (n.getUUID (uuid) || std::vector <Tree*>::iterator i;
n.getPartialUUID (uuid)) for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
sequence.push_back (uuid); std::string raw = (*i)->attribute ("raw");
while (n.skip (',')) if (raw == "--")
break;
if (! (*i)->hasTag ("?"))
continue;
Nibbler n (raw);
std::vector <std::string> uuidList;
std::string uuid;
if (n.getUUID (uuid) ||
n.getPartialUUID (uuid))
{ {
if (!n.getUUID (uuid) && uuidList.push_back (uuid);
!n.getPartialUUID (uuid))
throw std::string (STRING_PARSER_UUID_AFTER_COMMA);
sequence.push_back (uuid); while (n.skip (','))
}
if (n.depleted ())
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("UUID");
Tree* branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "(");
branch->tag ("OP");
std::vector <std::string>::iterator u;
for (u = sequence.begin (); u != sequence.end (); ++u)
{ {
if (u != sequence.begin ()) if (!n.getUUID (uuid) &&
!n.getPartialUUID (uuid))
throw std::string (STRING_PARSER_UUID_AFTER_COMMA);
uuidList.push_back (uuid);
}
if (n.depleted ())
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("UUID");
Tree* branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "(");
branch->tag ("OP");
std::vector <std::string>::iterator u;
for (u = uuidList.begin (); u != uuidList.end (); ++u)
{ {
if (u != uuidList.begin ())
{
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "or");
branch->tag ("OP");
}
branch = (*i)->addBranch (new Tree ("argSeq")); branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "or"); branch->attribute ("raw", "uuid");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "=");
branch->tag ("OP"); branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "'" + *u + "'");
} }
branch = (*i)->addBranch (new Tree ("argSeq")); branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "uuid"); branch->attribute ("raw", ")");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "=");
branch->tag ("OP"); branch->tag ("OP");
action = true;
branch = (*i)->addBranch (new Tree ("argSeq")); break;
branch->attribute ("raw", "'" + *u + "'");
} }
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ")");
branch->tag ("OP");
action = true;
} }
} }
} }
while (action);
if (action) context.debug (_tree->dump ());
context.debug (_tree->dump ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////