diff options
Diffstat (limited to 'louloulibs/utils/split.cpp')
m--------- | louloulibs | 0 | ||||
-rw-r--r-- | louloulibs/utils/split.cpp | 19 |
2 files changed, 19 insertions, 0 deletions
diff --git a/louloulibs b/louloulibs deleted file mode 160000 -Subproject 0f3c1183e2bf0941ae2bffd3f31577bce4f3001 diff --git a/louloulibs/utils/split.cpp b/louloulibs/utils/split.cpp new file mode 100644 index 0000000..80f8dae --- /dev/null +++ b/louloulibs/utils/split.cpp @@ -0,0 +1,19 @@ +#include <utils/split.hpp> +#include <sstream> + +namespace utils +{ + std::vector<std::string> split(const std::string& s, const char delim, const bool allow_empty) + { + std::vector<std::string> ret; + std::stringstream ss(s); + std::string item; + while (std::getline(ss, item, delim)) + { + if (item.empty() && !allow_empty) + continue ; + ret.emplace_back(std::move(item)); + } + return ret; + } +} |