| 718 | } |
| 719 | |
| 720 | std::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 | |
| 749 | std::vector<std::string> String::split( const std::string& str, const Int8& delim, |
| 750 | const bool& pushEmptyString, const bool& keepDelim ) { |
no test coverage detected