mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Allow beast::lexicalCast to parse 'true' & 'false' into a bool
This commit is contained in:
committed by
Vinnie Falco
parent
c1ecd661c3
commit
8e91ce67c5
@@ -178,6 +178,27 @@ struct LexicalCast <Out, std::string>
|
|||||||
{
|
{
|
||||||
return parseSigned (out, std::begin(in), std::end(in));
|
return parseSigned (out, std::begin(in), std::end(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
operator () (bool& out, std::string in) const
|
||||||
|
{
|
||||||
|
// Convert the input to lowercase
|
||||||
|
std::transform(in.begin (), in.end (), in.begin (), ::tolower);
|
||||||
|
|
||||||
|
if (in == "1" || in == "true")
|
||||||
|
{
|
||||||
|
out = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in == "0" || in == "false")
|
||||||
|
{
|
||||||
|
out = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user