1 // Boost string_algo library formatter.hpp header file ---------------------------//
3 // Copyright Pavol Droba 2002-2003.
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)
9 // See http://www.boost.org/ for updates, documentation, and revision history.
11 #ifndef BOOST_STRING_FORMATTER_HPP
12 #define BOOST_STRING_FORMATTER_HPP
14 #include <boost/detail/iterator.hpp>
15 #include <boost/range/value_type.hpp>
16 #include <boost/range/iterator_range_core.hpp>
17 #include <boost/range/as_literal.hpp>
19 #include <boost/algorithm/string/detail/formatter.hpp>
22 Defines Formatter generators. Formatter is a functor which formats
23 a string according to given parameters. A Formatter works
24 in conjunction with a Finder. A Finder can provide additional information
25 for a specific Formatter. An example of such a cooperation is regex_finder
28 Formatters are used as pluggable components for replace facilities.
29 This header contains generator functions for the Formatters provided in this library.
35 // generic formatters ---------------------------------------------------------------//
37 //! Constant formatter
39 Constructs a \c const_formatter. Const formatter always returns
40 the same value, regardless of the parameter.
42 \param Format A predefined value used as a result for formatting
43 \return An instance of the \c const_formatter object.
45 template<typename RangeT>
46 inline detail::const_formatF<
48 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
49 const_formatter(const RangeT& Format)
51 return detail::const_formatF<
53 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(::boost::as_literal(Format));
56 //! Identity formatter
58 Constructs an \c identity_formatter. Identity formatter always returns
61 \return An instance of the \c identity_formatter object.
63 template<typename RangeT>
64 inline detail::identity_formatF<
66 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
69 return detail::identity_formatF<
71 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
76 Constructs an \c empty_formatter. Empty formatter always returns an empty
79 \param Input container used to select a correct value_type for the
80 resulting empty_container<>.
81 \return An instance of the \c empty_formatter object.
83 template<typename RangeT>
84 inline detail::empty_formatF<
85 BOOST_STRING_TYPENAME range_value<RangeT>::type>
86 empty_formatter(const RangeT&)
88 return detail::empty_formatF<
89 BOOST_STRING_TYPENAME range_value<RangeT>::type>();
94 Constructs a \c dissect_formatter. Dissect formatter uses a specified finder
95 to extract a portion of the formatted sequence. The first finder's match is returned
98 \param Finder a finder used to select a portion of the formatted sequence
99 \return An instance of the \c dissect_formatter object.
101 template<typename FinderT>
102 inline detail::dissect_formatF< FinderT >
103 dissect_formatter(const FinderT& Finder)
105 return detail::dissect_formatF<FinderT>(Finder);
109 } // namespace algorithm
111 // pull the names to the boost namespace
112 using algorithm::const_formatter;
113 using algorithm::identity_formatter;
114 using algorithm::empty_formatter;
115 using algorithm::dissect_formatter;
120 #endif // BOOST_FORMATTER_HPP