Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / string / detail / case_conv.hpp @ 2486

History | View | Annotate | Download (4.2 kB)

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