| 265 | |
| 266 | template<typename _SliceVector, typename StringType, typename _DelimType> |
| 267 | void _stringUtilSplitStringToSliceVector( |
| 268 | _SliceVector& ret, const StringType& str, const _DelimType& delims, unsigned int maxSplits) |
| 269 | { |
| 270 | unsigned int numSplits = 0; |
| 271 | |
| 272 | // Use STL methods |
| 273 | size_t start, pos; |
| 274 | start = 0; |
| 275 | |
| 276 | do |
| 277 | { |
| 278 | pos = str.find_first_of(delims, start); |
| 279 | |
| 280 | if (pos == start) |
| 281 | { |
| 282 | ret.push_back(ark::AFSlice()); |
| 283 | start = pos + 1; |
| 284 | } |
| 285 | else if (pos == StringType::npos || (maxSplits && numSplits + 1 == maxSplits)) |
| 286 | { |
| 287 | // Copy the rest of the std::string |
| 288 | ret.push_back(ark::AFSlice(str.data() + start, str.size() - start)); |
| 289 | break; |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | // Copy up to delimiter |
| 294 | // ret.push_back( str.substr( start, pos - start ) ); |
| 295 | ret.push_back(ark::AFSlice(str.data() + start, pos - start)); |
| 296 | start = pos + 1; |
| 297 | } |
| 298 | |
| 299 | ++numSplits; |
| 300 | |
| 301 | } while (pos != StringType::npos); |
| 302 | } |
| 303 | |
| 304 | template<typename StringType, typename _DelimType> |
| 305 | inline void _stringUtilSplitStringToSlice( |