コード例 #1
0
ファイル: regex_split.hpp プロジェクト: 13W/icq-desktop
std::size_t regex_split(OutputIterator out,
                   std::basic_string<charT, Traits1, Alloc1>& s, 
                   const basic_regex<charT, Traits2>& e,
                   match_flag_type flags,
                   std::size_t max_split)
{
   typedef typename std::basic_string<charT, Traits1, Alloc1>::const_iterator  ci_t;
   //typedef typename match_results<ci_t>::allocator_type                        match_allocator;
   ci_t last = s.begin();
   std::size_t init_size = max_split;
   re_detail::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split);
   ci_t i, j;
   i = s.begin();
   j = s.end();
   regex_grep(pred, i, j, e, flags);
   //
   // if there is still input left, do a final push as long as max_split
   // is not exhausted, and we're not splitting sub-expressions rather 
   // than whitespace:
   if(max_split && (last != s.end()) && (e.mark_count() == 0))
   {
      *out = std::basic_string<charT, Traits1, Alloc1>((ci_t)last, (ci_t)s.end());
      ++out;
      last = s.end();
      --max_split;
   }
   //
   // delete from the string everything that has been processed so far:
   s.erase(0, last - s.begin());
   //
   // return the number of new records pushed:
   return init_size - max_split;
}
コード例 #2
0
 perl_matcher(BidiIterator first, BidiIterator end, 
    match_results<BidiIterator, Allocator>& what, 
    const basic_regex<char_type, traits>& e,
    match_flag_type f,
    BidiIterator l_base)
    :  m_result(what), base(first), last(end), 
       position(first), backstop(l_base), re(e), traits_inst(e.get_traits()), 
       m_independent(false), next_count(&rep_obj), rep_obj(&next_count)
 {
    construct_init(e, f);
 }
コード例 #3
0
ファイル: regex_search.hpp プロジェクト: 1234-/passenger
bool regex_search(BidiIterator first, BidiIterator last, 
                  match_results<BidiIterator, Allocator>& m, 
                  const basic_regex<charT, traits>& e, 
                  match_flag_type flags,
                  BidiIterator base)
{
   if(e.flags() & regex_constants::failbit)
      return false;

   BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base);
   return matcher.find();
}
コード例 #4
0
ファイル: regex_search.hpp プロジェクト: 1234-/passenger
bool regex_search(BidiIterator first, BidiIterator last, 
                  const basic_regex<charT, traits>& e, 
                  match_flag_type flags = match_default)
{
   if(e.flags() & regex_constants::failbit)
      return false;

   match_results<BidiIterator> m;
   typedef typename match_results<BidiIterator>::allocator_type match_alloc_type;
   BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, match_alloc_type, traits> matcher(first, last, m, e, flags | regex_constants::match_any, first);
   return matcher.find();
}
コード例 #5
0
 /// \param begin The beginning of the character range to search.
 /// \param end The end of the character range to search.
 /// \param rex The regex pattern to search for.
 /// \pre \c [begin,end) is a valid range.
 regex_token_iterator
 (
     BidiIter begin
   , BidiIter end
   , basic_regex<BidiIter> const &rex
 )
   : impl_()
 {
     if(0 != rex.regex_id())
     {
         this->impl_ = new impl_type_(begin, begin, end, begin, rex);
         this->next_();
     }
 }
コード例 #6
0
 regex_token_iterator
 (
     BidiIter begin
   , BidiIter end
   , basic_regex<BidiIter> const &rex
   , Subs const &subs
   , regex_constants::match_flag_type flags = regex_constants::match_default
 )
   : impl_()
 {
     if(0 != rex.regex_id())
     {
         this->impl_ = new impl_type_(begin, begin, end, begin, rex, flags, detail::to_vector(subs));
         this->next_();
     }
 }
コード例 #7
0
 regex_token_iterator
 (
     BidiIter begin
   , BidiIter end
   , basic_regex<BidiIter> const &rex
   , detail::let_<LetExpr> const &args
 )
   : impl_()
 {
     if(0 != rex.regex_id())
     {
         this->impl_ = new impl_type_(begin, begin, end, begin, rex);
         detail::bind_args(args, this->impl_->iter_.what_);
         this->next_();
     }
 }
コード例 #8
0
ファイル: regex_grep.hpp プロジェクト: AsherBond/PDAL
inline unsigned int regex_grep(Predicate foo, 
                               BidiIterator first, 
                               BidiIterator last, 
                               const basic_regex<charT, traits>& e, 
                               match_flag_type flags = match_default)
{
   if(e.flags() & regex_constants::failbit)
      return false;

   typedef typename match_results<BidiIterator>::allocator_type match_allocator_type;

   match_results<BidiIterator> m;
   re_detail::perl_matcher<BidiIterator, match_allocator_type, traits> matcher(first, last, m, e, flags, first);
   unsigned int count = 0;
   while(matcher.find())
   {
      ++count;
      if(0 == foo(m))
         return count; // caller doesn't want to go on
      if(m[0].second == last)
         return count; // we've reached the end, don't try and find an extra null match.
      if(m.length() == 0)
      {
         if(m[0].second == last)
            return count;
         // we found a NULL-match, now try to find
         // a non-NULL one at the same position:
         match_results<BidiIterator, match_allocator_type> m2(m);
         matcher.setf(match_not_null | match_continuous);
         if(matcher.find())
         {
            ++count;
            if(0 == foo(m))
               return count;
         }
         else
         {
            // reset match back to where it was:
            m = m2;
         }
         matcher.unsetf((match_not_null | match_continuous) & ~flags);
      }
   }
   return count;
}
コード例 #9
0
 static bool match(basic_regex<BidiIter> const &rex, match_state<BidiIter> &state)
 {
     return rex.match_(state);
 }
コード例 #10
0
 static bool invalid(basic_regex<BidiIter> const &rex)
 {
     return rex.invalid_();
 }