]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/regex/v5/regex_replace.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / regex / v5 / regex_replace.hpp
1 /*
2 *
3 * Copyright (c) 1998-2009
4 * John Maddock
5 *
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)
9 *
10 */
11
12 /*
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.
19 */
20
21 #ifndef BOOST_REGEX_V5_REGEX_REPLACE_HPP
22 #define BOOST_REGEX_V5_REGEX_REPLACE_HPP
23
24
25 namespace boost{
26
27 template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
28 OutputIterator regex_replace(OutputIterator out,
29 BidirectionalIterator first,
30 BidirectionalIterator last,
31 const basic_regex<charT, traits>& e,
32 Formatter fmt,
33 match_flag_type flags = match_default)
34 {
35 regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
36 regex_iterator<BidirectionalIterator, charT, traits> j;
37 if(i == j)
38 {
39 if(!(flags & regex_constants::format_no_copy))
40 out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
41 }
42 else
43 {
44 BidirectionalIterator last_m(first);
45 while(i != j)
46 {
47 if(!(flags & regex_constants::format_no_copy))
48 out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out);
49 out = i->format(out, fmt, flags, e);
50 last_m = (*i)[0].second;
51 if(flags & regex_constants::format_first_only)
52 break;
53 ++i;
54 }
55 if(!(flags & regex_constants::format_no_copy))
56 out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
57 }
58 return out;
59 }
60
61 template <class traits, class charT, class Formatter>
62 std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
63 const basic_regex<charT, traits>& e,
64 Formatter fmt,
65 match_flag_type flags = match_default)
66 {
67 std::basic_string<charT> result;
68 BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
69 regex_replace(i, s.begin(), s.end(), e, fmt, flags);
70 return result;
71 }
72
73 } // namespace boost
74
75 #endif // BOOST_REGEX_V5_REGEX_REPLACE_HPP
76
77