示例#1
0
bool split_pred<OutputIterator, charT, Traits1, Alloc1>::operator()
   (const match_results<iterator_type>& what)
{
   *p_last = what[0].second;
   if(what.size() > 1)
   {
      // output sub-expressions only:
      for(unsigned i = 1; i < what.size(); ++i)
      {
         *(*p_out) = what.str(i);
         ++(*p_out);
         if(0 == --*p_max) return false;
      }
      return *p_max != 0;
   }
   else
   {
      // output $` only if it's not-null or not at the start of the input:
      const sub_match<iterator_type>& sub = what[-1];
      if((sub.first != sub.second) || (*p_max != initial_max))
      {
         *(*p_out) = sub.str();
         ++(*p_out);
         return --*p_max;
      }
   }
   //
   // initial null, do nothing:
   return true;
}
 bool next()
 {
    if(N == -1)
       return false;
    if(N+1 < (int)subs.size())
    {
       ++N;
       result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
       return true;
    }
    //if(what.prefix().first != what[0].second)
    //   flags |= /*match_prev_avail |*/ regex_constants::match_not_bob;
    BidirectionalIterator last_end(what[0].second);
    if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base))
    {
       N =0;
       result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
       return true;
    }
    else if((last_end != end) && (subs[0] == -1))
    {
       N =-1;
       result.first = last_end;
       result.second = end;
       result.matched = (last_end != end);
       return true;
    }
    return false;
 }
 bool next()
 {
     if(what.prefix().first != what[0].second)
         flags |= match_prev_avail;
     BidirectionalIterator next_start = what[0].second;
     match_flag_type f(flags);
     if(!what.length())
         f |= regex_constants::match_not_initial_null;
     bool result = regex_search(next_start, end, what, *pre, f);
     if(result)
         what.set_base(base);
     return result;
 }
 static void init_match_results
 (
     match_results<BidiIter> &what
   , regex_id_type regex_id
   , intrusive_ptr<traits<char_type> const> const &traits
   , sub_match_impl<BidiIter> *sub_matches
   , std::size_t size
   , std::vector<named_mark<char_type> > const &named_marks
 )
 {
     what.init_(regex_id, traits, sub_matches, size, named_marks);
 }
示例#5
0
 bool init(BidirectionalIterator first)
 {
    N = 0;
    if(regex_search(first, end, what, re, flags) == true)
    {
       N = 0;
       result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
       return true;
    }
    else if((subs[N] == -1) && (first != end))
    {
       result.first = first;
       result.second = end;
       result.matched = (first != end);
       return true;
    }
    return false;
 }
示例#6
0
 bool operator ()(match_results<BidiIter> const &res) const
 {
     return this->regex_id_ == res.regex_id();
 }
 static void set_base(match_results<BidiIter> &what, BidiIter base)
 {
     what.set_base_(base);
 }
 static void reset(match_results<BidiIter> &what)
 {
     what.reset_();
 }
 static void set_prefix_suffix(match_results<BidiIter> &what, BidiIter begin, BidiIter end)
 {
     what.set_prefix_suffix_(begin, end);
 }