| 227 | |
| 228 | template <typename StringType, typename ITR> |
| 229 | static inline |
| 230 | void SplitStringToIteratorUsing(const StringPiece& full, const char* delim, ITR& result) |
| 231 | { |
| 232 | // Optimize the common case where delim is a single character. |
| 233 | if (delim[0] != '\0' && delim[1] == '\0') |
| 234 | { |
| 235 | char c = delim[0]; |
| 236 | const char* p = full.data(); |
| 237 | const char* end = p + full.size(); |
| 238 | while (p != end) |
| 239 | { |
| 240 | if (*p == c) |
| 241 | ++p; |
| 242 | else |
| 243 | { |
| 244 | const char* start = p; |
| 245 | while (++p != end && *p != c) {} |
| 246 | *result++ = StringType(start, p - start); |
| 247 | } |
| 248 | } |
| 249 | return; |
| 250 | } |
| 251 | |
| 252 | std::string::size_type begin_index, end_index; |
| 253 | begin_index = full.find_first_not_of(delim); |
| 254 | while (begin_index != std::string::npos) |
| 255 | { |
| 256 | end_index = full.find_first_of(delim, begin_index); |
| 257 | if (end_index == std::string::npos) |
| 258 | { |
| 259 | *result++ = full.substr(begin_index).as_string(); |
| 260 | return; |
| 261 | } |
| 262 | *result++ = full.substr(begin_index, (end_index - begin_index)).as_string(); |
| 263 | begin_index = full.find_first_not_of(delim, end_index); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Split a string using a character delimiter. |
| 268 | void SplitStringByAnyOf( |
nothing calls this directly
no test coverage detected