mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
ascii_to() utility for boolean values
Also, Genode::Arg was adapted to use the new utility for boolean tokens and strings. Issue #1648
This commit is contained in:
committed by
Christian Helmuth
parent
ce354d6fd9
commit
df0bbe0b0e
@@ -309,6 +309,24 @@ namespace Genode {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read boolean value from string
|
||||
*
|
||||
* \return number of consumed characters
|
||||
*/
|
||||
inline size_t ascii_to(char const *s, bool &result)
|
||||
{
|
||||
if (!strcmp(s, "yes", 3)) { result = true; return 3; }
|
||||
if (!strcmp(s, "true", 4)) { result = true; return 4; }
|
||||
if (!strcmp(s, "on", 2)) { result = true; return 2; }
|
||||
if (!strcmp(s, "no", 2)) { result = false; return 2; }
|
||||
if (!strcmp(s, "false", 5)) { result = false; return 5; }
|
||||
if (!strcmp(s, "off", 3)) { result = false; return 3; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read unsigned long value from string
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user