* @brief split string by char * * @param input * @param c */
| 162 | * @param c |
| 163 | */ |
| 164 | std::vector<std::string> split_by_char(const char *input, const char &c) { |
| 165 | std::vector<std::string> result; |
| 166 | if (!input) return result; // if input is null, return empty vector |
| 167 | |
| 168 | const char *start = input; |
| 169 | const char *current = input; |
| 170 | |
| 171 | while (*current) { |
| 172 | if (*current == c) { |
| 173 | result.emplace_back(start, current - start); |
| 174 | start = current + 1; |
| 175 | } |
| 176 | ++current; |
| 177 | } |
| 178 | |
| 179 | if (current != start) result.emplace_back(start, current - start); |
| 180 | return result; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * |
no test coverage detected