From be9ccb73bc20b03f62c77f5d529602a10ef4eda9 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 12 Mar 2022 12:09:58 -0500 Subject: player has a sprite now thanks to world of solaria --- src/util.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 150a6a5..1eb2303 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,9 @@ #ifndef UTIL_H_E9110D4C #define UTIL_H_E9110D4C +#include +#include + template void erase_if(Container& items, const Predicate& predicate) { @@ -17,4 +20,36 @@ void erase_if(Container& items, const Predicate& predicate) } }; +template +void splitStr( + std::string input, + std::string delimiter, + OutputIterator out) { + while (!input.empty()) { + int divider = input.find(delimiter); + if (divider == std::string::npos) { + *out = input; + out++; + + input = ""; + } else { + *out = input.substr(0, divider); + out++; + + input = input.substr(divider+delimiter.length()); + } + } +} + +template +Container splitStr( + std::string input, + std::string delimiter) { + Container result; + + splitStr(input, delimiter, std::back_inserter(result)); + + return result; +} + #endif /* end of include guard: UTIL_H_E9110D4C */ -- cgit 1.4.1