| 77 | } |
| 78 | |
| 79 | std::vector<std::string> Strings::Split(const std::string &str, const char delim) |
| 80 | { |
| 81 | std::vector<std::string> ret; |
| 82 | std::string::size_type start = 0; |
| 83 | auto end = str.find(delim); |
| 84 | while (end != std::string::npos) { |
| 85 | ret.emplace_back(str, start, end - start); |
| 86 | start = end + 1; |
| 87 | end = str.find(delim, start); |
| 88 | } |
| 89 | // this will catch the last word since the string is unlikely to end with a delimiter |
| 90 | if (str.length() > start) { |
| 91 | ret.emplace_back(str, start, str.length() - start); |
| 92 | } |
| 93 | return ret; |
| 94 | } |
| 95 | |
| 96 | // this one takes delimiter length into consideration |
| 97 | std::vector<std::string> Strings::Split(const std::string &s, const std::string &delimiter) |