diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-01-30 13:01:01 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-01-30 13:01:01 -0500 |
| commit | f3166702d7dd30312b5a401f52941aad43ac51c3 (patch) | |
| tree | 08f15a0fde9ee7be08c9b4fe510dfa6ed04d4a78 /src/util.h | |
| parent | 763bd80603dbace9f14c25309159ed07ec6e9a93 (diff) | |
| download | tanetane-f3166702d7dd30312b5a401f52941aad43ac51c3.tar.gz tanetane-f3166702d7dd30312b5a401f52941aad43ac51c3.tar.bz2 tanetane-f3166702d7dd30312b5a401f52941aad43ac51c3.zip | |
Added standing/walking animations
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 39 |
1 files changed, 39 insertions, 0 deletions
| diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..8cdad3d --- /dev/null +++ b/src/util.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #ifndef UTIL_H_4AC35025 | ||
| 2 | #define UTIL_H_4AC35025 | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | #include <iterator> | ||
| 6 | |||
| 7 | template <class OutputIterator> | ||
| 8 | void splitStr( | ||
| 9 | std::string input, | ||
| 10 | std::string delimiter, | ||
| 11 | OutputIterator out) { | ||
| 12 | while (!input.empty()) { | ||
| 13 | int divider = input.find(delimiter); | ||
| 14 | if (divider == std::string::npos) { | ||
| 15 | *out = input; | ||
| 16 | out++; | ||
| 17 | |||
| 18 | input = ""; | ||
| 19 | } else { | ||
| 20 | *out = input.substr(0, divider); | ||
| 21 | out++; | ||
| 22 | |||
| 23 | input = input.substr(divider+delimiter.length()); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | template <class Container> | ||
| 29 | Container splitStr( | ||
| 30 | std::string input, | ||
| 31 | std::string delimiter) { | ||
| 32 | Container result; | ||
| 33 | |||
| 34 | splitStr(input, delimiter, std::back_inserter(result)); | ||
| 35 | |||
| 36 | return result; | ||
| 37 | } | ||
| 38 | |||
| 39 | #endif /* end of include guard: UTIL_H_4AC35025 */ | ||
