summary refs log tree commit diff stats
path: root/lib/util.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-30 09:59:48 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-30 09:59:48 -0400
commit3554df2e34e63364eea3a7998e0dfb0e6be65ca4 (patch)
treee82ccb7eb257adde7d7df2b2295975ed81f137b5 /lib/util.h
parent84bae572d353b03ecb3498df83ba301a456b6c6f (diff)
downloadverbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.gz
verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.tar.bz2
verbly-3554df2e34e63364eea3a7998e0dfb0e6be65ca4.zip
Started migrating to hkutil (does not build)
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h61
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
8namespace 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 */