annotate DEPENDENCIES/generic/include/boost/algorithm/string/trim_all.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost string_algo library trim.hpp header file ---------------------------//
Chris@16 2
Chris@16 3 // Copyright Pavol Droba 2002-2003.
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // See http://www.boost.org/ for updates, documentation, and revision history.
Chris@16 10
Chris@16 11 #ifndef BOOST_STRING_TRIM_ALL_HPP
Chris@16 12 #define BOOST_STRING_TRIM_ALL_HPP
Chris@16 13
Chris@16 14 #include <boost/algorithm/string/config.hpp>
Chris@16 15
Chris@16 16 #include <boost/algorithm/string/trim.hpp>
Chris@16 17 #include <boost/algorithm/string/classification.hpp>
Chris@16 18 #include <boost/algorithm/string/find_format.hpp>
Chris@16 19 #include <boost/algorithm/string/formatter.hpp>
Chris@16 20 #include <boost/algorithm/string/finder.hpp>
Chris@16 21 #include <locale>
Chris@16 22
Chris@16 23 /*! \file
Chris@16 24 Defines trim_all algorithms.
Chris@16 25
Chris@16 26 Just like \c trim, \c trim_all removes all trailing and leading spaces from a
Chris@16 27 sequence (string). In addition, spaces in the middle of the sequence are truncated
Chris@16 28 to just one character. Space is recognized using given locales.
Chris@16 29
Chris@16 30 \c trim_fill acts as trim_all, but the spaces in the middle are replaces with
Chris@16 31 a user-define sequence of character.
Chris@16 32
Chris@16 33 Parametric (\c _if) variants use a predicate (functor) to select which characters
Chris@16 34 are to be trimmed..
Chris@16 35 Functions take a selection predicate as a parameter, which is used to determine
Chris@16 36 whether a character is a space. Common predicates are provided in classification.hpp header.
Chris@16 37
Chris@16 38 */
Chris@16 39
Chris@16 40 namespace boost {
Chris@16 41 namespace algorithm {
Chris@16 42
Chris@16 43 // multi line trim ----------------------------------------------- //
Chris@16 44
Chris@16 45 //! Trim All - parametric
Chris@16 46 /*!
Chris@16 47 Remove all leading and trailing spaces from the input and
Chris@16 48 compress all other spaces to a single character.
Chris@16 49 The result is a trimmed copy of the input
Chris@16 50
Chris@16 51 \param Input An input sequence
Chris@16 52 \param IsSpace A unary predicate identifying spaces
Chris@16 53 \return A trimmed copy of the input
Chris@16 54 */
Chris@16 55 template<typename SequenceT, typename PredicateT>
Chris@16 56 inline SequenceT trim_all_copy_if(const SequenceT& Input, PredicateT IsSpace)
Chris@16 57 {
Chris@16 58 return
Chris@16 59 ::boost::find_format_all_copy(
Chris@16 60 ::boost::trim_copy_if(Input, IsSpace),
Chris@16 61 ::boost::token_finder(IsSpace, ::boost::token_compress_on),
Chris@16 62 ::boost::dissect_formatter(::boost::head_finder(1)));
Chris@16 63 }
Chris@16 64
Chris@16 65
Chris@16 66 //! Trim All
Chris@16 67 /*!
Chris@16 68 Remove all leading and trailing spaces from the input and
Chris@16 69 compress all other spaces to a single character.
Chris@16 70 The input sequence is modified in-place.
Chris@16 71
Chris@16 72 \param Input An input sequence
Chris@16 73 \param IsSpace A unary predicate identifying spaces
Chris@16 74 */
Chris@16 75 template<typename SequenceT, typename PredicateT>
Chris@16 76 inline void trim_all_if(SequenceT& Input, PredicateT IsSpace)
Chris@16 77 {
Chris@16 78 ::boost::trim_if(Input, IsSpace);
Chris@16 79 ::boost::find_format_all(
Chris@16 80 Input,
Chris@16 81 ::boost::token_finder(IsSpace, ::boost::token_compress_on),
Chris@16 82 ::boost::dissect_formatter(::boost::head_finder(1)));
Chris@16 83 }
Chris@16 84
Chris@16 85
Chris@16 86 //! Trim All
Chris@16 87 /*!
Chris@16 88 Remove all leading and trailing spaces from the input and
Chris@16 89 compress all other spaces to a single character.
Chris@16 90 The result is a trimmed copy of the input
Chris@16 91
Chris@16 92 \param Input An input sequence
Chris@16 93 \param Loc A locale used for 'space' classification
Chris@16 94 \return A trimmed copy of the input
Chris@16 95 */
Chris@16 96 template<typename SequenceT>
Chris@16 97 inline SequenceT trim_all_copy(const SequenceT& Input, const std::locale& Loc =std::locale())
Chris@16 98 {
Chris@16 99 return trim_all_copy_if(Input, ::boost::is_space(Loc));
Chris@16 100 }
Chris@16 101
Chris@16 102
Chris@16 103 //! Trim All
Chris@16 104 /*!
Chris@16 105 Remove all leading and trailing spaces from the input and
Chris@16 106 compress all other spaces to a single character.
Chris@16 107 The input sequence is modified in-place.
Chris@16 108
Chris@16 109 \param Input An input sequence
Chris@16 110 \param Loc A locale used for 'space' classification
Chris@16 111 \return A trimmed copy of the input
Chris@16 112 */
Chris@16 113 template<typename SequenceT>
Chris@16 114 inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale())
Chris@16 115 {
Chris@16 116 trim_all_if(Input, ::boost::is_space(Loc));
Chris@16 117 }
Chris@16 118
Chris@16 119
Chris@16 120 //! Trim Fill - parametric
Chris@16 121 /*!
Chris@16 122 Remove all leading and trailing spaces from the input and
Chris@16 123 replace all every block of consecutive spaces with a fill string
Chris@16 124 defined by user.
Chris@16 125 The result is a trimmed copy of the input
Chris@16 126
Chris@16 127 \param Input An input sequence
Chris@16 128 \param Fill A string used to fill the inner spaces
Chris@16 129 \param IsSpace A unary predicate identifying spaces
Chris@16 130 \return A trimmed copy of the input
Chris@16 131 */
Chris@16 132 template<typename SequenceT, typename RangeT, typename PredicateT>
Chris@16 133 inline SequenceT trim_fill_copy_if(const SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
Chris@16 134 {
Chris@16 135 return
Chris@16 136 ::boost::find_format_all_copy(
Chris@16 137 ::boost::trim_copy_if(Input, IsSpace),
Chris@16 138 ::boost::token_finder(IsSpace, ::boost::token_compress_on),
Chris@16 139 ::boost::const_formatter(::boost::as_literal(Fill)));
Chris@16 140 }
Chris@16 141
Chris@16 142
Chris@16 143 //! Trim Fill
Chris@16 144 /*!
Chris@16 145 Remove all leading and trailing spaces from the input and
Chris@16 146 replace all every block of consecutive spaces with a fill string
Chris@16 147 defined by user.
Chris@16 148 The input sequence is modified in-place.
Chris@16 149
Chris@16 150 \param Input An input sequence
Chris@16 151 \param Fill A string used to fill the inner spaces
Chris@16 152 \param IsSpace A unary predicate identifying spaces
Chris@16 153 */
Chris@16 154 template<typename SequenceT, typename RangeT, typename PredicateT>
Chris@16 155 inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
Chris@16 156 {
Chris@16 157 ::boost::trim_if(Input, IsSpace);
Chris@16 158 ::boost::find_format_all(
Chris@16 159 Input,
Chris@16 160 ::boost::token_finder(IsSpace, ::boost::token_compress_on),
Chris@16 161 ::boost::const_formatter(::boost::as_literal(Fill)));
Chris@16 162 }
Chris@16 163
Chris@16 164
Chris@16 165 //! Trim Fill
Chris@16 166 /*!
Chris@16 167 Remove all leading and trailing spaces from the input and
Chris@16 168 replace all every block of consecutive spaces with a fill string
Chris@16 169 defined by user.
Chris@16 170 The result is a trimmed copy of the input
Chris@16 171
Chris@16 172 \param Input An input sequence
Chris@16 173 \param Fill A string used to fill the inner spaces
Chris@16 174 \param Loc A locale used for 'space' classification
Chris@16 175 \return A trimmed copy of the input
Chris@16 176 */
Chris@16 177 template<typename SequenceT, typename RangeT>
Chris@16 178 inline SequenceT trim_fill_copy(const SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
Chris@16 179 {
Chris@16 180 return trim_fill_copy_if(Input, Fill, ::boost::is_space(Loc));
Chris@16 181 }
Chris@16 182
Chris@16 183
Chris@16 184 //! Trim Fill
Chris@16 185 /*!
Chris@16 186 Remove all leading and trailing spaces from the input and
Chris@16 187 replace all every block of consecutive spaces with a fill string
Chris@16 188 defined by user.
Chris@16 189 The input sequence is modified in-place.
Chris@16 190
Chris@16 191 \param Input An input sequence
Chris@16 192 \param Fill A string used to fill the inner spaces
Chris@16 193 \param Loc A locale used for 'space' classification
Chris@16 194 \return A trimmed copy of the input
Chris@16 195 */
Chris@16 196 template<typename SequenceT, typename RangeT>
Chris@16 197 inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
Chris@16 198 {
Chris@16 199 trim_fill_if(Input, Fill, ::boost::is_space(Loc));
Chris@16 200 }
Chris@16 201
Chris@16 202
Chris@16 203 } // namespace algorithm
Chris@16 204
Chris@16 205 // pull names to the boost namespace
Chris@16 206 using algorithm::trim_all;
Chris@16 207 using algorithm::trim_all_if;
Chris@16 208 using algorithm::trim_all_copy;
Chris@16 209 using algorithm::trim_all_copy_if;
Chris@16 210 using algorithm::trim_fill;
Chris@16 211 using algorithm::trim_fill_if;
Chris@16 212 using algorithm::trim_fill_copy;
Chris@16 213 using algorithm::trim_fill_copy_if;
Chris@16 214
Chris@16 215 } // namespace boost
Chris@16 216
Chris@16 217 #endif // BOOST_STRING_TRIM_ALL_HPP