| 379 | // ---------------------------------------------------------------------- |
| 380 | template <typename StringType, typename ITR> |
| 381 | static inline |
| 382 | void SplitStringToIteratorUsing(const StringType& full, |
| 383 | const char* delim, |
| 384 | ITR& result) { |
| 385 | // Optimize the common case where delim is a single character. |
| 386 | if (delim[0] != '\0' && delim[1] == '\0') { |
| 387 | char c = delim[0]; |
| 388 | const char* p = full.data(); |
| 389 | const char* end = p + full.size(); |
| 390 | while (p != end) { |
| 391 | if (*p == c) { |
| 392 | ++p; |
| 393 | } else { |
| 394 | const char* start = p; |
| 395 | while (++p != end && *p != c) { |
| 396 | // Skip to the next occurence of the delimiter. |
| 397 | } |
| 398 | *result++ = StringType(start, p - start); |
| 399 | } |
| 400 | } |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | string::size_type begin_index, end_index; |
| 405 | begin_index = full.find_first_not_of(delim); |
| 406 | while (begin_index != string::npos) { |
| 407 | end_index = full.find_first_of(delim, begin_index); |
| 408 | if (end_index == string::npos) { |
| 409 | *result++ = full.substr(begin_index); |
| 410 | return; |
| 411 | } |
| 412 | *result++ = full.substr(begin_index, (end_index - begin_index)); |
| 413 | begin_index = full.find_first_not_of(delim, end_index); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | void SplitStringUsing(const string& full, |
| 418 | const char* delim, |
no test coverage detected