#include #include #include #include using std::string; namespace Feather::StringUtil { bool iequalc(char c1, char c2); // case insensitive string equal static inline bool iequal(string const& s1, string const& s2) { return s1.size() == s2.size() && std::equal(s1.begin(), s1.end(), s2.begin(), iequalc); } // trim from start (in place) static inline void ltrim(string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); })); } // trim from end (in place) static inline void rtrim(string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end()); } // trim from both ends (in place) static inline void trim(string &s) { ltrim(s); rtrim(s); } // trim from start (copying) static inline string ltrim_copy(string s) { ltrim(s); return s; } // trim from end (copying) static inline string rtrim_copy(string s) { rtrim(s); return s; } // trim from both ends (copying) static inline string trim_copy(string s) { trim(s); return s; } }