MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / splitString

Method splitString

src/helper.cpp:554–567  ·  view source on GitHub ↗

https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string/236803#236803 */

Source from the content-addressed store, hash-verified

552 https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string/236803#236803
553 */
554std::vector<std::string> Helper::splitString(std::string sep, std::string str, size_t maxSplits) {
555 std::vector<std::string> tokens;
556 std::size_t start = 0;
557 std::size_t end = 0;
558 std::size_t splitLen = sep.size();
559 while( (end = str.find(sep, start)) != std::string::npos ) {
560 tokens.push_back( str.substr(start, end - start) );
561 start = end + splitLen;
562 if( maxSplits > 0 && tokens.size() == maxSplits )
563 break;
564 }
565 tokens.push_back(str.substr(start));
566 return tokens;
567}
568
569
570/**

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected