Config: added function to move children from one config to another

The regular append_children function makes a copy of the applicable child tags. This moves them
from the source to the destination configs. Do note it leaves the source tags empty.
This commit is contained in:
Charles Dang 2017-11-09 21:11:59 +11:00
parent 3b2077fdc3
commit 192fbdc173
2 changed files with 14 additions and 0 deletions

View File

@ -255,6 +255,17 @@ void config::append(const config& cfg)
}
}
void config::append_children_by_move(config& cfg, const std::string& key)
{
check_valid(cfg);
// DO note this leaves the tags empty in the source config. Not sure if
// that should be changed.
for(config& value : cfg.child_range(key)) {
add_child(key, std::move(value));
}
}
void config::merge_children(const std::string& key)
{
check_valid();

View File

@ -733,6 +733,9 @@ public:
*/
void append_children(const config &cfg, const std::string& key);
/** Moves children with the given name from the given config to this one. */
void append_children_by_move(config& cfg, const std::string& key);
/**
* Adds attributes from @a cfg.
*/