Allow beast::lexicalCast to parse 'true' & 'false' into a bool

This commit is contained in:
Nik Bougalis
2014-09-25 16:01:41 -07:00
committed by Vinnie Falco
parent 4640079f55
commit 78dfb6bcf5

View File

@@ -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;
}
};
//------------------------------------------------------------------------------