1 | // Boost string_algo library string_funct.hpp header file ---------------------------//
|
---|
2 |
|
---|
3 | // Copyright Pavol Droba 2002-2003. Use, modification and
|
---|
4 | // distribution is subject to the Boost Software License, Version
|
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 |
|
---|
8 | // See http://www.boost.org for updates, documentation, and revision history.
|
---|
9 |
|
---|
10 | #ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP
|
---|
11 | #define BOOST_STRING_CASE_CONV_DETAIL_HPP
|
---|
12 |
|
---|
13 | #include <boost/algorithm/string/config.hpp>
|
---|
14 | #include <locale>
|
---|
15 | #include <functional>
|
---|
16 |
|
---|
17 | namespace boost {
|
---|
18 | namespace algorithm {
|
---|
19 | namespace detail {
|
---|
20 |
|
---|
21 | // case conversion functors -----------------------------------------------//
|
---|
22 |
|
---|
23 | // a tolower functor
|
---|
24 | template<typename CharT>
|
---|
25 | struct to_lowerF : public std::unary_function<CharT, CharT>
|
---|
26 | {
|
---|
27 | // Constructor
|
---|
28 | to_lowerF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
---|
29 |
|
---|
30 | // Operation
|
---|
31 | CharT operator ()( CharT Ch ) const
|
---|
32 | {
|
---|
33 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
---|
34 | return std::tolower( Ch);
|
---|
35 | #else
|
---|
36 | return std::tolower( Ch, m_Loc );
|
---|
37 | #endif
|
---|
38 | }
|
---|
39 | private:
|
---|
40 | const std::locale& m_Loc;
|
---|
41 | };
|
---|
42 |
|
---|
43 | // a toupper functor
|
---|
44 | template<typename CharT>
|
---|
45 | struct to_upperF : public std::unary_function<CharT, CharT>
|
---|
46 | {
|
---|
47 | // Constructor
|
---|
48 | to_upperF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
---|
49 |
|
---|
50 | // Operation
|
---|
51 | CharT operator ()( CharT Ch ) const
|
---|
52 | {
|
---|
53 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
---|
54 | return std::toupper( Ch);
|
---|
55 | #else
|
---|
56 | return std::toupper( Ch, m_Loc );
|
---|
57 | #endif
|
---|
58 | }
|
---|
59 | private:
|
---|
60 | const std::locale& m_Loc;
|
---|
61 | };
|
---|
62 |
|
---|
63 | } // namespace detail
|
---|
64 | } // namespace algorithm
|
---|
65 | } // namespace boost
|
---|
66 |
|
---|
67 |
|
---|
68 | #endif // BOOST_STRING_CASE_CONV_DETAIL_HPP
|
---|