Loading base/include/android-base/parsedouble.h +11 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <stdlib.h> #include <limits> #include <string> namespace android { namespace base { Loading Loading @@ -52,6 +53,11 @@ static inline bool ParseDouble(const char* s, double* out, double max = std::numeric_limits<double>::max()) { return ParseFloatingPoint<double, strtod>(s, out, min, max); } static inline bool ParseDouble(const std::string& s, double* out, double min = std::numeric_limits<double>::lowest(), double max = std::numeric_limits<double>::max()) { return ParseFloatingPoint<double, strtod>(s.c_str(), out, min, max); } // Parse float value in the string 's' and sets 'out' to that value if it exists. // Optionally allows the caller to define a 'min' and 'max' beyond which Loading @@ -61,6 +67,11 @@ static inline bool ParseFloat(const char* s, float* out, float max = std::numeric_limits<float>::max()) { return ParseFloatingPoint<float, strtof>(s, out, min, max); } static inline bool ParseFloat(const std::string& s, float* out, float min = std::numeric_limits<float>::lowest(), float max = std::numeric_limits<float>::max()) { return ParseFloatingPoint<float, strtof>(s.c_str(), out, min, max); } } // namespace base } // namespace android Loading
base/include/android-base/parsedouble.h +11 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <stdlib.h> #include <limits> #include <string> namespace android { namespace base { Loading Loading @@ -52,6 +53,11 @@ static inline bool ParseDouble(const char* s, double* out, double max = std::numeric_limits<double>::max()) { return ParseFloatingPoint<double, strtod>(s, out, min, max); } static inline bool ParseDouble(const std::string& s, double* out, double min = std::numeric_limits<double>::lowest(), double max = std::numeric_limits<double>::max()) { return ParseFloatingPoint<double, strtod>(s.c_str(), out, min, max); } // Parse float value in the string 's' and sets 'out' to that value if it exists. // Optionally allows the caller to define a 'min' and 'max' beyond which Loading @@ -61,6 +67,11 @@ static inline bool ParseFloat(const char* s, float* out, float max = std::numeric_limits<float>::max()) { return ParseFloatingPoint<float, strtof>(s, out, min, max); } static inline bool ParseFloat(const std::string& s, float* out, float min = std::numeric_limits<float>::lowest(), float max = std::numeric_limits<float>::max()) { return ParseFloatingPoint<float, strtof>(s.c_str(), out, min, max); } } // namespace base } // namespace android