1 | // Boost string_algo library formatter.hpp header file ---------------------------// |
---|
2 | |
---|
3 | // Copyright Pavol Droba 2002-2003. Use, modification and |
---|
4 | // distribution is subject to the Boost Software License, Version |
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | |
---|
8 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
9 | |
---|
10 | #ifndef BOOST_STRING_FORMATTER_HPP |
---|
11 | #define BOOST_STRING_FORMATTER_HPP |
---|
12 | |
---|
13 | #include <boost/detail/iterator.hpp> |
---|
14 | #include <boost/range/value_type.hpp> |
---|
15 | #include <boost/range/iterator_range.hpp> |
---|
16 | |
---|
17 | #include <boost/algorithm/string/detail/formatter.hpp> |
---|
18 | |
---|
19 | /*! \file |
---|
20 | Defines Formatter generators. Formatter is a functor which formats |
---|
21 | a string according to given parameters. A Formatter works |
---|
22 | in conjunction with a Finder. A Finder can provide additional information |
---|
23 | for a specific Formatter. An example of such a cooperation is regex_finder |
---|
24 | and regex_formatter. |
---|
25 | |
---|
26 | Formatters are used as pluggable components for replace facilities. |
---|
27 | This header contains generator functions for the Formatters provided in this library. |
---|
28 | */ |
---|
29 | |
---|
30 | namespace boost { |
---|
31 | namespace algorithm { |
---|
32 | |
---|
33 | // generic formatters ---------------------------------------------------------------// |
---|
34 | |
---|
35 | //! Constant formatter |
---|
36 | /*! |
---|
37 | Construct the \c const_formatter. Const formatter always returns |
---|
38 | the same value, regardless of the parameter. |
---|
39 | |
---|
40 | \param Format A predefined value used as a result for formating |
---|
41 | \return An instance of the \c const_formatter object. |
---|
42 | */ |
---|
43 | template<typename RangeT> |
---|
44 | inline detail::const_formatF<RangeT> |
---|
45 | const_formatter(const RangeT& Format) |
---|
46 | { |
---|
47 | return detail::const_formatF<RangeT>(Format); |
---|
48 | } |
---|
49 | |
---|
50 | //! Identity formatter |
---|
51 | /*! |
---|
52 | Construct the \c identity_formatter. Identity formatter always returns |
---|
53 | the parameter. |
---|
54 | |
---|
55 | \return An instance of the \c identity_formatter object. |
---|
56 | */ |
---|
57 | template<typename RangeT> |
---|
58 | inline detail::identity_formatF<RangeT> |
---|
59 | identity_formatter() |
---|
60 | { |
---|
61 | return detail::identity_formatF<RangeT>(); |
---|
62 | } |
---|
63 | |
---|
64 | //! Empty formatter |
---|
65 | /*! |
---|
66 | Construct the \c empty_formatter. Empty formatter always returns an empty |
---|
67 | sequence. |
---|
68 | |
---|
69 | \param Input container used to select a correct value_type for the |
---|
70 | resulting empty_container<>. |
---|
71 | \return An instance of the \c empty_formatter object. |
---|
72 | */ |
---|
73 | template<typename RangeT> |
---|
74 | inline detail::empty_formatF< |
---|
75 | BOOST_STRING_TYPENAME range_value<RangeT>::type> |
---|
76 | empty_formatter(const RangeT&) |
---|
77 | { |
---|
78 | return detail::empty_formatF< |
---|
79 | BOOST_STRING_TYPENAME range_value<RangeT>::type>(); |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | } // namespace algorithm |
---|
84 | |
---|
85 | // pull the names to the boost namespace |
---|
86 | using algorithm::const_formatter; |
---|
87 | using algorithm::identity_formatter; |
---|
88 | using algorithm::empty_formatter; |
---|
89 | |
---|
90 | } // namespace boost |
---|
91 | |
---|
92 | |
---|
93 | #endif // BOOST_FORMATTER_HPP |
---|