Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:24

0001 //  Boost string_algo library formatter.hpp header file  ---------------------------//
0002 
0003 //  Copyright Pavol Droba 2002-2003.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org for updates, documentation, and revision history.
0010 
0011 #ifndef BOOST_STRING_FORMATTER_DETAIL_HPP
0012 #define BOOST_STRING_FORMATTER_DETAIL_HPP
0013 
0014 
0015 #include <boost/range/iterator_range_core.hpp>
0016 #include <boost/range/begin.hpp>
0017 #include <boost/range/end.hpp>
0018 #include <boost/range/const_iterator.hpp>
0019 
0020 #include <boost/algorithm/string/detail/util.hpp>
0021 
0022 //  generic replace functors -----------------------------------------------//
0023 
0024 namespace boost {
0025     namespace algorithm {
0026         namespace detail {
0027 
0028 //  const format functor ----------------------------------------------------//
0029 
0030             // constant format functor
0031             template<typename RangeT>
0032             struct const_formatF
0033             {
0034             private:
0035                 typedef BOOST_STRING_TYPENAME
0036                     range_const_iterator<RangeT>::type format_iterator;
0037                 typedef iterator_range<format_iterator> result_type;
0038             
0039             public:
0040                 // Construction
0041                 const_formatF(const RangeT& Format) :
0042                     m_Format(::boost::begin(Format), ::boost::end(Format)) {}
0043 
0044                 // Operation
0045 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0046                 template<typename Range2T>
0047                 result_type& operator()(const Range2T&)
0048                 {
0049                     return m_Format;
0050                 }
0051 #endif
0052 
0053                 template<typename Range2T>
0054                 const result_type& operator()(const Range2T&) const
0055                 {
0056                     return m_Format;
0057                 }
0058 
0059             private:
0060                 result_type m_Format;
0061             };
0062 
0063 //  identity format functor ----------------------------------------------------//
0064 
0065             // identity format functor
0066             template<typename RangeT>
0067             struct identity_formatF
0068             {
0069                 // Operation
0070                 template< typename Range2T >
0071                 const RangeT& operator()(const Range2T& Replace) const
0072                 {
0073                     return RangeT(::boost::begin(Replace), ::boost::end(Replace));
0074                 }
0075             };
0076 
0077 //  empty format functor ( used by erase ) ------------------------------------//
0078         
0079             // empty format functor
0080             template< typename CharT >
0081             struct empty_formatF
0082             {
0083                 template< typename ReplaceT >
0084                 empty_container<CharT> operator()(const ReplaceT&) const
0085                 {
0086                     return empty_container<CharT>();
0087                 }
0088             };
0089 
0090 //  dissect format functor ----------------------------------------------------//
0091 
0092             // dissect format functor
0093             template<typename FinderT>
0094             struct dissect_formatF
0095             {
0096             public:
0097                 // Construction
0098                 dissect_formatF(FinderT Finder) :
0099                   m_Finder(Finder) {}
0100 
0101                   // Operation
0102                   template<typename RangeT>
0103                   inline iterator_range< 
0104                       BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
0105                   operator()(const RangeT& Replace) const
0106                   {
0107                       return m_Finder(::boost::begin(Replace), ::boost::end(Replace));
0108                   }
0109 
0110             private:
0111                 FinderT m_Finder;
0112             };
0113 
0114 
0115         } // namespace detail
0116     } // namespace algorithm
0117 } // namespace boost
0118 
0119 #endif  // BOOST_STRING_FORMATTER_DETAIL_HPP