summaryrefslogtreecommitdiff
path: root/src/utils/split.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-06 20:56:59 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-06 21:01:18 +0100
commit4b76a30d0479f366374c7dcf99ac211038722503 (patch)
tree39845f3b8617d095fc047da00b564e60b8cbbe19 /src/utils/split.hpp
parentbf7b05ef72bbdac97704d262ddfe418908267535 (diff)
downloadbiboumi-4b76a30d0479f366374c7dcf99ac211038722503.tar.gz
biboumi-4b76a30d0479f366374c7dcf99ac211038722503.tar.bz2
biboumi-4b76a30d0479f366374c7dcf99ac211038722503.tar.xz
biboumi-4b76a30d0479f366374c7dcf99ac211038722503.zip
Add make_unique.hpp and split.hpp
Diffstat (limited to 'src/utils/split.hpp')
-rw-r--r--src/utils/split.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/split.hpp b/src/utils/split.hpp
new file mode 100644
index 0000000..0067131
--- /dev/null
+++ b/src/utils/split.hpp
@@ -0,0 +1,21 @@
+#ifndef SPLIT_INCLUDED
+# define SPLIT_INCLUDED
+
+#include <string>
+#include <sstream>
+#include <vector>
+
+namespace utils
+{
+ std::vector<std::string> split(const std::string &s, const char delim)
+ {
+ std::vector<std::string> ret;
+ std::stringstream ss(s);
+ std::string item;
+ while (std::getline(ss, item, delim))
+ ret.emplace_back(std::move(item));
+ return ret;
+ }
+}
+
+#endif // SPLIT_INCLUDED