mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-14 16:26:30 +00:00
xml_node.h: construct from Const_byte_range_ptr
This patch allows for the construction of 'Xml_node' objects from a 'Const_byte_range_ptr' argument as a safer alternative to the pair of addr, max_len arguments. Issue #5411
This commit is contained in:
parent
bdb8d4d881
commit
fe40a3c45e
@ -576,7 +576,7 @@ class Genode::Xml_node
|
||||
start(skip_non_tag_characters(Token(addr, max_len))),
|
||||
end(_search_end_tag(start, num_sub_nodes))
|
||||
{ }
|
||||
} _tags;
|
||||
} _tags { _addr, _max_len };
|
||||
|
||||
/**
|
||||
* Return true if specified buffer contains a valid XML node
|
||||
@ -628,14 +628,19 @@ class Genode::Xml_node
|
||||
*
|
||||
* \throw Invalid_syntax
|
||||
*/
|
||||
Xml_node(char const *addr, size_t max_len = ~0UL)
|
||||
Xml_node(Const_byte_range_ptr const &bytes)
|
||||
:
|
||||
_addr(addr), _max_len(max_len), _tags(addr, max_len)
|
||||
_addr(bytes.start), _max_len(bytes.num_bytes)
|
||||
{
|
||||
if (!_valid(_tags))
|
||||
throw Invalid_syntax();
|
||||
}
|
||||
|
||||
Xml_node(char const *addr, size_t max_len = ~0UL)
|
||||
:
|
||||
Xml_node(Const_byte_range_ptr { addr, max_len })
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Return size of node including start and end tags in bytes
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user