annotate DEPENDENCIES/generic/include/boost/algorithm/string/detail/case_conv.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost string_algo library string_funct.hpp header file ---------------------------//
Chris@16 2
Chris@16 3 // Copyright Pavol Droba 2002-2003.
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // See http://www.boost.org/ for updates, documentation, and revision history.
Chris@16 10
Chris@16 11 #ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP
Chris@16 12 #define BOOST_STRING_CASE_CONV_DETAIL_HPP
Chris@16 13
Chris@16 14 #include <boost/algorithm/string/config.hpp>
Chris@16 15 #include <locale>
Chris@16 16 #include <functional>
Chris@16 17
Chris@16 18 #include <boost/type_traits/make_unsigned.hpp>
Chris@16 19
Chris@16 20 namespace boost {
Chris@16 21 namespace algorithm {
Chris@16 22 namespace detail {
Chris@16 23
Chris@16 24 // case conversion functors -----------------------------------------------//
Chris@16 25
Chris@16 26 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
Chris@16 27 #pragma warning(push)
Chris@16 28 #pragma warning(disable:4512) //assignment operator could not be generated
Chris@16 29 #endif
Chris@16 30
Chris@16 31 // a tolower functor
Chris@16 32 template<typename CharT>
Chris@16 33 struct to_lowerF : public std::unary_function<CharT, CharT>
Chris@16 34 {
Chris@16 35 // Constructor
Chris@16 36 to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {}
Chris@16 37
Chris@16 38 // Operation
Chris@16 39 CharT operator ()( CharT Ch ) const
Chris@16 40 {
Chris@16 41 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
Chris@16 42 return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
Chris@16 43 #else
Chris@16 44 return std::tolower<CharT>( Ch, *m_Loc );
Chris@16 45 #endif
Chris@16 46 }
Chris@16 47 private:
Chris@16 48 const std::locale* m_Loc;
Chris@16 49 };
Chris@16 50
Chris@16 51 // a toupper functor
Chris@16 52 template<typename CharT>
Chris@16 53 struct to_upperF : public std::unary_function<CharT, CharT>
Chris@16 54 {
Chris@16 55 // Constructor
Chris@16 56 to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {}
Chris@16 57
Chris@16 58 // Operation
Chris@16 59 CharT operator ()( CharT Ch ) const
Chris@16 60 {
Chris@16 61 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
Chris@16 62 return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
Chris@16 63 #else
Chris@16 64 return std::toupper<CharT>( Ch, *m_Loc );
Chris@16 65 #endif
Chris@16 66 }
Chris@16 67 private:
Chris@16 68 const std::locale* m_Loc;
Chris@16 69 };
Chris@16 70
Chris@16 71 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
Chris@16 72 #pragma warning(pop)
Chris@16 73 #endif
Chris@16 74
Chris@16 75 // algorithm implementation -------------------------------------------------------------------------
Chris@16 76
Chris@16 77 // Transform a range
Chris@16 78 template<typename OutputIteratorT, typename RangeT, typename FunctorT>
Chris@16 79 OutputIteratorT transform_range_copy(
Chris@16 80 OutputIteratorT Output,
Chris@16 81 const RangeT& Input,
Chris@16 82 FunctorT Functor)
Chris@16 83 {
Chris@16 84 return std::transform(
Chris@16 85 ::boost::begin(Input),
Chris@16 86 ::boost::end(Input),
Chris@16 87 Output,
Chris@16 88 Functor);
Chris@16 89 }
Chris@16 90
Chris@16 91 // Transform a range (in-place)
Chris@16 92 template<typename RangeT, typename FunctorT>
Chris@16 93 void transform_range(
Chris@16 94 const RangeT& Input,
Chris@16 95 FunctorT Functor)
Chris@16 96 {
Chris@16 97 std::transform(
Chris@16 98 ::boost::begin(Input),
Chris@16 99 ::boost::end(Input),
Chris@16 100 ::boost::begin(Input),
Chris@16 101 Functor);
Chris@16 102 }
Chris@16 103
Chris@16 104 template<typename SequenceT, typename RangeT, typename FunctorT>
Chris@16 105 inline SequenceT transform_range_copy(
Chris@16 106 const RangeT& Input,
Chris@16 107 FunctorT Functor)
Chris@16 108 {
Chris@16 109 return SequenceT(
Chris@16 110 ::boost::make_transform_iterator(
Chris@16 111 ::boost::begin(Input),
Chris@16 112 Functor),
Chris@16 113 ::boost::make_transform_iterator(
Chris@16 114 ::boost::end(Input),
Chris@16 115 Functor));
Chris@16 116 }
Chris@16 117
Chris@16 118 } // namespace detail
Chris@16 119 } // namespace algorithm
Chris@16 120 } // namespace boost
Chris@16 121
Chris@16 122
Chris@16 123 #endif // BOOST_STRING_CASE_CONV_DETAIL_HPP