MCPcopy Create free account
hub / github.com/SpartanJ/eepp / split

Method split

src/eepp/core/string.cpp:720–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720std::vector<String> String::split( const String& str, const StringBaseType& delim,
721 const bool& pushEmptyString, const bool& keepDelim ) {
722 if ( str.empty() )
723 return {};
724 std::vector<String> cont;
725 std::size_t current, previous = 0;
726 current = str.find( delim );
727 while ( current != String::InvalidPos ) {
728 String substr( str.substr( previous, current - previous ) );
729 if ( pushEmptyString || !substr.empty() )
730 cont.emplace_back( std::move( substr ) );
731 previous = current + 1;
732 current = str.find( delim, previous );
733 }
734 String substr( str.substr( previous, current - previous ) );
735 if ( pushEmptyString || !substr.empty() )
736 cont.emplace_back( std::move( substr ) );
737 if ( keepDelim ) {
738 for ( size_t i = 0; i < cont.size(); i++ ) {
739 if ( i != cont.size() - 1 ||
740 ( str.lastChar() == delim && cont[cont.size() - 1].lastChar() != delim ) )
741 cont[i].push_back( delim );
742 if ( cont[cont.size() - 1].empty() )
743 cont.pop_back();
744 }
745 }
746 return cont;
747}
748
749std::vector<std::string> String::split( const std::string& str, const Int8& delim,
750 const bool& pushEmptyString, const bool& keepDelim ) {

Callers 6

UniversalLocatorMethod · 0.45
onCodeEditorCreatedMethod · 0.45
loadDocumentsMethod · 0.45
parseGlobMatchesMethod · 0.45

Calls 9

substrMethod · 0.80
lastCharMethod · 0.80
push_backMethod · 0.80
pop_backMethod · 0.80
find_first_ofMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected