summary refs log tree commit diff stats
path: root/src/util.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
commitbe9ccb73bc20b03f62c77f5d529602a10ef4eda9 (patch)
tree6f88a9b780a75e52b2f04b6f61167f4ef46590a7 /src/util.h
parentc1a88a064a0cddbc1df2e716ef2102d22bbf681b (diff)
downloadether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.gz
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.bz2
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.zip
player has a sprite now thanks to world of solaria
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h35
1 files changed, 35 insertions, 0 deletions
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 @@
1#ifndef UTIL_H_E9110D4C 1#ifndef UTIL_H_E9110D4C
2#define UTIL_H_E9110D4C 2#define UTIL_H_E9110D4C
3 3
4#include <string>
5#include <iterator>
6
4template <typename Container, typename Predicate> 7template <typename Container, typename Predicate>
5void erase_if(Container& items, const Predicate& predicate) 8void erase_if(Container& items, const Predicate& predicate)
6{ 9{
@@ -17,4 +20,36 @@ void erase_if(Container& items, const Predicate& predicate)
17 } 20 }
18}; 21};
19 22
23template <class OutputIterator>
24void splitStr(
25 std::string input,
26 std::string delimiter,
27 OutputIterator out) {
28 while (!input.empty()) {
29 int divider = input.find(delimiter);
30 if (divider == std::string::npos) {
31 *out = input;
32 out++;
33
34 input = "";
35 } else {
36 *out = input.substr(0, divider);
37 out++;
38
39 input = input.substr(divider+delimiter.length());
40 }
41 }
42}
43
44template <class Container>
45Container splitStr(
46 std::string input,
47 std::string delimiter) {
48 Container result;
49
50 splitStr(input, delimiter, std::back_inserter(result));
51
52 return result;
53}
54
20#endif /* end of include guard: UTIL_H_E9110D4C */ 55#endif /* end of include guard: UTIL_H_E9110D4C */