diff options
Diffstat (limited to 'src/utils/split.hpp')
-rw-r--r-- | src/utils/split.hpp | 21 |
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 |