Use internal string trim functions instead of boost algorithm

This commit is contained in:
Joakim Hove
2020-02-13 09:18:39 +01:00
parent 9ac9e53d68
commit 36662b2734
5 changed files with 54 additions and 6 deletions

View File

@@ -20,9 +20,21 @@ typename std::decay< T >::type uppercase( T&& x ) {
return uppercase( t, t );
}
template<typename T>
std::string ltrim_copy(const T& s)
{
auto ret = std::string(s.c_str());
const auto start = ret.find_first_not_of(" \t\n\r\f\v");
if (start == std::string::npos)
return "";
return ret.substr(start);
}
template<typename T>
std::string trim_copy(const T& s) {
std::string rtrim_copy(const T& s)
{
auto ret = std::string(s.c_str());
@@ -32,6 +44,11 @@ std::string trim_copy(const T& s) {
return ret.substr(0, end + 1);
}
template<typename T>
std::string trim_copy(const T& s)
{
return ltrim_copy( rtrim_copy(s) );
}
}
#endif //OPM_UTILITY_STRING_HPP