| 278 | } |
| 279 | |
| 280 | std::vector<std::string_view> SplitString(const std::string_view str, char delimiter, bool skip_empty /*= true*/) |
| 281 | { |
| 282 | std::vector<std::string_view> res; |
| 283 | std::string_view::size_type last_pos = 0; |
| 284 | std::string_view::size_type pos; |
| 285 | while (last_pos < str.size() && (pos = str.find(delimiter, last_pos)) != std::string_view::npos) |
| 286 | { |
| 287 | std::string_view part(StripWhitespace(str.substr(last_pos, pos - last_pos))); |
| 288 | if (!skip_empty || !part.empty()) |
| 289 | res.push_back(std::move(part)); |
| 290 | |
| 291 | last_pos = pos + 1; |
| 292 | } |
| 293 | |
| 294 | if (last_pos < str.size()) |
| 295 | { |
| 296 | std::string_view part(StripWhitespace(str.substr(last_pos))); |
| 297 | if (!skip_empty || !part.empty()) |
| 298 | res.push_back(std::move(part)); |
| 299 | } |
| 300 | |
| 301 | return res; |
| 302 | } |
| 303 | |
| 304 | std::string ReplaceAll(const std::string_view subject, const std::string_view search, const std::string_view replacement) |
| 305 | { |
no test coverage detected