mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-14 13:18:19 +00:00
xml_node: change with_sub_node
signature
The `with_sub_node` method is renamed to `with_optional_sub_node` to better reflect that the non-existence of a sub node with the desired type is ignored. At the same time, the new `with_sub_node` now takes a second functor that is called when no sub node of the desired type exists. genodelabs/genode#4600
This commit is contained in:
committed by
Norman Feske
parent
f0e9881c7e
commit
7d143087c9
@ -846,12 +846,27 @@ class Genode::Xml_node
|
||||
* If no matching sub node exists, the functor is not called.
|
||||
*/
|
||||
template <typename FN>
|
||||
void with_sub_node(char const *type, FN const &fn) const
|
||||
void with_optional_sub_node(char const *type, FN const &fn) const
|
||||
{
|
||||
if (has_sub_node(type))
|
||||
fn(sub_node(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply functor 'fn' to first sub node of specified type
|
||||
*
|
||||
* The functor is called with the sub node as argument.
|
||||
* If no matching sub node exists, the functor 'fn_nexists' is called.
|
||||
*/
|
||||
template <typename FN, typename FN_NEXISTS>
|
||||
void with_sub_node(char const *type, FN const &fn, FN_NEXISTS const &fn_nexists) const
|
||||
{
|
||||
if (has_sub_node(type))
|
||||
fn(sub_node(type));
|
||||
else
|
||||
fn_nexists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute functor 'fn' for each sub node of specified type
|
||||
*/
|
||||
|
Reference in New Issue
Block a user