Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:55:53

0001 //  Boost string_algo library case_conv.hpp header file  ---------------------------//
0002 
0003 //  Copyright Pavol Droba 2002-2003.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org/ for updates, documentation, and revision history.
0010 
0011 #ifndef BOOST_STRING_CASE_CONV_HPP
0012 #define BOOST_STRING_CASE_CONV_HPP
0013 
0014 #include <boost/algorithm/string/config.hpp>
0015 #include <algorithm>
0016 #include <locale>
0017 #include <boost/iterator/transform_iterator.hpp>
0018 
0019 #include <boost/range/as_literal.hpp>
0020 #include <boost/range/begin.hpp>
0021 #include <boost/range/end.hpp>
0022 #include <boost/range/value_type.hpp>
0023 
0024 #include <boost/algorithm/string/detail/case_conv.hpp>
0025 
0026 /*! \file
0027     Defines sequence case-conversion algorithms.
0028     Algorithms convert each element in the input sequence to the
0029     desired case using provided locales.
0030 */
0031 
0032 namespace boost {
0033     namespace algorithm {
0034 
0035 //  to_lower  -----------------------------------------------//
0036 
0037         //! Convert to lower case
0038         /*!
0039             Each element of the input sequence is converted to lower
0040             case. The result is a copy of the input converted to lower case.
0041             It is returned as a sequence or copied to the output iterator.
0042 
0043             \param Output An output iterator to which the result will be copied
0044             \param Input An input range
0045             \param Loc A locale used for conversion
0046             \return 
0047                 An output iterator pointing just after the last inserted character or
0048                 a copy of the input
0049 
0050             \note The second variant of this function provides the strong exception-safety guarantee
0051                 
0052         */
0053         template<typename OutputIteratorT, typename RangeT>
0054         inline OutputIteratorT 
0055         to_lower_copy(
0056             OutputIteratorT Output,
0057             const RangeT& Input,
0058             const std::locale& Loc=std::locale())
0059         {
0060             return ::boost::algorithm::detail::transform_range_copy( 
0061                Output,
0062                ::boost::as_literal(Input),
0063                ::boost::algorithm::detail::to_lowerF<
0064                     typename range_value<RangeT>::type >(Loc));
0065         }
0066 
0067         //! Convert to lower case
0068         /*!
0069             \overload
0070         */
0071         template<typename SequenceT>
0072         inline SequenceT to_lower_copy( 
0073             const SequenceT& Input, 
0074             const std::locale& Loc=std::locale())
0075         {
0076             return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
0077                 Input,
0078                 ::boost::algorithm::detail::to_lowerF<
0079                     typename range_value<SequenceT>::type >(Loc));
0080         }
0081 
0082         //! Convert to lower case
0083         /*!
0084             Each element of the input sequence is converted to lower
0085             case. The input sequence is modified in-place.
0086 
0087             \param Input A range
0088             \param Loc a locale used for conversion
0089         */
0090         template<typename WritableRangeT>
0091         inline void to_lower( 
0092             WritableRangeT& Input, 
0093             const std::locale& Loc=std::locale())
0094         {
0095             ::boost::algorithm::detail::transform_range(
0096                 ::boost::as_literal(Input),
0097                 ::boost::algorithm::detail::to_lowerF<
0098                     typename range_value<WritableRangeT>::type >(Loc));
0099         }
0100         
0101 //  to_upper  -----------------------------------------------//
0102 
0103         //! Convert to upper case
0104         /*!
0105             Each element of the input sequence is converted to upper
0106             case. The result is a copy of the input converted to upper case.
0107             It is returned as a sequence or copied to the output iterator
0108 
0109             \param Output An output iterator to which the result will be copied
0110             \param Input An input range
0111             \param Loc A locale used for conversion
0112             \return 
0113                 An output iterator pointing just after the last inserted character or
0114                 a copy of the input
0115 
0116             \note The second variant of this function provides the strong exception-safety guarantee
0117         */
0118         template<typename OutputIteratorT, typename RangeT>
0119         inline OutputIteratorT 
0120         to_upper_copy(
0121             OutputIteratorT Output,
0122             const RangeT& Input,
0123             const std::locale& Loc=std::locale())
0124         {
0125             return ::boost::algorithm::detail::transform_range_copy( 
0126                Output,
0127                ::boost::as_literal(Input),
0128                ::boost::algorithm::detail::to_upperF<
0129                     typename range_value<RangeT>::type >(Loc));
0130         }
0131 
0132         //! Convert to upper case
0133         /*!
0134             \overload
0135         */
0136         template<typename SequenceT>
0137         inline SequenceT to_upper_copy( 
0138             const SequenceT& Input, 
0139             const std::locale& Loc=std::locale())
0140         {
0141             return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
0142                 Input,
0143                 ::boost::algorithm::detail::to_upperF<
0144                     typename range_value<SequenceT>::type >(Loc));
0145         }
0146 
0147         //! Convert to upper case
0148         /*!
0149             Each element of the input sequence is converted to upper
0150             case. The input sequence is modified in-place.
0151 
0152             \param Input An input range
0153             \param Loc a locale used for conversion
0154         */
0155         template<typename WritableRangeT>
0156         inline void to_upper( 
0157             WritableRangeT& Input, 
0158             const std::locale& Loc=std::locale())
0159         {
0160             ::boost::algorithm::detail::transform_range(
0161                 ::boost::as_literal(Input),
0162                 ::boost::algorithm::detail::to_upperF<
0163                     typename range_value<WritableRangeT>::type >(Loc));
0164         }
0165 
0166     } // namespace algorithm
0167 
0168     // pull names to the boost namespace
0169     using algorithm::to_lower;
0170     using algorithm::to_lower_copy;
0171     using algorithm::to_upper;
0172     using algorithm::to_upper_copy;
0173 
0174 } // namespace boost
0175 
0176 #endif  // BOOST_STRING_CASE_CONV_HPP