diff --git a/etk/stdTools.cpp b/etk/stdTools.cpp index 26c97b6..58ab13f 100644 --- a/etk/stdTools.cpp +++ b/etk/stdTools.cpp @@ -274,7 +274,11 @@ namespace etk { } template<> std::string to_string(const int64_t& _val) { char tmpVal[256]; - sprintf(tmpVal, "%ld", _val); + #if (defined(__TARGET_OS__Android)) + sprintf(tmpVal, "%lld", _val); + #else + sprintf(tmpVal, "%ld", _val); + #endif return tmpVal; } template<> std::string to_string(const uint8_t& _val) { @@ -294,7 +298,11 @@ namespace etk { } template<> std::string to_string(const uint64_t& _val) { char tmpVal[256]; - sprintf(tmpVal, "%lu", _val); + #if (defined(__TARGET_OS__Android)) + sprintf(tmpVal, "%llu", _val); + #else + sprintf(tmpVal, "%lu", _val); + #endif return tmpVal; } template<> std::string to_string(const float& _val) { @@ -827,7 +835,11 @@ int32_t etk::string_to_int32_t(const std::string& _str, int _base) { } int64_t etk::string_to_int64_t(const std::string& _str, int _base) { int64_t ret = 0; - sscanf(_str.c_str(), "%ld", &ret); + #if (defined(__TARGET_OS__Android)) + sscanf(_str.c_str(), "%lld", &ret); + #else + sscanf(_str.c_str(), "%ld", &ret); + #endif return ret; } uint8_t etk::string_to_uint8_t(const std::string& _str, int _base) { @@ -846,8 +858,12 @@ uint32_t etk::string_to_uint32_t(const std::string& _str, int _base) { return ret; } uint64_t etk::string_to_uint64_t(const std::string& _str, int _base) { - int64_t ret = 0; - sscanf(_str.c_str(), "%ld", &ret); + uint64_t ret = 0; + #if (defined(__TARGET_OS__Android)) + sscanf(_str.c_str(), "%llu", &ret); + #else + sscanf(_str.c_str(), "%lu", &ret); + #endif return ret; } @@ -1025,3 +1041,93 @@ std::ostream& std::operator <<(std::ostream& _os, const std::vector u32string; #endif + #if (defined(__TARGET_OS__Android)) + //! @previous + std::string to_string(int _val); + //! @previous + std::string to_string(long _val); + //! @previous + std::string to_string(long long _val); + //! @previous + std::string to_string(unsigned _val); + //! @previous + std::string to_string(unsigned long _val); + //! @previous + std::string to_string(unsigned long long _val); + //! @previous + std::string to_string(float _val); + //! @previous + std::string to_string(double _val); + //! @previous + std::string to_string(long double _val); + double stod(const std::string& _str, size_t* _idx = 0); + float stof(const std::string& _str, size_t* _idx = 0); + int stoi(const std::string& _str, size_t* _idx = 0, int _base = 10); + long stol(const std::string& _str, size_t* _idx = 0, int _base = 10); + long double stold(const std::string& _str, size_t* _idx = 0); + long long stoll(const std::string& _str, size_t* _idx = 0, int _base = 10); + unsigned long stoul(const std::string& _str, size_t* _idx = 0, int _base = 10); + unsigned long long stoull(const std::string& _str, size_t* _idx = 0, int _base = 10); + #endif }; namespace etk { // these declaration is to prevent some under template declaration of unknown type