| 30 | } |
| 31 | |
| 32 | void split(const std::string& input, const std::string& delimiter, std::function<void(const std::string&)> callback) { |
| 33 | size_t token_index = 0; |
| 34 | size_t delimiter_index; |
| 35 | const size_t delimiter_length = delimiter.length(); |
| 36 | |
| 37 | while ((delimiter_index = input.find(delimiter, token_index)) != std::string::npos) { |
| 38 | std::string token = input.substr(token_index, delimiter_index - token_index); |
| 39 | token_index = delimiter_index + delimiter_length; |
| 40 | callback(token); |
| 41 | } |
| 42 | |
| 43 | auto end_token = input.substr(token_index); |
| 44 | if (!end_token.empty()) { |
| 45 | callback(end_token); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | std::vector<std::string> split(const std::string&input, const std::string&delimiter) { |
| 50 | std::vector<std::string> result; |
no outgoing calls
no test coverage detected