mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
base: add Xml_node::for_each_attribute
Adds a function that allows iterating over an XML node's attributes without relying on `Xml_node::Nonexistent_attribute`. Issue #4817
This commit is contained in:
parent
7e06aa13c1
commit
83f78e7fe6
@ -990,6 +990,26 @@ class Genode::Xml_node
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute functor 'fn' for each attribute
|
||||
*/
|
||||
template <typename FN>
|
||||
void for_each_attribute(FN const &fn) const
|
||||
{
|
||||
if (!_tags.start.has_attribute())
|
||||
return;
|
||||
|
||||
for (Xml_attribute attr = _tags.start.attribute(); ; ) {
|
||||
fn(attr);
|
||||
|
||||
Token const next = attr._next_token();
|
||||
if (!Xml_attribute::_valid(next))
|
||||
return;
|
||||
|
||||
attr = Xml_attribute(next);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if sub node of specified type exists
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user