diff --git a/src/util/string.h b/src/util/string.h index 8b0848f8e..24fa3d293 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -300,6 +300,36 @@ inline std::vector > str_split( return parts; } +/** + * Splits a string_view into its component parts separated by the character + * \p delimiter. + * + * @return An std::vector > of the component parts + */ +template +inline std::vector > str_split( + const std::basic_string_view &strv, + T delimiter) +{ + std::vector> output; + size_t first = 0; + + while (first < strv.size()) + { + const auto second = strv.find_first_of(delimiter, first); + + if (first != second) + output.push_back(strv.substr(first, second - first)); + + if (second == std::string_view::npos) + break; + + first = second + 1; + } + + return output; +} + /** * @param str