Function fromString< bool >
Synopsis
#include <lib/inc/drogon/utils/Utilities.h>
template <>
bool fromString< bool >(const std::string &p) noexcept(false)
Description
No description yet.
Source
Lines 386-410 in lib/inc/drogon/utils/Utilities.h.
template <>
inline bool fromString<bool>(const std::string &p) noexcept(false)
{
if (p == "1")
{
return true;
}
if (p == "0")
{
return false;
}
std::string l{p};
std::transform(p.begin(), p.end(), l.begin(), [](unsigned char c) {
return tolower(c);
});
if (l == "true")
{
return true;
}
else if (l == "false")
{
return false;
}
throw std::runtime_error("Can't convert from string '" + p + "' to bool");
}