1 | // Boost string_algo library formatter.hpp header file ---------------------------// |
---|
2 | |
---|
3 | // Copyright Pavol Droba 2002-2003. |
---|
4 | // |
---|
5 | // Distributed under the Boost Software License, Version 1.0. |
---|
6 | // (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | |
---|
9 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
10 | |
---|
11 | #ifndef BOOST_STRING_FORMATTER_DETAIL_HPP |
---|
12 | #define BOOST_STRING_FORMATTER_DETAIL_HPP |
---|
13 | |
---|
14 | |
---|
15 | #include <boost/range/iterator_range.hpp> |
---|
16 | #include <boost/range/begin.hpp> |
---|
17 | #include <boost/range/end.hpp> |
---|
18 | #include <boost/range/const_iterator.hpp> |
---|
19 | |
---|
20 | #include <boost/algorithm/string/detail/util.hpp> |
---|
21 | |
---|
22 | // generic replace functors -----------------------------------------------// |
---|
23 | |
---|
24 | namespace boost { |
---|
25 | namespace algorithm { |
---|
26 | namespace detail { |
---|
27 | |
---|
28 | // const format functor ----------------------------------------------------// |
---|
29 | |
---|
30 | // constant format functor |
---|
31 | template<typename RangeT> |
---|
32 | struct const_formatF |
---|
33 | { |
---|
34 | private: |
---|
35 | typedef BOOST_STRING_TYPENAME |
---|
36 | range_const_iterator<RangeT>::type format_iterator; |
---|
37 | typedef iterator_range<format_iterator> result_type; |
---|
38 | |
---|
39 | public: |
---|
40 | // Construction |
---|
41 | const_formatF(const RangeT& Format) : |
---|
42 | m_Format(::boost::begin(Format), ::boost::end(Format)) {} |
---|
43 | |
---|
44 | // Operation |
---|
45 | #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) |
---|
46 | template<typename Range2T> |
---|
47 | result_type& operator()(const Range2T&) |
---|
48 | { |
---|
49 | return m_Format; |
---|
50 | } |
---|
51 | #endif |
---|
52 | |
---|
53 | template<typename Range2T> |
---|
54 | const result_type& operator()(const Range2T&) const |
---|
55 | { |
---|
56 | return m_Format; |
---|
57 | } |
---|
58 | |
---|
59 | private: |
---|
60 | result_type m_Format; |
---|
61 | }; |
---|
62 | |
---|
63 | // identity format functor ----------------------------------------------------// |
---|
64 | |
---|
65 | // identity format functor |
---|
66 | template<typename RangeT> |
---|
67 | struct identity_formatF |
---|
68 | { |
---|
69 | // Operation |
---|
70 | template< typename Range2T > |
---|
71 | const RangeT& operator()(const Range2T& Replace) const |
---|
72 | { |
---|
73 | return RangeT(::boost::begin(Replace), ::boost::end(Replace)); |
---|
74 | } |
---|
75 | }; |
---|
76 | |
---|
77 | // empty format functor ( used by erase ) ------------------------------------// |
---|
78 | |
---|
79 | // empty format functor |
---|
80 | template< typename CharT > |
---|
81 | struct empty_formatF |
---|
82 | { |
---|
83 | template< typename ReplaceT > |
---|
84 | empty_container<CharT> operator()(const ReplaceT&) const |
---|
85 | { |
---|
86 | return empty_container<CharT>(); |
---|
87 | } |
---|
88 | }; |
---|
89 | |
---|
90 | } // namespace detail |
---|
91 | } // namespace algorithm |
---|
92 | } // namespace boost |
---|
93 | |
---|
94 | #endif // BOOST_STRING_FORMATTER_DETAIL_HPP |
---|