diff --git a/common/compat.h b/common/compat.h new file mode 100644 index 00000000..0f1281fe --- /dev/null +++ b/common/compat.h @@ -0,0 +1,46 @@ +#ifndef COMPAT_H +#define COMPAT_H + +#ifdef ANDROID +#define NO_TO_STRING +#define NO_STOUL +#endif + +#include + +#ifdef NO_TO_STRING +#include +#endif + +#ifdef NO_STOUL +#include +#endif + + +namespace cpt +{ + template + static std::string to_string(const T& t) + { + #ifdef NO_TO_STRING + std::stringstream ss; + ss << t; + return ss.str(); + #else + return std::to_string(t); + #endif + } + + static long stoul(const std::string& s) + { + #ifdef NO_STOUL + return atol(s.c_str()); + #else + return std::stoul(s); + #endif + } +} + + +#endif + diff --git a/common/utils.h b/common/utils.h index 5dc34a10..e8e36265 100644 --- a/common/utils.h +++ b/common/utils.h @@ -159,22 +159,6 @@ static std::string getMacAddress(int sock) } -namespace utl -{ - template - static std::string to_string(const T& t) - { - std::stringstream ss; - ss << t; - return ss.str(); - } - - static long stoul(const std::string& s) - { - return atol(s.c_str()); - } -} - #endif