Chris@16: // Boost string_algo library string_funct.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_CASE_CONV_DETAIL_HPP Chris@16: #define BOOST_STRING_CASE_CONV_DETAIL_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace algorithm { Chris@16: namespace detail { Chris@16: Chris@16: // case conversion functors -----------------------------------------------// Chris@16: Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable:4512) //assignment operator could not be generated Chris@16: #endif Chris@16: Chris@16: // a tolower functor Chris@16: template Chris@16: struct to_lowerF : public std::unary_function Chris@16: { Chris@16: // Constructor Chris@16: to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {} Chris@16: Chris@16: // Operation Chris@16: CharT operator ()( CharT Ch ) const Chris@16: { Chris@16: #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) Chris@16: return std::tolower( static_cast::type> ( Ch )); Chris@16: #else Chris@16: return std::tolower( Ch, *m_Loc ); Chris@16: #endif Chris@16: } Chris@16: private: Chris@16: const std::locale* m_Loc; Chris@16: }; Chris@16: Chris@16: // a toupper functor Chris@16: template Chris@16: struct to_upperF : public std::unary_function Chris@16: { Chris@16: // Constructor Chris@16: to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {} Chris@16: Chris@16: // Operation Chris@16: CharT operator ()( CharT Ch ) const Chris@16: { Chris@16: #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) Chris@16: return std::toupper( static_cast::type> ( Ch )); Chris@16: #else Chris@16: return std::toupper( Ch, *m_Loc ); Chris@16: #endif Chris@16: } Chris@16: private: Chris@16: const std::locale* m_Loc; Chris@16: }; Chris@16: Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: // algorithm implementation ------------------------------------------------------------------------- Chris@16: Chris@16: // Transform a range Chris@16: template Chris@16: OutputIteratorT transform_range_copy( Chris@16: OutputIteratorT Output, Chris@16: const RangeT& Input, Chris@16: FunctorT Functor) Chris@16: { Chris@16: return std::transform( Chris@16: ::boost::begin(Input), Chris@16: ::boost::end(Input), Chris@16: Output, Chris@16: Functor); Chris@16: } Chris@16: Chris@16: // Transform a range (in-place) Chris@16: template Chris@16: void transform_range( Chris@16: const RangeT& Input, Chris@16: FunctorT Functor) Chris@16: { Chris@16: std::transform( Chris@16: ::boost::begin(Input), Chris@16: ::boost::end(Input), Chris@16: ::boost::begin(Input), Chris@16: Functor); Chris@16: } Chris@16: Chris@16: template Chris@16: inline SequenceT transform_range_copy( Chris@16: const RangeT& Input, Chris@16: FunctorT Functor) Chris@16: { Chris@16: return SequenceT( Chris@16: ::boost::make_transform_iterator( Chris@16: ::boost::begin(Input), Chris@16: Functor), Chris@16: ::boost::make_transform_iterator( Chris@16: ::boost::end(Input), Chris@16: Functor)); Chris@16: } Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace algorithm Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_STRING_CASE_CONV_DETAIL_HPP