MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / _stringUtilSplitStringToSlice

Function _stringUtilSplitStringToSlice

src/base/AFStringUtils.hpp:305–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303
304template<typename StringType, typename _DelimType>
305inline 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
341inline void _stringUtilSplitSliceToSlice(
342 const ark::AFSlice& str, const char& delim, std::vector<ark::AFSlice>& ret, unsigned int maxSplits)

Callers 1

SplitMethod · 0.85

Calls 3

AFSliceClass · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected