mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-28 11:20:53 +00:00
Changed: Support more values for fromString with a boolean
This commit is contained in:
parent
816d812ea2
commit
a82b0baa72
1 changed files with 20 additions and 9 deletions
|
@ -246,27 +246,38 @@ inline bool fromString(const std::string &str, bool &val)
|
|||
{
|
||||
if (str.length() == 1)
|
||||
{
|
||||
if (str[0] == '1')
|
||||
const char c = str[0];
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case '1':
|
||||
case 't':
|
||||
case 'T':
|
||||
case 'y':
|
||||
case 'Y':
|
||||
val = true;
|
||||
}
|
||||
else if (str[0] == '0')
|
||||
{
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case 'f':
|
||||
case 'F':
|
||||
case 'n':
|
||||
case 'N':
|
||||
val = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
default:
|
||||
val = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (str == "true")
|
||||
if (str == "true" || str == "yes")
|
||||
{
|
||||
val = true;
|
||||
}
|
||||
else if (str == "false")
|
||||
else if (str == "false" || str == "no")
|
||||
{
|
||||
val = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue