MCPcopy Create free account
hub / github.com/chen3feng/toft / DoSplitLines

Function DoSplitLines

base/string/algorithm.cpp:413–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411
412template <typename StringType>
413void DoSplitLines(
414 const StringPiece& full,
415 std::vector<StringType>* result,
416 bool keep_line_endling
417)
418{
419 result->clear();
420 size_t prev_pos = 0;
421 size_t pos;
422 StringType token;
423 while ((pos = full.find('\n', prev_pos)) != std::string::npos)
424 {
425 token.assign(full.data() + prev_pos, pos - prev_pos + 1);
426 if (!keep_line_endling)
427 RemoveLineEnding(&token);
428 result->push_back(token);
429 prev_pos = pos + 1;
430 }
431 if (prev_pos < full.size())
432 {
433 token.assign(full.data() + prev_pos, full.length() - prev_pos);
434 if (!keep_line_endling)
435 RemoveLineEnding(&token);
436 result->push_back(token);
437 }
438}
439
440void SplitLines(
441 const StringPiece& full,

Callers 1

SplitLinesFunction · 0.85

Calls 8

RemoveLineEndingFunction · 0.85
findMethod · 0.80
assignMethod · 0.80
dataMethod · 0.80
push_backMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected