#pragma once #include #include namespace stringUtils { /// /// Case insensitive compare /// /// /// /// inline bool iequals(const std::string& a, const std::string& b) { return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); }); } /// /// left trim white space (\r\n etc) /// /// /// inline std::string_view ltrim(std::string_view s) { s.remove_prefix(std::distance(s.cbegin(), std::find_if(s.cbegin(), s.cend(), [](int c) { return !std::isspace(c); }))); return s; } /// /// Right trim white space (\r\n etc) /// /// /// inline std::string_view rtrim(std::string_view s) { s.remove_suffix(std::distance(s.crbegin(), std::find_if(s.crbegin(), s.crend(), [](int c) { return !std::isspace(c); }))); return s; } /// /// Left Right trim /// /// /// inline std::string_view trim(std::string_view s) { return ltrim(rtrim(s)); } }