mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Allow beast::lexicalCast to parse 'true' & 'false' into a bool
This commit is contained in:
committed by
Vinnie Falco
parent
4640079f55
commit
78dfb6bcf5
@@ -178,6 +178,27 @@ struct LexicalCast <Out, std::string>
|
||||
{
|
||||
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