This commit is contained in:
Green Sky 2022-03-10 15:51:42 +01:00
parent 0408f771b7
commit 8f44e09f32

View File

@ -1,9 +1,30 @@
#pragma once
#include <string_view>
#include <cctype>
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<std::string_view> split(std::string_view str, const char* delims) {
std::vector<std::string_view> ret;