diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-16 22:57:15 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-03-16 22:57:15 -0400 |
commit | 29c6d78edb88a38c2bfde54fc7ecccc691bbef30 (patch) | |
tree | 21d458d02337420dfb1fd5eda4cffada38f9642a /verbly/lib/util.h | |
parent | 8b1333d0e6e2b9a5014bdbff2987d899f5413fee (diff) | |
download | furries-29c6d78edb88a38c2bfde54fc7ecccc691bbef30.tar.gz furries-29c6d78edb88a38c2bfde54fc7ecccc691bbef30.tar.bz2 furries-29c6d78edb88a38c2bfde54fc7ecccc691bbef30.zip |
Added verbly submodule
Diffstat (limited to 'verbly/lib/util.h')
-rw-r--r-- | verbly/lib/util.h | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/verbly/lib/util.h b/verbly/lib/util.h deleted file mode 100644 index 815b47c..0000000 --- a/verbly/lib/util.h +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | #ifndef UTIL_H_15DDCA2D | ||
2 | #define UTIL_H_15DDCA2D | ||
3 | |||
4 | #include <string> | ||
5 | #include <iterator> | ||
6 | #include <sstream> | ||
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 Container> | ||
29 | Container split(std::string input, std::string delimiter) | ||
30 | { | ||
31 | Container result; | ||
32 | |||
33 | while (!input.empty()) | ||
34 | { | ||
35 | int divider = input.find(" "); | ||
36 | if (divider == std::string::npos) | ||
37 | { | ||
38 | result.push_back(input); | ||
39 | |||
40 | input = ""; | ||
41 | } else { | ||
42 | result.push_back(input.substr(0, divider)); | ||
43 | |||
44 | input = input.substr(divider+1); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | return result; | ||
49 | } | ||
50 | |||
51 | }; | ||
52 | |||
53 | #endif /* end of include guard: UTIL_H_15DDCA2D */ | ||