Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:38

0001 /*
0002  *
0003  * Copyright (c) 1998-2009
0004  * John Maddock
0005  *
0006  * Use, modification and distribution are subject to the 
0007  * Boost Software License, Version 1.0. (See accompanying file 
0008  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009  *
0010  */
0011 
0012  /*
0013   *   LOCATION:    see http://www.boost.org for most recent version.
0014   *   FILE         regex_format.hpp
0015   *   VERSION      see <boost/version.hpp>
0016   *   DESCRIPTION: Provides formatting output routines for search and replace
0017   *                operations.  Note this is an internal header file included
0018   *                by regex.hpp, do not include on its own.
0019   */
0020 
0021 #ifndef BOOST_REGEX_V5_REGEX_REPLACE_HPP
0022 #define BOOST_REGEX_V5_REGEX_REPLACE_HPP
0023 
0024 
0025 namespace boost{
0026 
0027 template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
0028 OutputIterator regex_replace(OutputIterator out,
0029                          BidirectionalIterator first,
0030                          BidirectionalIterator last,
0031                          const basic_regex<charT, traits>& e, 
0032                          Formatter fmt, 
0033                          match_flag_type flags = match_default)
0034 {
0035    regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
0036    regex_iterator<BidirectionalIterator, charT, traits> j;
0037    if(i == j)
0038    {
0039       if(!(flags & regex_constants::format_no_copy))
0040          out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
0041    }
0042    else
0043    {
0044       BidirectionalIterator last_m(first);
0045       while(i != j)
0046       {
0047          if(!(flags & regex_constants::format_no_copy))
0048             out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out);
0049          out = i->format(out, fmt, flags, e);
0050          last_m = (*i)[0].second;
0051          if(flags & regex_constants::format_first_only)
0052             break;
0053          ++i;
0054       }
0055       if(!(flags & regex_constants::format_no_copy))
0056          out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
0057    }
0058    return out;
0059 }
0060 
0061 template <class traits, class charT, class Formatter>
0062 std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
0063                          const basic_regex<charT, traits>& e, 
0064                          Formatter fmt,
0065                          match_flag_type flags = match_default)
0066 {
0067    std::basic_string<charT> result;
0068    BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
0069    regex_replace(i, s.begin(), s.end(), e, fmt, flags);
0070    return result;
0071 }
0072 
0073 } // namespace boost
0074 
0075 #endif  // BOOST_REGEX_V5_REGEX_REPLACE_HPP
0076 
0077