Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //  Boost string_algo library string_funct.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_CASE_CONV_DETAIL_HPP
0012 #define BOOST_STRING_CASE_CONV_DETAIL_HPP
0013 
0014 #include <boost/algorithm/string/config.hpp>
0015 #include <locale>
0016 #include <functional>
0017 
0018 #include <boost/iterator/transform_iterator.hpp>
0019 #include <boost/range/begin.hpp>
0020 #include <boost/range/end.hpp>
0021 #include <boost/type_traits/make_unsigned.hpp>
0022 
0023 namespace boost {
0024     namespace algorithm {
0025         namespace detail {
0026 
0027 //  case conversion functors -----------------------------------------------//
0028 
0029 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0030 #pragma warning(push)
0031 #pragma warning(disable:4512) //assignment operator could not be generated
0032 #endif
0033 
0034             // a tolower functor
0035             template<typename CharT>
0036             struct to_lowerF
0037             {
0038                 typedef CharT argument_type;
0039                 typedef CharT result_type;
0040                 // Constructor
0041                 to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {}
0042 
0043                 // Operation
0044                 CharT operator ()( CharT Ch ) const
0045                 {
0046                     #if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
0047                         return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
0048                     #else
0049                         return std::tolower<CharT>( Ch, *m_Loc );
0050                     #endif
0051                 }
0052             private:
0053                 const std::locale* m_Loc;
0054             };
0055 
0056             // a toupper functor
0057             template<typename CharT>
0058             struct to_upperF
0059             {
0060                 typedef CharT argument_type;
0061                 typedef CharT result_type;
0062                 // Constructor
0063                 to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {}
0064 
0065                 // Operation
0066                 CharT operator ()( CharT Ch ) const
0067                 {
0068                     #if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
0069                         return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
0070                     #else
0071                         return std::toupper<CharT>( Ch, *m_Loc );
0072                     #endif
0073                 }
0074             private:
0075                 const std::locale* m_Loc;
0076             };
0077 
0078 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0079 #pragma warning(pop)
0080 #endif
0081 
0082 // algorithm implementation -------------------------------------------------------------------------
0083 
0084             // Transform a range
0085             template<typename OutputIteratorT, typename RangeT, typename FunctorT>
0086             OutputIteratorT transform_range_copy(
0087                 OutputIteratorT Output,
0088                 const RangeT& Input,
0089                 FunctorT Functor)
0090             {
0091                 return std::transform( 
0092                     ::boost::begin(Input), 
0093                     ::boost::end(Input), 
0094                     Output,
0095                     Functor);
0096             }
0097 
0098             // Transform a range (in-place)
0099             template<typename RangeT, typename FunctorT>
0100             void transform_range(
0101                 const RangeT& Input,
0102                 FunctorT Functor)
0103             {
0104                 std::transform( 
0105                     ::boost::begin(Input), 
0106                     ::boost::end(Input), 
0107                     ::boost::begin(Input),
0108                     Functor);
0109             }
0110 
0111             template<typename SequenceT, typename RangeT, typename FunctorT>
0112             inline SequenceT transform_range_copy( 
0113                 const RangeT& Input, 
0114                 FunctorT Functor)
0115             {
0116                 return SequenceT(
0117                     ::boost::make_transform_iterator(
0118                         ::boost::begin(Input),
0119                         Functor),
0120                     ::boost::make_transform_iterator(
0121                         ::boost::end(Input), 
0122                         Functor));
0123             }
0124 
0125         } // namespace detail
0126     } // namespace algorithm
0127 } // namespace boost
0128 
0129 
0130 #endif  // BOOST_STRING_CASE_CONV_DETAIL_HPP