CLI #25

Merged
crtxcr merged 5 commits from WIP/cli into master 2021-10-03 17:06:32 +02:00
2 changed files with 19 additions and 0 deletions
Showing only changes of commit 5037a17fba - Show all commits

View File

@ -181,3 +181,20 @@ std::string utils::toISODate(time_t t)
}
return std::string{result};
}
std::string utils::trim(const std::string &str)
{
std::string_view chars = " \t\n\r";
std::string_view view = str;
auto n = view.find_first_not_of(chars);
if(n != std::string_view::npos)
{
view.remove_prefix(n);
}
n = view.find_last_not_of(chars);
if(n != std::string_view::npos)
{
view.remove_suffix(view.size() - n - 1);
}
return std::string{view};
}

View File

@ -93,5 +93,7 @@ template <class T> inline std::string toString(const T &v)
return std::string(v.begin(), v.end());
}
std::string trim(const std::string &str);
} // namespace utils
#endif