3 * Copyright (c) 1998-2009
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE regex_format.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Provides formatting output routines for search and replace
17 * operations. Note this is an internal header file included
18 * by regex.hpp, do not include on its own.
21 #ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP
22 #define BOOST_REGEX_V4_REGEX_REPLACE_HPP
29 #pragma warning(disable: 4103)
31 #ifdef BOOST_HAS_ABI_HEADERS
32 # include BOOST_ABI_PREFIX
38 template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
39 OutputIterator regex_replace(OutputIterator out,
40 BidirectionalIterator first,
41 BidirectionalIterator last,
42 const basic_regex<charT, traits>& e,
44 match_flag_type flags = match_default)
46 regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
47 regex_iterator<BidirectionalIterator, charT, traits> j;
50 if(!(flags & regex_constants::format_no_copy))
51 out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
55 BidirectionalIterator last_m(first);
58 if(!(flags & regex_constants::format_no_copy))
59 out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out);
60 out = i->format(out, fmt, flags, e);
61 last_m = (*i)[0].second;
62 if(flags & regex_constants::format_first_only)
66 if(!(flags & regex_constants::format_no_copy))
67 out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
72 template <class traits, class charT, class Formatter>
73 std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
74 const basic_regex<charT, traits>& e,
76 match_flag_type flags = match_default)
78 std::basic_string<charT> result;
79 BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
80 regex_replace(i, s.begin(), s.end(), e, fmt, flags);
86 #pragma warning(disable: 4103)
88 #ifdef BOOST_HAS_ABI_HEADERS
89 # include BOOST_ABI_SUFFIX
97 #endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP