X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/46b0747592074017ff0ea4b33d4a7194235886e5..1e8eb98d30459399902534082c88b94bb26bb2e3:/libs/common/include/stg/common.h diff --git a/libs/common/include/stg/common.h b/libs/common/include/stg/common.h index 94cf9f06..ca8c3b45 100644 --- a/libs/common/include/stg/common.h +++ b/libs/common/include/stg/common.h @@ -171,22 +171,9 @@ int str2x(const std::string & str, int64_t & x); int str2x(const std::string & str, uint64_t & x); #endif //----------------------------------------------------------------------------- -const std::string & x2str(uint32_t x, std::string & s); -const std::string & x2str(uint64_t x, std::string & s); -//----------------------------------------------------------------------------- -const std::string & x2str(double x, std::string & s); -//----------------------------------------------------------------------------- template int str2x(const std::string & str, varT & x); -template -const std::string & x2str(varT x, std::string & s); -template -std::string x2str(varT x) { std::string s; return x2str(x, s); } -template -const std::string & unsigned2str(varT x, std::string & s); -template -std::string unsigned2str(varT x) { std::string s; return unsigned2str(x, s); } //----------------------------------------------------------------------------- template @@ -227,89 +214,6 @@ int str2x(const std::string & str, varT & x) return 0; } //----------------------------------------------------------------------------- -template -inline -const std::string & x2str(varT x, std::string & s) -{ - varT xx = x; - int pos = 1; - - x /= 10; - while (x != 0) - { - x /= 10; - pos++; - } - - if (xx < 0) - { - pos++; - s.resize(pos, 0); - s[0] = '-'; - } - else if (xx > 0) - { - s.resize(pos, 0); - } - else - { - s.resize(1, 0); - s[0] = '0'; - return s; - } - - x = xx; - - while (x != 0) - { - if (x < 0) - s[--pos] = -(x % 10) + '0'; - else - s[--pos] = x % 10 + '0'; - - x /= 10; - } - - return s; -} -//----------------------------------------------------------------------------- -template -inline -const std::string & unsigned2str(varT x, std::string & s) -{ - varT xx = x; - int pos = 1; - - x /= 10; - while (x != 0) - { - x /= 10; - pos++; - } - - if (xx > 0) - { - s.resize(pos, 0); - } - else - { - s.resize(1, 0); - s[0] = '0'; - return s; - } - - x = xx; - - while (x != 0) - { - s[--pos] = x % 10 + '0'; - - x /= 10; - } - - return s; -} -//----------------------------------------------------------------------------- char * stg_strptime(const char *, const char *, struct tm *); time_t stg_timegm(struct tm *);