diff --git a/etk/Stream.cpp b/etk/Stream.cpp index 22f0065..db05305 100644 --- a/etk/Stream.cpp +++ b/etk/Stream.cpp @@ -158,6 +158,12 @@ etk::CCout& etk::CCout::operator << (char32_t _t) return *this; } +etk::CCout& etk::CCout::operator << (size_t _t) +{ + snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", (uint64_t)_t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + return *this; +} etk::CCout& etk::CCout::operator << (int8_t _t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t); diff --git a/etk/Stream.h b/etk/Stream.h index 73f82f4..631c2a6 100644 --- a/etk/Stream.h +++ b/etk/Stream.h @@ -31,7 +31,8 @@ namespace etk { public: CCout(void); ~CCout(void); - CCout& operator << (char32_t _t);; + CCout& operator << (char32_t _t); + CCout& operator << (size_t _t); CCout& operator << (int8_t _t); CCout& operator << (int16_t _t); CCout& operator << (int32_t _t); diff --git a/etk/UString.cpp b/etk/UString.cpp index ad722e0..03a0093 100644 --- a/etk/UString.cpp +++ b/etk/UString.cpp @@ -215,7 +215,7 @@ std::string std::to_string(bool _val) { } return "false"; } -#ifdef __TARGET_OS__Android +#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) std::string std::to_string(int _val) { char tmpVal[256]; sprintf(tmpVal, "%d", _val); @@ -253,12 +253,12 @@ std::string std::to_string(bool _val) { } std::string std::to_string(double _val) { char tmpVal[256]; - sprintf(tmpVal, "%d", _val); + sprintf(tmpVal, "%f", _val); return tmpVal; } std::string std::to_string(long double _val) { char tmpVal[256]; - sprintf(tmpVal, "%ld", _val); + sprintf(tmpVal, "%lf", _val); return tmpVal; } #endif @@ -530,10 +530,10 @@ std::vector string_split(const std::string& _input, char _val) { return list; } -#ifdef __TARGET_OS__Android +#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) double std::stod(const std::string& _str, size_t* _idx) { double ret = 0; - sscanf(_str.c_str(), "%lf", &ret); + sscanf(_str.c_str(), "%Lf", &ret); return ret; } @@ -557,7 +557,7 @@ long std::stol(const std::string& _str, size_t* _idx, int _base) { long double std::stold(const std::string& _str, size_t* _idx) { long double ret = 0; - sscanf(_str.c_str(), "%llf", &ret); + sscanf(_str.c_str(), "%Lf", &ret); return ret; } diff --git a/etk/UString.h b/etk/UString.h index 99794ac..4a97628 100644 --- a/etk/UString.h +++ b/etk/UString.h @@ -41,7 +41,7 @@ template std::u32string to_u32string(T t, std::ios_base & (*f)(std::ios } namespace std { std::string to_string(bool _val); - #ifdef __TARGET_OS__Android + #if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) std::string to_string(int _val); std::string to_string(long _val); std::string to_string(long long _val); @@ -65,7 +65,7 @@ std::u32string to_u32string(double _val); std::u32string to_u32string(long double _val); namespace std { - #ifdef __TARGET_OS__Android + #if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) 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); diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp index 445fdfb..3617449 100644 --- a/etk/math/Vector2D.cpp +++ b/etk/math/Vector2D.cpp @@ -74,11 +74,11 @@ namespace etk { m_floats[1] = false; // copy to permit to modify it : std::string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { @@ -98,11 +98,11 @@ namespace etk { m_floats[1] = false; // copy to permit to modify it : std::u32string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { @@ -142,11 +142,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); @@ -167,11 +167,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::u32string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); @@ -214,11 +214,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { @@ -239,11 +239,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::u32string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { @@ -283,11 +283,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { @@ -307,11 +307,11 @@ namespace etk { m_floats[1] = 0; // copy to permit to modify it : std::u32string tmpStr = _str; - if (tmpStr.front() == '(') { + if (tmpStr[0] == '(') { tmpStr.erase(tmpStr.begin()); } - if (tmpStr.back() == ')') { - tmpStr.pop_back(); + if (tmpStr[tmpStr.size()-1] == ')') { + tmpStr.erase(tmpStr.end()-1); } size_t posComa = tmpStr.find(','); if (posComa == std::string::npos) { diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index b4bead2..4557fc7 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -310,7 +310,7 @@ void etk::initDefaultFolder(const char* _applName) { // remove bin/applName baseFolderData = binaryPath; #ifdef __TARGET_OS__MacOs - baseFolderData += "/../../Resources/"; + baseFolderData += "/../Resources/"; #else baseFolderData += "/../share"; baseFolderData += binaryName; @@ -897,7 +897,7 @@ std::string etk::FSNode::getRelativeFolder(void) const { case etk::FSN_UNKNOW: case etk::FSN_FOLDER: case etk::FSN_LINK: - if (tmppp.back() == '/') { + if (tmppp[tmppp.size()-1] == '/') { TK_DBG_MODE(" ==> : " << tmppp ); return tmppp; } else { @@ -988,8 +988,8 @@ uint64_t etk::FSNode::timeCreated(void) const { std::string etk::FSNode::timeCreatedString(void) const { time_t tmpVal = (int32_t)m_timeCreate; std::string tmpTime = ctime(&tmpVal); - if (tmpTime.back() == '\n') { - tmpTime.pop_back(); + if (tmpTime[tmpTime.size()-1] == '\n') { + tmpTime.erase(tmpTime.end()-1); } return tmpTime; } @@ -1004,8 +1004,8 @@ uint64_t etk::FSNode::timeModified(void) const { std::string etk::FSNode::timeModifiedString(void) const { time_t tmpVal = (int32_t)m_timeModify; std::string tmpTime = ctime(&tmpVal); - if (tmpTime.back() == '\n') { - tmpTime.pop_back(); + if (tmpTime[tmpTime.size()-1] == '\n') { + tmpTime.erase(tmpTime.end()-1); } return tmpTime; } @@ -1020,8 +1020,8 @@ uint64_t etk::FSNode::timeAccessed(void) const { std::string etk::FSNode::timeAccessedString(void) const { time_t tmpVal = (int32_t)m_timeAccess; std::string tmpTime = ctime(&tmpVal); - if (tmpTime.back() == '\n') { - tmpTime.pop_back(); + if (tmpTime[tmpTime.size()-1] == '\n') { + tmpTime.erase(tmpTime.end()-1); } return tmpTime; } diff --git a/etk/types.h b/etk/types.h index 5bf49cf..ec8b01d 100644 --- a/etk/types.h +++ b/etk/types.h @@ -8,18 +8,7 @@ #ifndef __ETK_TYPES_H__ #define __ETK_TYPES_H__ -/* -#ifdef __TARGET_OS__Android - // NOTE : This is for compatibility with the C++ stdlib (missing this declaration on android ... - namespace std { - typedef struct { - int dummy; - } mbstate_t; - }; - #include - #include -#endif -*/ + #include #include @@ -58,5 +47,12 @@ #include +#include +#ifdef __TARGET_OS__MacOs + namespace std { + typedef std::basic_string u32string; + }; +#endif + typedef float float_t; #endif