Chris@16: // Boost string_algo library formatter.hpp header file ---------------------------// Chris@16: Chris@16: // Copyright Pavol Droba 2002-2003. Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org/ for updates, documentation, and revision history. Chris@16: Chris@16: #ifndef BOOST_STRING_FORMATTER_HPP Chris@16: #define BOOST_STRING_FORMATTER_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: /*! \file Chris@16: Defines Formatter generators. Formatter is a functor which formats Chris@16: a string according to given parameters. A Formatter works Chris@16: in conjunction with a Finder. A Finder can provide additional information Chris@16: for a specific Formatter. An example of such a cooperation is regex_finder Chris@16: and regex_formatter. Chris@16: Chris@16: Formatters are used as pluggable components for replace facilities. Chris@16: This header contains generator functions for the Formatters provided in this library. Chris@16: */ Chris@16: Chris@16: namespace boost { Chris@16: namespace algorithm { Chris@16: Chris@16: // generic formatters ---------------------------------------------------------------// Chris@16: Chris@16: //! Constant formatter Chris@16: /*! Chris@16: Constructs a \c const_formatter. Const formatter always returns Chris@16: the same value, regardless of the parameter. Chris@16: Chris@16: \param Format A predefined value used as a result for formatting Chris@16: \return An instance of the \c const_formatter object. Chris@16: */ Chris@16: template Chris@16: inline detail::const_formatF< Chris@16: iterator_range< Chris@16: BOOST_STRING_TYPENAME range_const_iterator::type> > Chris@16: const_formatter(const RangeT& Format) Chris@16: { Chris@16: return detail::const_formatF< Chris@16: iterator_range< Chris@16: BOOST_STRING_TYPENAME range_const_iterator::type> >(::boost::as_literal(Format)); Chris@16: } Chris@16: Chris@16: //! Identity formatter Chris@16: /*! Chris@16: Constructs an \c identity_formatter. Identity formatter always returns Chris@16: the parameter. Chris@16: Chris@16: \return An instance of the \c identity_formatter object. Chris@16: */ Chris@16: template Chris@16: inline detail::identity_formatF< Chris@16: iterator_range< Chris@16: BOOST_STRING_TYPENAME range_const_iterator::type> > Chris@16: identity_formatter() Chris@16: { Chris@16: return detail::identity_formatF< Chris@16: iterator_range< Chris@16: BOOST_STRING_TYPENAME range_const_iterator::type> >(); Chris@16: } Chris@16: Chris@16: //! Empty formatter Chris@16: /*! Chris@16: Constructs an \c empty_formatter. Empty formatter always returns an empty Chris@16: sequence. Chris@16: Chris@16: \param Input container used to select a correct value_type for the Chris@16: resulting empty_container<>. Chris@16: \return An instance of the \c empty_formatter object. Chris@16: */ Chris@16: template Chris@16: inline detail::empty_formatF< Chris@16: BOOST_STRING_TYPENAME range_value::type> Chris@16: empty_formatter(const RangeT&) Chris@16: { Chris@16: return detail::empty_formatF< Chris@16: BOOST_STRING_TYPENAME range_value::type>(); Chris@16: } Chris@16: Chris@16: //! Empty formatter Chris@16: /*! Chris@16: Constructs a \c dissect_formatter. Dissect formatter uses a specified finder Chris@16: to extract a portion of the formatted sequence. The first finder's match is returned Chris@16: as a result Chris@16: Chris@16: \param Finder a finder used to select a portion of the formatted sequence Chris@16: \return An instance of the \c dissect_formatter object. Chris@16: */ Chris@16: template Chris@16: inline detail::dissect_formatF< FinderT > Chris@16: dissect_formatter(const FinderT& Finder) Chris@16: { Chris@16: return detail::dissect_formatF(Finder); Chris@16: } Chris@16: Chris@16: Chris@16: } // namespace algorithm Chris@16: Chris@16: // pull the names to the boost namespace Chris@16: using algorithm::const_formatter; Chris@16: using algorithm::identity_formatter; Chris@16: using algorithm::empty_formatter; Chris@16: using algorithm::dissect_formatter; Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_FORMATTER_HPP