9 #ifndef MARIADBCLIENTPP_CONVERSION_HELPER_H 10 #define MARIADBCLIENTPP_CONVERSION_HELPER_H 20 template <
typename T,
typename K>
22 if (value < std::numeric_limits<T>::lowest() || value > std::numeric_limits<T>::max())
return T();
24 return static_cast<T
>(value);
30 int parsedNumber = std::stoi(str, &endPos);
32 if (endPos != str.size())
return T();
40 unsigned long parsedNumber = std::stoul(str, &endPos);
42 if (endPos != str.size())
return 0;
57 unsigned long long parsedNumber = std::stoull(str, &endPos);
59 if (endPos != str.size())
return 0;
67 long long parsedNumber = std::stoll(str, &endPos);
69 if (endPos != str.size())
return 0;
78 double parsedNumber = std::stod(str, &endPos);
80 if (endPos != str.size())
return 0;
83 }
catch (std::out_of_range &) {
85 return std::numeric_limits<double>::quiet_NaN();
93 float parsedNumber = std::stof(str, &endPos);
95 if (endPos != str.size())
return 0;
98 }
catch (std::out_of_range &) {
100 return std::numeric_limits<float>::quiet_NaN();
104 #endif // MARIADBCLIENTPP_CONVERSION_HELPER_H
T string_cast(const std::string &str)