diff --git a/libs/util/include/psemek/util/to_string.hpp b/libs/util/include/psemek/util/to_string.hpp index 2e8a1161..7b3eec7d 100644 --- a/libs/util/include/psemek/util/to_string.hpp +++ b/libs/util/include/psemek/util/to_string.hpp @@ -4,6 +4,7 @@ #include #include +#include namespace psemek::util { @@ -54,4 +55,27 @@ namespace psemek::util return from_string>(s); } + inline std::vector split(std::string const & str, char delim) + { + std::vector result; + + for (std::size_t pos = 0;;) + { + auto next = str.find(delim, pos); + + if (next == std::string::npos) + { + result.push_back(str.substr(pos)); + break; + } + else + { + result.push_back(str.substr(pos, next - pos)); + pos = next + 1; + } + } + + return result; + } + }