bool operator ()(state_type<BidiIter> &state) const { if(state.bos() && state.flags_.match_bol_) { return true; } BidiIter cur = state.cur_; BidiIter const end = state.end_; std::advance(cur, static_cast<diff_type>(-!state.bos())); for(; cur != end; ++cur) { if(this->bits_[static_cast<unsigned char>(*cur)]) { state.cur_ = ++cur; return true; } } return false; }
bool operator ()(state_type<BidiIter> &state) const { if(state.bos() && state.flags_.match_bol_) { return true; } Traits const &traits = traits_cast<Traits>(state); BidiIter cur = state.cur_; BidiIter const end = state.end_; std::advance(cur, static_cast<diff_type>(-!state.bos())); for(; cur != end; ++cur) { if(traits.isctype(*cur, this->newline_)) { state.cur_ = ++cur; return true; } } return false; }
inline bool regex_search_impl ( state_type<BidiIter> &state , basic_regex<BidiIter> const &re , bool not_initial_null = false ) { typedef core_access<BidiIter> access; typedef typename iterator_value<BidiIter>::type char_type; match_results<BidiIter> &what = *state.context_.results_ptr_; // an invlid regex matches nothing if(!access::invalid(re)) { bool const partial_ok = state.flags_.match_partial_; save_restore<bool> not_null(state.flags_.match_not_null_, state.flags_.match_not_null_ || not_initial_null); state.flags_.match_prev_avail_ = state.flags_.match_prev_avail_ || !state.bos(); regex_impl<BidiIter> const &impl = *access::get_regex_impl(re); BidiIter const begin = state.cur_, end = state.end_; BidiIter &sub0begin = state.sub_match(0).begin_; sub0begin = state.cur_; // If match_continuous is set, we only need to check for a match at the current position if(state.flags_.match_continuous_) { if(access::match(re, state)) { access::set_prefix_suffix(what, begin, end); return true; } // handle partial matches else if(partial_ok && state.found_partial_match_) { state.set_partial_match(); return true; } } // If we have a finder, use it to find where a potential match can start else if(impl.finder_) { finder<BidiIter> const &find = *impl.finder_; if(find(state)) { if(state.cur_ != begin) { not_null.restore(); } do { sub0begin = state.cur_; if(access::match(re, state)) { access::set_prefix_suffix(what, begin, end); return true; } // handle partial matches else if(partial_ok && state.found_partial_match_) { state.set_partial_match(); return true; } BOOST_ASSERT(state.cur_ == sub0begin); not_null.restore(); } while(state.cur_ != state.end_ && (++state.cur_, find(state))); } } // Otherwise, use brute force search at every position. else { for(;;) { if(access::match(re, state)) { access::set_prefix_suffix(what, begin, end); return true; } // handle partial matches else if(partial_ok && state.found_partial_match_) { state.set_partial_match(); return true; } else if(end == sub0begin) { break; } BOOST_ASSERT(state.cur_ == sub0begin); state.cur_ = ++sub0begin; not_null.restore(); } } } access::reset(what); return false; }
static bool match(state_type<BidiIter> &state, Next const &next) { return state.bos() && next.match(state); }