mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 18:06:50 +00:00
parent
ef269ea2e0
commit
da150dbb1c
@ -110,7 +110,7 @@ class Genode::Token
|
|||||||
/**
|
/**
|
||||||
* Access single characters of token
|
* Access single characters of token
|
||||||
*/
|
*/
|
||||||
char operator [] (int idx)
|
char operator [] (int idx) const
|
||||||
{
|
{
|
||||||
return ((idx >= 0) && ((unsigned)idx < _len)) ? _start[idx] : 0;
|
return ((idx >= 0) && ((unsigned)idx < _len)) ? _start[idx] : 0;
|
||||||
}
|
}
|
||||||
|
@ -55,17 +55,16 @@ class Genode::Xml_attribute
|
|||||||
struct Tokens
|
struct Tokens
|
||||||
{
|
{
|
||||||
Token name;
|
Token name;
|
||||||
Token value;
|
Token equals { name .next().eat_whitespace() };
|
||||||
|
Token value { equals.next().eat_whitespace() };
|
||||||
|
|
||||||
Tokens(Token t)
|
Tokens(Token t) : name(t.eat_whitespace()) { };
|
||||||
: name(t.eat_whitespace()), value(name.next().next()) { };
|
|
||||||
|
|
||||||
bool valid() const
|
bool valid() const
|
||||||
{
|
{
|
||||||
bool const tag_present = (name.type() == Token::IDENT);
|
return (name.type() == Token::IDENT)
|
||||||
bool const value_present = (name.next()[0] == '=' &&
|
&& (equals[0] == '=')
|
||||||
value.type() == Token::STRING);
|
&& (value.type() == Token::STRING);
|
||||||
return tag_present && value_present;
|
|
||||||
}
|
}
|
||||||
} _tokens;
|
} _tokens;
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ class Genode::Xml_attribute
|
|||||||
/**
|
/**
|
||||||
* Return token following the attribute declaration
|
* Return token following the attribute declaration
|
||||||
*/
|
*/
|
||||||
Token _next_token() const { return _tokens.name.next().next().next(); }
|
Token _next_token() const { return _tokens.value.next(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ class Genode::Xml_node
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if tag as at least one attribute
|
* Return true if tag has at least one attribute
|
||||||
*/
|
*/
|
||||||
bool has_attribute() const { return Xml_attribute::_valid(_name.next()); }
|
bool has_attribute() const { return Xml_attribute::_valid(_name.next()); }
|
||||||
|
|
||||||
|
@ -99,6 +99,9 @@
|
|||||||
[init -> test-xml_node] -- Test backslash as attribute value --
|
[init -> test-xml_node] -- Test backslash as attribute value --
|
||||||
[init -> test-xml_node] attribute value: '\'
|
[init -> test-xml_node] attribute value: '\'
|
||||||
[init -> test-xml_node]
|
[init -> test-xml_node]
|
||||||
|
[init -> test-xml_node] -- Test whitespace around assignment character --
|
||||||
|
[init -> test-xml_node] attribute value: '123'
|
||||||
|
[init -> test-xml_node]
|
||||||
[init -> test-xml_node] -- Test exporting decoded content from XML node --
|
[init -> test-xml_node] -- Test exporting decoded content from XML node --
|
||||||
[init -> test-xml_node] step 1
|
[init -> test-xml_node] step 1
|
||||||
[init -> test-xml_node] step 2
|
[init -> test-xml_node] step 2
|
||||||
|
@ -152,6 +152,10 @@ static const char *xml_test_comments =
|
|||||||
static const char *xml_test_backslash =
|
static const char *xml_test_backslash =
|
||||||
"<config attr=\"\\\"/>";
|
"<config attr=\"\\\"/>";
|
||||||
|
|
||||||
|
/* withspace around attribute assignment character */
|
||||||
|
static const char *xml_test_whitespace_assign =
|
||||||
|
"<config attr = \"123\"/>";
|
||||||
|
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
** Test program **
|
** Test program **
|
||||||
@ -415,6 +419,12 @@ void Component::construct(Genode::Env &env)
|
|||||||
log("attribute value: '", node.attribute_value("attr", String<10>()), "'\n");
|
log("attribute value: '", node.attribute_value("attr", String<10>()), "'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log("-- Test whitespace around assignment character --");
|
||||||
|
{
|
||||||
|
Xml_node const node(xml_test_whitespace_assign);
|
||||||
|
log("attribute value: '", node.attribute_value("attr", String<10>()), "'\n");
|
||||||
|
}
|
||||||
|
|
||||||
log("-- Test exporting decoded content from XML node --");
|
log("-- Test exporting decoded content from XML node --");
|
||||||
test_decoded_content<~0UL>(env, 1, xml_test_comments, 8, 119);
|
test_decoded_content<~0UL>(env, 1, xml_test_comments, 8, 119);
|
||||||
test_decoded_content<119 >(env, 2, xml_test_comments, 8, 119);
|
test_decoded_content<119 >(env, 2, xml_test_comments, 8, 119);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user