diff --git a/framework/std_utils/src/mm/string_view_split.hpp b/framework/std_utils/src/mm/string_view_split.hpp index c7ff40d..d21bc02 100644 --- a/framework/std_utils/src/mm/string_view_split.hpp +++ b/framework/std_utils/src/mm/string_view_split.hpp @@ -1,9 +1,30 @@ #pragma once #include +#include namespace MM::std_utils { +inline std::string_view trim_prefix(std::string_view sv) { + while (!sv.empty() && std::isspace(sv.front())) { + sv.remove_prefix(1); + } + + return sv; +} + +inline std::string_view trim_suffix(std::string_view sv) { + while (!sv.empty() && std::isspace(sv.back())) { + sv.remove_suffix(1); + } + + return sv; +} + +inline std::string_view trim(std::string_view sv) { + return trim_suffix(trim_prefix(sv)); +} + // src : https://marcoarena.wordpress.com/2017/01/03/string_view-odi-et-amo/ inline std::vector split(std::string_view str, const char* delims) { std::vector ret;