| 26 | } |
| 27 | |
| 28 | std::vector<std::string> utils::splitString(const std::string &str, const std::string &splits) { |
| 29 | std::vector<std::string> res; |
| 30 | if (str.empty()) { |
| 31 | return res; |
| 32 | } |
| 33 | std::string strs = str + splits; |
| 34 | size_t pos = strs.find(splits); |
| 35 | size_t step = splits.size(); |
| 36 | while (pos != std::string::npos) { |
| 37 | std::string temp = strs.substr(0, pos); |
| 38 | res.push_back(temp); |
| 39 | strs = strs.substr(pos + step, strs.size()); |
| 40 | pos = strs.find(splits); |
| 41 | } |
| 42 | return res; |
| 43 | } |