diff --git a/src/utils/utils.h b/src/utils/utils.h index 9f13365..42115f2 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -19,8 +19,9 @@ #include #include #include -#include "options.h" +#include +#include "options.h" #include "miniz/miniz.h" /** @@ -201,15 +202,22 @@ inline bool parse_boolstring(const std::string &value) { return value == "true"; inline double double_min() { return std::numeric_limits::min(); } -static inline std::string <rim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace)))); - return s; +// trim from start +static inline std::string& ltrim(std::string &s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) + { return !std::isspace(ch); })); + return s; } // trim from end -static inline std::string &rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); - return s; +static inline std::string& rtrim(std::string &s) +{ + s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) + { return !std::isspace(ch); }) + .base(), + s.end()); + return s; } // trim from both ends