diff options
Diffstat (limited to 'include/mbgl/util/string.hpp')
-rw-r--r-- | include/mbgl/util/string.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp index de061647b5..13498ccb92 100644 --- a/include/mbgl/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -1,9 +1,38 @@ #pragma once +#include <sstream> #include <string> #include <cassert> +#include <cstdlib> #include <exception> +// Polyfill needed by Qt when building for Android with GCC +#if defined(__ANDROID__) && defined(__GLIBCXX__) + +namespace std { + +template <typename T> +std::string to_string(T value) +{ + std::ostringstream oss; + oss << value; + + return oss.str(); +} + +inline int stoi(const std::string &str) +{ + return atoi(str.c_str()); +} + +inline float stof(const std::string &str) { + return static_cast<float>(atof(str.c_str())); +} + +} // namespace std + +#endif + namespace mbgl { namespace util { @@ -40,5 +69,9 @@ inline std::string toString(std::exception_ptr error) { } } +inline float stof(const std::string& str) { + return std::stof(str); +} + } // namespace util } // namespace mbgl |