1 // Boost string_algo library case_conv.hpp header file ---------------------------//
3 // Copyright Pavol Droba 2002-2003.
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)
9 // See http://www.boost.org/ for updates, documentation, and revision history.
11 #ifndef BOOST_STRING_CASE_CONV_HPP
12 #define BOOST_STRING_CASE_CONV_HPP
14 #include <boost/algorithm/string/config.hpp>
17 #include <boost/iterator/transform_iterator.hpp>
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>
24 #include <boost/algorithm/string/detail/case_conv.hpp>
27 Defines sequence case-conversion algorithms.
28 Algorithms convert each element in the input sequence to the
29 desired case using provided locales.
35 // to_lower -----------------------------------------------//
37 //! Convert to lower case
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.
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
47 An output iterator pointing just after the last inserted character or
50 \note The second variant of this function provides the strong exception-safety guarantee
53 template<typename OutputIteratorT, typename RangeT>
54 inline OutputIteratorT
56 OutputIteratorT Output,
58 const std::locale& Loc=std::locale())
60 return ::boost::algorithm::detail::transform_range_copy(
62 ::boost::as_literal(Input),
63 ::boost::algorithm::detail::to_lowerF<
64 typename range_value<RangeT>::type >(Loc));
67 //! Convert to lower case
71 template<typename SequenceT>
72 inline SequenceT to_lower_copy(
73 const SequenceT& Input,
74 const std::locale& Loc=std::locale())
76 return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
78 ::boost::algorithm::detail::to_lowerF<
79 typename range_value<SequenceT>::type >(Loc));
82 //! Convert to lower case
84 Each element of the input sequence is converted to lower
85 case. The input sequence is modified in-place.
88 \param Loc a locale used for conversion
90 template<typename WritableRangeT>
92 WritableRangeT& Input,
93 const std::locale& Loc=std::locale())
95 ::boost::algorithm::detail::transform_range(
96 ::boost::as_literal(Input),
97 ::boost::algorithm::detail::to_lowerF<
98 typename range_value<WritableRangeT>::type >(Loc));
101 // to_upper -----------------------------------------------//
103 //! Convert to upper case
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
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
113 An output iterator pointing just after the last inserted character or
116 \note The second variant of this function provides the strong exception-safety guarantee
118 template<typename OutputIteratorT, typename RangeT>
119 inline OutputIteratorT
121 OutputIteratorT Output,
123 const std::locale& Loc=std::locale())
125 return ::boost::algorithm::detail::transform_range_copy(
127 ::boost::as_literal(Input),
128 ::boost::algorithm::detail::to_upperF<
129 typename range_value<RangeT>::type >(Loc));
132 //! Convert to upper case
136 template<typename SequenceT>
137 inline SequenceT to_upper_copy(
138 const SequenceT& Input,
139 const std::locale& Loc=std::locale())
141 return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
143 ::boost::algorithm::detail::to_upperF<
144 typename range_value<SequenceT>::type >(Loc));
147 //! Convert to upper case
149 Each element of the input sequence is converted to upper
150 case. The input sequence is modified in-place.
152 \param Input An input range
153 \param Loc a locale used for conversion
155 template<typename WritableRangeT>
156 inline void to_upper(
157 WritableRangeT& Input,
158 const std::locale& Loc=std::locale())
160 ::boost::algorithm::detail::transform_range(
161 ::boost::as_literal(Input),
162 ::boost::algorithm::detail::to_upperF<
163 typename range_value<WritableRangeT>::type >(Loc));
166 } // namespace algorithm
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;
176 #endif // BOOST_STRING_CASE_CONV_HPP