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_DETAIL_HPP Chris@16: #define BOOST_STRING_FORMATTER_DETAIL_HPP Chris@16: Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: // generic replace functors -----------------------------------------------// Chris@16: Chris@16: namespace boost { Chris@16: namespace algorithm { Chris@16: namespace detail { Chris@16: Chris@16: // const format functor ----------------------------------------------------// Chris@16: Chris@16: // constant format functor Chris@16: template Chris@16: struct const_formatF Chris@16: { Chris@16: private: Chris@16: typedef BOOST_STRING_TYPENAME Chris@16: range_const_iterator::type format_iterator; Chris@16: typedef iterator_range result_type; Chris@16: Chris@16: public: Chris@16: // Construction Chris@16: const_formatF(const RangeT& Format) : Chris@16: m_Format(::boost::begin(Format), ::boost::end(Format)) {} Chris@16: Chris@16: // Operation Chris@16: #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: template Chris@16: result_type& operator()(const Range2T&) Chris@16: { Chris@16: return m_Format; Chris@16: } Chris@16: #endif Chris@16: Chris@16: template Chris@16: const result_type& operator()(const Range2T&) const Chris@16: { Chris@16: return m_Format; Chris@16: } Chris@16: Chris@16: private: Chris@16: result_type m_Format; Chris@16: }; Chris@16: Chris@16: // identity format functor ----------------------------------------------------// Chris@16: Chris@16: // identity format functor Chris@16: template Chris@16: struct identity_formatF Chris@16: { Chris@16: // Operation Chris@16: template< typename Range2T > Chris@16: const RangeT& operator()(const Range2T& Replace) const Chris@16: { Chris@16: return RangeT(::boost::begin(Replace), ::boost::end(Replace)); Chris@16: } Chris@16: }; Chris@16: Chris@16: // empty format functor ( used by erase ) ------------------------------------// Chris@16: Chris@16: // empty format functor Chris@16: template< typename CharT > Chris@16: struct empty_formatF Chris@16: { Chris@16: template< typename ReplaceT > Chris@16: empty_container operator()(const ReplaceT&) const Chris@16: { Chris@16: return empty_container(); Chris@16: } Chris@16: }; Chris@16: Chris@16: // dissect format functor ----------------------------------------------------// Chris@16: Chris@16: // dissect format functor Chris@16: template Chris@16: struct dissect_formatF Chris@16: { Chris@16: public: Chris@16: // Construction Chris@16: dissect_formatF(FinderT Finder) : Chris@16: m_Finder(Finder) {} Chris@16: Chris@16: // Operation Chris@16: template Chris@16: inline iterator_range< Chris@16: BOOST_STRING_TYPENAME range_const_iterator::type> Chris@16: operator()(const RangeT& Replace) const Chris@16: { Chris@16: return m_Finder(::boost::begin(Replace), ::boost::end(Replace)); Chris@16: } Chris@16: Chris@16: private: Chris@16: FinderT m_Finder; Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace algorithm Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_STRING_FORMATTER_DETAIL_HPP