diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-30 09:59:48 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-30 09:59:48 -0400 |
commit | 3554df2e34e63364eea3a7998e0dfb0e6be65ca4 (patch) | |
tree | e82ccb7eb257adde7d7df2b2295975ed81f137b5 /lib | |
parent | 84bae572d353b03ecb3498df83ba301a456b6c6f (diff) | |
download | verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.gz verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.bz2 verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.zip |
Started migrating to hkutil (does not build)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.h | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/lib/util.h b/lib/util.h deleted file mode 100644 index 9db8678..0000000 --- a/lib/util.h +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | #ifndef UTIL_H_15DDCA2D | ||
2 | #define UTIL_H_15DDCA2D | ||
3 | |||
4 | #include <string> | ||
5 | #include <sstream> | ||
6 | #include <iterator> | ||
7 | |||
8 | namespace verbly { | ||
9 | |||
10 | template <class InputIterator> | ||
11 | std::string implode(InputIterator first, InputIterator last, std::string delimiter) | ||
12 | { | ||
13 | std::stringstream result; | ||
14 | |||
15 | for (InputIterator it = first; it != last; it++) | ||
16 | { | ||
17 | if (it != first) | ||
18 | { | ||
19 | result << delimiter; | ||
20 | } | ||
21 | |||
22 | result << *it; | ||
23 | } | ||
24 | |||
25 | return result.str(); | ||
26 | } | ||
27 | |||
28 | template <class OutputIterator> | ||
29 | void split(std::string input, std::string delimiter, OutputIterator out) | ||
30 | { | ||
31 | while (!input.empty()) | ||
32 | { | ||
33 | int divider = input.find(delimiter); | ||
34 | if (divider == std::string::npos) | ||
35 | { | ||
36 | *out = input; | ||
37 | out++; | ||
38 | |||
39 | input = ""; | ||
40 | } else { | ||
41 | *out = input.substr(0, divider); | ||
42 | out++; | ||
43 | |||
44 | input = input.substr(divider+delimiter.length()); | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | template <class Container> | ||
50 | Container split(std::string input, std::string delimiter) | ||
51 | { | ||
52 | Container result; | ||
53 | |||
54 | split(input, delimiter, std::back_inserter(result)); | ||
55 | |||
56 | return result; | ||
57 | } | ||
58 | |||
59 | }; | ||
60 | |||
61 | #endif /* end of include guard: UTIL_H_15DDCA2D */ | ||