summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/stringtokenizer.h
Unidiff
Diffstat (limited to 'noncore/games/sfcave-sdl/stringtokenizer.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/stringtokenizer.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/games/sfcave-sdl/stringtokenizer.h b/noncore/games/sfcave-sdl/stringtokenizer.h
new file mode 100644
index 0000000..3f299a6
--- a/dev/null
+++ b/noncore/games/sfcave-sdl/stringtokenizer.h
@@ -0,0 +1,23 @@
1#ifndef __STRINGTOKENIZER_H
2#define __STRINGTOKENIZER_H
3
4#include <vector>
5using namespace std;
6
7class StringTokenizer : public vector<string>
8{
9 public:
10 StringTokenizer(const string &rStr, const string &rDelimiters = " ,\n")
11 {
12 string::size_type lastPos(rStr.find_first_not_of(rDelimiters, 0));
13 string::size_type pos(rStr.find_first_of(rDelimiters, lastPos));
14 while (string::npos != pos || string::npos != lastPos)
15 {
16 push_back(rStr.substr(lastPos, pos - lastPos));
17 lastPos = rStr.find_first_not_of(rDelimiters, pos);
18 pos = rStr.find_first_of(rDelimiters, lastPos);
19 }
20 }
21};
22
23#endif