From 276a1775f16bc101ca7cdb8dd7f9e7cfc938af90 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 21 Jan 2014 22:32:18 +0100 Subject: [PATCH] Accessors for Xml_node utility This patch adds accessors to obtain the buffer of an attribute value, which is useful to avoid the copying-out of such information by maintaining pointers into the XML string as meta data. --- os/include/util/xml_node.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/os/include/util/xml_node.h b/os/include/util/xml_node.h index 397f2177c2..b62eecb93f 100644 --- a/os/include/util/xml_node.h +++ b/os/include/util/xml_node.h @@ -123,7 +123,8 @@ namespace Genode { /** * Return size of value */ - size_t value_size() const { return _value.len(); } + size_t value_size() const { return _value.len() - 2; } + char const *value_base() const { return _value.start() + 1; } /** * Return attribute value as null-terminated string @@ -550,9 +551,16 @@ namespace Genode { * Note that the returned string is not null-terminated as it * points directly into a sub range of the unmodified Xml_node * address range. + * + * XXX This function is deprecated. Use 'content_base()' instead. */ char *content_addr() const { return _start_tag.next_token().start(); } + /** + * Return pointer to start of content + */ + char const *content_base() const { return content_addr(); } + /** * Return size of node content */