mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
Xml_node::Unquoted utility for attribute values
The new utility can be used to revert quoted XML attribute values. Such quoting is needed whenever an attribute value can contain '"' characters. E.g., in the menu_view's <label text="..."> widget. Issue #1757
This commit is contained in:
parent
d70cf314d8
commit
567d9f7910
@ -16,11 +16,13 @@
|
||||
|
||||
#include <base/log.h>
|
||||
#include <util/token.h>
|
||||
#include <util/noncopyable.h>
|
||||
#include <base/exception.h>
|
||||
|
||||
namespace Genode {
|
||||
class Xml_attribute;
|
||||
class Xml_node;
|
||||
class Xml_unquoted;
|
||||
}
|
||||
|
||||
|
||||
@ -276,6 +278,8 @@ class Genode::Xml_node
|
||||
*/
|
||||
class Tag;
|
||||
|
||||
friend class Xml_unquoted;
|
||||
|
||||
public:
|
||||
|
||||
/*********************
|
||||
@ -1105,4 +1109,38 @@ class Genode::Xml_node
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Genode::Xml_unquoted : Noncopyable
|
||||
{
|
||||
private:
|
||||
|
||||
struct
|
||||
{
|
||||
char const *base;
|
||||
size_t len;
|
||||
} const _content_ptr;
|
||||
|
||||
public:
|
||||
|
||||
template <size_t N>
|
||||
Xml_unquoted(String<N> const &string)
|
||||
: _content_ptr({ string.string(), string.length() - 1})
|
||||
{ }
|
||||
|
||||
void print(Output &out) const
|
||||
{
|
||||
char const *src = _content_ptr.base;
|
||||
size_t len = _content_ptr.len;
|
||||
|
||||
while (len > 0) {
|
||||
Xml_node::Decoded_character const decoded_character(src, len);
|
||||
|
||||
Genode::print(out, Char(decoded_character.character));
|
||||
|
||||
src += decoded_character.encoded_len;
|
||||
len -= decoded_character.encoded_len;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__UTIL__XML_NODE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user