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

Function _stringUtilSplitStringToSliceVector

src/base/AFStringUtils.hpp:267–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265
266template<typename _SliceVector, typename StringType, typename _DelimType>
267void _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
304template<typename StringType, typename _DelimType>
305inline void _stringUtilSplitStringToSlice(

Callers 1

SplitMethod · 0.85

Calls 4

AFSliceClass · 0.85
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected