| 63 | } |
| 64 | |
| 65 | std::vector<std::string> Split(std::string_view in, std::string_view delim) { |
| 66 | std::vector<std::string> out; |
| 67 | |
| 68 | if (in.empty()) { |
| 69 | return out; |
| 70 | } |
| 71 | |
| 72 | if (delim.empty()) { |
| 73 | out.resize(in.size()); |
| 74 | std::transform(in.begin(), in.end(), out.begin(), [](char c) -> std::string { return {c}; }); |
| 75 | return out; |
| 76 | } |
| 77 | |
| 78 | size_t begin = 0, end = in.find_first_of(delim); |
| 79 | do { |
| 80 | std::string_view elem = in.substr(begin, end - begin); |
| 81 | if (!elem.empty()) out.emplace_back(elem.begin(), elem.end()); |
| 82 | if (end == std::string::npos) break; |
| 83 | begin = end + 1; |
| 84 | end = in.find_first_of(delim, begin); |
| 85 | } while (true); |
| 86 | |
| 87 | return out; |
| 88 | } |
| 89 | |
| 90 | std::vector<std::string> Split2KV(const std::string &in, const std::string &delim) { |
| 91 | std::vector<std::string> out; |