summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/stringtokenizer.h
Side-by-side diff
Diffstat (limited to 'noncore/games/sfcave-sdl/stringtokenizer.h') (more/less context) (ignore 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 @@
+#ifndef __STRINGTOKENIZER_H
+#define __STRINGTOKENIZER_H
+
+#include <vector>
+using namespace std;
+
+class StringTokenizer : public vector<string>
+{
+ public:
+ StringTokenizer(const string &rStr, const string &rDelimiters = " ,\n")
+ {
+ string::size_type lastPos(rStr.find_first_not_of(rDelimiters, 0));
+ string::size_type pos(rStr.find_first_of(rDelimiters, lastPos));
+ while (string::npos != pos || string::npos != lastPos)
+ {
+ push_back(rStr.substr(lastPos, pos - lastPos));
+ lastPos = rStr.find_first_not_of(rDelimiters, pos);
+ pos = rStr.find_first_of(rDelimiters, lastPos);
+ }
+ }
+};
+
+#endif