mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 19:58:11 +00:00
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:
parent
3b2077fdc3
commit
192fbdc173
@ -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();
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user