Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:26

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_V4_REGEX_REPLACE_HPP
0022 #define BOOST_REGEX_V4_REGEX_REPLACE_HPP
0023 
0024 
0025 namespace boost{
0026 
0027 #ifdef BOOST_MSVC
0028 #pragma warning(push)
0029 #pragma warning(disable: 4103)
0030 #endif
0031 #ifdef BOOST_HAS_ABI_HEADERS
0032 #  include BOOST_ABI_PREFIX
0033 #endif
0034 #ifdef BOOST_MSVC
0035 #pragma warning(pop)
0036 #endif
0037 
0038 template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
0039 OutputIterator regex_replace(OutputIterator out,
0040                          BidirectionalIterator first,
0041                          BidirectionalIterator last,
0042                          const basic_regex<charT, traits>& e, 
0043                          Formatter fmt, 
0044                          match_flag_type flags = match_default)
0045 {
0046    regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
0047    regex_iterator<BidirectionalIterator, charT, traits> j;
0048    if(i == j)
0049    {
0050       if(!(flags & regex_constants::format_no_copy))
0051          out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
0052    }
0053    else
0054    {
0055       BidirectionalIterator last_m(first);
0056       while(i != j)
0057       {
0058          if(!(flags & regex_constants::format_no_copy))
0059             out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); 
0060          out = i->format(out, fmt, flags, e);
0061          last_m = (*i)[0].second;
0062          if(flags & regex_constants::format_first_only)
0063             break;
0064          ++i;
0065       }
0066       if(!(flags & regex_constants::format_no_copy))
0067          out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
0068    }
0069    return out;
0070 }
0071 
0072 template <class traits, class charT, class Formatter>
0073 std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
0074                          const basic_regex<charT, traits>& e, 
0075                          Formatter fmt,
0076                          match_flag_type flags = match_default)
0077 {
0078    std::basic_string<charT> result;
0079    BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
0080    regex_replace(i, s.begin(), s.end(), e, fmt, flags);
0081    return result;
0082 }
0083 
0084 #ifdef BOOST_MSVC
0085 #pragma warning(push)
0086 #pragma warning(disable: 4103)
0087 #endif
0088 #ifdef BOOST_HAS_ABI_HEADERS
0089 #  include BOOST_ABI_SUFFIX
0090 #endif
0091 #ifdef BOOST_MSVC
0092 #pragma warning(pop)
0093 #endif
0094 
0095 } // namespace boost
0096 
0097 #endif  // BOOST_REGEX_V4_REGEX_REPLACE_HPP
0098 
0099