| 303 | |
| 304 | template<typename StringType, typename _DelimType> |
| 305 | inline void _stringUtilSplitStringToSlice( |
| 306 | const StringType& str, const _DelimType& delims, ark::AFSlice* ret, size_t& slices_count) |
| 307 | { |
| 308 | unsigned int numSplits = 0; |
| 309 | |
| 310 | // Use STL methods |
| 311 | size_t start, pos; |
| 312 | start = 0; |
| 313 | |
| 314 | do |
| 315 | { |
| 316 | pos = str.find_first_of(delims, start); |
| 317 | |
| 318 | if (pos == start) |
| 319 | { |
| 320 | ret[numSplits++] = ark::AFSlice(); |
| 321 | start = pos + 1; |
| 322 | } |
| 323 | else if (pos == StringType::npos || ((numSplits + 1) == slices_count)) |
| 324 | { |
| 325 | // Copy the rest of the std::string |
| 326 | ret[numSplits++] = (ark::AFSlice(str.data() + start, str.size() - start)); |
| 327 | break; |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | // Copy up to delimiter |
| 332 | // ret.push_back( str.substr( start, pos - start ) ); |
| 333 | ret[numSplits++] = (ark::AFSlice(str.data() + start, pos - start)); |
| 334 | start = pos + 1; |
| 335 | } |
| 336 | } while (pos != StringType::npos); |
| 337 | |
| 338 | slices_count = numSplits; |
| 339 | } |
| 340 | |
| 341 | inline void _stringUtilSplitSliceToSlice( |
| 342 | const ark::AFSlice& str, const char& delim, std::vector<ark::AFSlice>& ret, unsigned int maxSplits) |