summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..cbabdb8
--- /dev/null
+++ b/util.h
@@ -0,0 +1,35 @@
+#ifndef UTIL_H_INCLUDED
+#define UTIL_H_INCLUDED
+
+#include "debugTimer.h"
+#include <sstream>
+#include <vector>
+
+namespace Util {
+ std::vector<std::string>
+ Split(const std::string & s, char delim)
+ {
+ std::vector<std::string> elems;
+
+ const char * cstr = s.c_str();
+ unsigned int strLength = s.length();
+ unsigned int start = 0;
+ unsigned int end = 0;
+
+ while (end <= strLength) {
+ while (end <= strLength) {
+ if (cstr[end] == delim)
+ break;
+ end++;
+ }
+
+ elems.push_back(s.substr(start, end - start));
+ start = end + 1;
+ end = start;
+ }
+
+ return elems;
+ }
+};
+
+#endif // UTIL_H_INCLUDED