Line data Source code
1 : #include "string.hpp"
2 :
3 : namespace wren::utils {
4 :
5 0 : auto split(const std::string& input, const char c) -> std::vector<std::string> {
6 0 : std::vector<std::string> result;
7 :
8 0 : std::string::size_type pos = 0;
9 0 : std::string::size_type prev = 0;
10 :
11 0 : while ((pos = input.find(c, prev)) != std::string::npos) {
12 0 : result.push_back(input.substr(prev, pos - prev));
13 0 : prev = pos + 1;
14 : }
15 :
16 0 : result.push_back(input.substr(prev));
17 :
18 0 : return result;
19 0 : }
20 :
21 : } // namespace wren::utils
|