13 const auto r = std::strtol(str.c_str(), &end, 10);
14 if(end == str.c_str()) {
return std::nullopt; }
20 return static_cast<int>(r);
28 const auto r = std::strtof(str.c_str(), &end);
29 if(end == str.c_str()) {
return std::nullopt; }
37 if(str ==
"true") {
return true; }
38 if(str ==
"yes") {
return true; }
40 if(str ==
"false") {
return false; }
41 if(str ==
"no") {
return false; }
47 #define SPECIALIZE(TYPE, FUN) \
48 template<> std::optional<TYPE> \
49 locale_parse_generic<TYPE>(const std::string& str) { return FUN(str); }
54 SPECIALIZE(std::string, [](
const std::string& s) {
return s; })
std::optional< bool > locale_parse_bool(const std::string &str)
std::optional< float > locale_parse_float(const std::string &str)
size2f min(const size2f lhs, const size2f rhs)
size2f max(const size2f lhs, const size2f rhs)
std::optional< int > locale_parse_int(const std::string &str)
#define SPECIALIZE(TYPE, FUN)