36 auto isSep = [](
char ch )->
bool {
return ch ==
' '||
ch ==
'\t'; };
51 std::string_view
word;
56 if ( !
word.empty() ) {
78 if ( !
word.empty() ) {
98 using size_type = std::string_view::size_type;
110 if ( ! fnc_r( trim( line_r.substr(wordstart,searchfrom-wordstart), trim_r ), fncCall,
false ) )
116 searchfrom += sep_r.size();
117 wordstart = searchfrom;
118 }
while( wordstart < line_r.size() );
122 if ( wordstart < line_r.size() )
123 fnc_r(
trim( line_r.substr(wordstart,line_r.size()-wordstart), trim_r ), fncCall,
true );
125 fnc_r( std::string_view( line_r.data()+line_r.size(), 0 ), fncCall,
true );
131 unsigned detail::_splitRx( std::string_view line_r,
const regex & rx_r,
const WordConsumer& fnc_r )
134 bool fncStop =
false;
135 unsigned fncCall = 0;
138 const char *
const eol = line_r.data() + line_r.size();
139 bool trailingNL = line_r.size() && *(eol-1) ==
'\n';
140 const char * wordstart = line_r.data();
141 const char * searchfrom = line_r.data();
144 auto matchAtBOL = [&]() {
145 return searchfrom == line_r.data() || *(searchfrom-1) ==
'\n' ? regex::none : regex::not_bol;
149 if ( fncStop || ! rx_r.matches( searchfrom, match, matchAtBOL() ) ) {
152 if ( trailingNL && searchfrom+match.begin(0) == eol )
155 if ( match.end(0) == 0 && searchfrom == wordstart && searchfrom != line_r.data() ) {
164 if ( ! fnc_r( std::string_view( wordstart, searchfrom+match.begin(0) - wordstart ), fncCall,
false ) )
170 wordstart = searchfrom+match.end(0);
171 searchfrom += match.end(0) ? match.end(0) : 1;
173 }
while ( searchfrom <= eol );
177 if ( wordstart < eol )
178 fnc_r( std::string_view( wordstart, eol-wordstart ), fncCall,
true );
180 fnc_r( std::string_view( eol, 0 ), fncCall,
true );