mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 04:30:13 +00:00
Add config::has_child().
This allows to easily query whether a certain child exists.
This commit is contained in:
parent
018ff27c62
commit
9ebb260d01
@ -374,6 +374,13 @@ unsigned config::child_count(const std::string &key) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool config::has_child(const std::string &key) const
|
||||
{
|
||||
check_valid();
|
||||
|
||||
return children.find(key) != children.end();
|
||||
}
|
||||
|
||||
config &config::child(const std::string& key, int n)
|
||||
{
|
||||
check_valid();
|
||||
|
@ -252,6 +252,15 @@ public:
|
||||
const_child_itors child_range(const std::string& key) const;
|
||||
unsigned child_count(const std::string &key) const;
|
||||
|
||||
/**
|
||||
* Determine whether a config has a child or not.
|
||||
*
|
||||
* @param key The key of the child to find.
|
||||
*
|
||||
* @returns Whether a child is available.
|
||||
*/
|
||||
bool has_child(const std::string& key) const;
|
||||
|
||||
/**
|
||||
* Copies the first child with the given @a key, or an empty config if there is none.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user