1// Boost string_algo library case_conv.hpp header file ---------------------------//
2
3// Copyright Pavol Droba 2002-2003.
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9// See http://www.boost.org/ for updates, documentation, and revision history.
10
11#ifndef BOOST_STRING_CASE_CONV_HPP
12#define BOOST_STRING_CASE_CONV_HPP
13
14#include <boost/algorithm/string/config.hpp>
15#include <algorithm>
16#include <locale>
17#include <boost/iterator/transform_iterator.hpp>
18
19#include <boost/range/as_literal.hpp>
20#include <boost/range/begin.hpp>
21#include <boost/range/end.hpp>
22#include <boost/range/value_type.hpp>
23
24#include <boost/algorithm/string/detail/case_conv.hpp>
25
26/*! \file
27 Defines sequence case-conversion algorithms.
28 Algorithms convert each element in the input sequence to the
29 desired case using provided locales.
30*/
31
32namespace boost {
33 namespace algorithm {
34
35// to_lower -----------------------------------------------//
36
37 //! Convert to lower case
38 /*!
39 Each element of the input sequence is converted to lower
40 case. The result is a copy of the input converted to lower case.
41 It is returned as a sequence or copied to the output iterator.
42
43 \param Output An output iterator to which the result will be copied
44 \param Input An input range
45 \param Loc A locale used for conversion
46 \return
47 An output iterator pointing just after the last inserted character or
48 a copy of the input
49
50 \note The second variant of this function provides the strong exception-safety guarantee
51
52 */
53 template<typename OutputIteratorT, typename RangeT>
54 inline OutputIteratorT
55 to_lower_copy(
56 OutputIteratorT Output,
57 const RangeT& Input,
58 const std::locale& Loc=std::locale())
59 {
60 return ::boost::algorithm::detail::transform_range_copy(
61 Output,
62 ::boost::as_literal(Input),
63 ::boost::algorithm::detail::to_lowerF<
64 typename range_value<RangeT>::type >(Loc));
65 }
66
67 //! Convert to lower case
68 /*!
69 \overload
70 */
71 template<typename SequenceT>
72 inline SequenceT to_lower_copy(
73 const SequenceT& Input,
74 const std::locale& Loc=std::locale())
75 {
76 return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
77 Input,
78 ::boost::algorithm::detail::to_lowerF<
79 typename range_value<SequenceT>::type >(Loc));
80 }
81
82 //! Convert to lower case
83 /*!
84 Each element of the input sequence is converted to lower
85 case. The input sequence is modified in-place.
86
87 \param Input A range
88 \param Loc a locale used for conversion
89 */
90 template<typename WritableRangeT>
91 inline void to_lower(
92 WritableRangeT& Input,
93 const std::locale& Loc=std::locale())
94 {
95 ::boost::algorithm::detail::transform_range(
96 ::boost::as_literal(Input),
97 ::boost::algorithm::detail::to_lowerF<
98 typename range_value<WritableRangeT>::type >(Loc));
99 }
100
101// to_upper -----------------------------------------------//
102
103 //! Convert to upper case
104 /*!
105 Each element of the input sequence is converted to upper
106 case. The result is a copy of the input converted to upper case.
107 It is returned as a sequence or copied to the output iterator
108
109 \param Output An output iterator to which the result will be copied
110 \param Input An input range
111 \param Loc A locale used for conversion
112 \return
113 An output iterator pointing just after the last inserted character or
114 a copy of the input
115
116 \note The second variant of this function provides the strong exception-safety guarantee
117 */
118 template<typename OutputIteratorT, typename RangeT>
119 inline OutputIteratorT
120 to_upper_copy(
121 OutputIteratorT Output,
122 const RangeT& Input,
123 const std::locale& Loc=std::locale())
124 {
125 return ::boost::algorithm::detail::transform_range_copy(
126 Output,
127 ::boost::as_literal(Input),
128 ::boost::algorithm::detail::to_upperF<
129 typename range_value<RangeT>::type >(Loc));
130 }
131
132 //! Convert to upper case
133 /*!
134 \overload
135 */
136 template<typename SequenceT>
137 inline SequenceT to_upper_copy(
138 const SequenceT& Input,
139 const std::locale& Loc=std::locale())
140 {
141 return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
142 Input,
143 ::boost::algorithm::detail::to_upperF<
144 typename range_value<SequenceT>::type >(Loc));
145 }
146
147 //! Convert to upper case
148 /*!
149 Each element of the input sequence is converted to upper
150 case. The input sequence is modified in-place.
151
152 \param Input An input range
153 \param Loc a locale used for conversion
154 */
155 template<typename WritableRangeT>
156 inline void to_upper(
157 WritableRangeT& Input,
158 const std::locale& Loc=std::locale())
159 {
160 ::boost::algorithm::detail::transform_range(
161 ::boost::as_literal(Input),
162 ::boost::algorithm::detail::to_upperF<
163 typename range_value<WritableRangeT>::type >(Loc));
164 }
165
166 } // namespace algorithm
167
168 // pull names to the boost namespace
169 using algorithm::to_lower;
170 using algorithm::to_lower_copy;
171 using algorithm::to_upper;
172 using algorithm::to_upper_copy;
173
174} // namespace boost
175
176#endif // BOOST_STRING_CASE_CONV_HPP
177

source code of boost/boost/algorithm/string/case_conv.hpp