mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-06 09:21:49 +00:00
os: add Xml_attribute::value(String<N> *out)
This overload of the value member eases the retrieval of Genode::String objects from XML attributes. So we won't need to deal with C-style character buffers anymore.
This commit is contained in:
parent
c8ec7b6ffb
commit
a80d944944
@ -119,11 +119,8 @@ class Genode::Xml_attribute
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return attribute value as null-terminated string
|
* Return attribute value as null-terminated string
|
||||||
*
|
|
||||||
* \return true on success, or
|
|
||||||
* false if attribute is invalid
|
|
||||||
*/
|
*/
|
||||||
bool value(char *dst, size_t max_len) const
|
void value(char *dst, size_t max_len) const
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The value of 'max_len' denotes the maximum number of
|
* The value of 'max_len' denotes the maximum number of
|
||||||
@ -134,7 +131,6 @@ class Genode::Xml_attribute
|
|||||||
*/
|
*/
|
||||||
max_len = min(max_len, _value.len() - 2 + 1);
|
max_len = min(max_len, _value.len() - 2 + 1);
|
||||||
strncpy(dst, _value.start() + 1, max_len);
|
strncpy(dst, _value.start() + 1, max_len);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,6 +160,17 @@ class Genode::Xml_attribute
|
|||||||
return ascii_to(_value.start() + 1, *out) == _value.len() - 2;
|
return ascii_to(_value.start() + 1, *out) == _value.len() - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return attribute value as Genode::String
|
||||||
|
*/
|
||||||
|
template <size_t N>
|
||||||
|
void value(String<N> *out) const
|
||||||
|
{
|
||||||
|
char buf[N];
|
||||||
|
value(buf, sizeof(buf));
|
||||||
|
*out = String<N>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next attribute in attribute list
|
* Return next attribute in attribute list
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user