__remove= attribute. Deletes tags when merged.

A wml tag with the attribute set to yes will not be merged into but
delete the tag in the final merge result.
This commit is contained in:
fendrin 2013-09-30 06:56:20 +02:00
parent cd515e2f5f
commit 67bb876ffa

View File

@ -1237,6 +1237,7 @@ void config::merge_with(const config& c)
{
check_valid(c);
std::vector<child_pos> to_remove;
std::map<std::string, unsigned> visitations;
// Merge attributes first
@ -1250,7 +1251,12 @@ void config::merge_with(const config& c)
if (j != c.children.end()) {
unsigned &visits = visitations[tag];
if(visits < j->second.size()) {
(i->pos->second[i->index])->merge_with(*j->second[visits++]);
if ((*j->second[visits])["__remove"].to_bool()) {
visits++;
to_remove.push_back(*i);
} else
(i->pos->second[i->index])->merge_with(*j->second[visits++]);
}
}
}
@ -1263,6 +1269,15 @@ void config::merge_with(const config& c)
add_child(tag, *j->second[visits++]);
}
}
// Remove those marked so
std::map<std::string, unsigned> removals;
BOOST_FOREACH(const child_pos& pos, to_remove) {
const std::string& tag = pos.pos->first;
unsigned &removes = removals[tag];
remove_child(tag, pos.index - removes++);
}
}
/**