annotate DEPENDENCIES/generic/include/boost/algorithm/string/find_format.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 find_format.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_FIND_FORMAT_HPP
Chris@16 12 #define BOOST_STRING_FIND_FORMAT_HPP
Chris@16 13
Chris@16 14 #include <deque>
Chris@16 15 #include <boost/detail/iterator.hpp>
Chris@16 16 #include <boost/range/iterator_range_core.hpp>
Chris@16 17 #include <boost/range/begin.hpp>
Chris@16 18 #include <boost/range/end.hpp>
Chris@16 19 #include <boost/range/const_iterator.hpp>
Chris@16 20 #include <boost/range/as_literal.hpp>
Chris@16 21
Chris@16 22 #include <boost/algorithm/string/concept.hpp>
Chris@16 23 #include <boost/algorithm/string/detail/find_format.hpp>
Chris@16 24 #include <boost/algorithm/string/detail/find_format_all.hpp>
Chris@16 25
Chris@16 26 /*! \file
Chris@16 27 Defines generic replace algorithms. Each algorithm replaces
Chris@16 28 part(s) of the input. The part to be replaced is looked up using a Finder object.
Chris@16 29 Result of finding is then used by a Formatter object to generate the replacement.
Chris@16 30 */
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33 namespace algorithm {
Chris@16 34
Chris@16 35 // generic replace -----------------------------------------------------------------//
Chris@16 36
Chris@16 37 //! Generic replace algorithm
Chris@16 38 /*!
Chris@16 39 Use the Finder to search for a substring. Use the Formatter to format
Chris@16 40 this substring and replace it in the input.
Chris@16 41 The result is a modified copy of the input. It is returned as a sequence
Chris@16 42 or copied to the output iterator.
Chris@16 43
Chris@16 44 \param Output An output iterator to which the result will be copied
Chris@16 45 \param Input An input sequence
Chris@16 46 \param Finder A Finder object used to search for a match to be replaced
Chris@16 47 \param Formatter A Formatter object used to format a match
Chris@16 48 \return An output iterator pointing just after the last inserted character or
Chris@16 49 a modified copy of the input
Chris@16 50
Chris@16 51 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 52 */
Chris@16 53 template<
Chris@16 54 typename OutputIteratorT,
Chris@16 55 typename RangeT,
Chris@16 56 typename FinderT,
Chris@16 57 typename FormatterT>
Chris@16 58 inline OutputIteratorT find_format_copy(
Chris@16 59 OutputIteratorT Output,
Chris@16 60 const RangeT& Input,
Chris@16 61 FinderT Finder,
Chris@16 62 FormatterT Formatter )
Chris@16 63 {
Chris@16 64 // Concept check
Chris@16 65 BOOST_CONCEPT_ASSERT((
Chris@16 66 FinderConcept<
Chris@16 67 FinderT,
Chris@16 68 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
Chris@16 69 ));
Chris@16 70 BOOST_CONCEPT_ASSERT((
Chris@16 71 FormatterConcept<
Chris@16 72 FormatterT,
Chris@16 73 FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
Chris@16 74 ));
Chris@16 75
Chris@16 76 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
Chris@16 77
Chris@16 78 return detail::find_format_copy_impl(
Chris@16 79 Output,
Chris@16 80 lit_input,
Chris@16 81 Formatter,
Chris@16 82 Finder( ::boost::begin(lit_input), ::boost::end(lit_input) ) );
Chris@16 83 }
Chris@16 84
Chris@16 85 //! Generic replace algorithm
Chris@16 86 /*!
Chris@16 87 \overload
Chris@16 88 */
Chris@16 89 template<
Chris@16 90 typename SequenceT,
Chris@16 91 typename FinderT,
Chris@16 92 typename FormatterT>
Chris@16 93 inline SequenceT find_format_copy(
Chris@16 94 const SequenceT& Input,
Chris@16 95 FinderT Finder,
Chris@16 96 FormatterT Formatter )
Chris@16 97 {
Chris@16 98 // Concept check
Chris@16 99 BOOST_CONCEPT_ASSERT((
Chris@16 100 FinderConcept<
Chris@16 101 FinderT,
Chris@16 102 BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 103 ));
Chris@16 104 BOOST_CONCEPT_ASSERT((
Chris@16 105 FormatterConcept<
Chris@16 106 FormatterT,
Chris@16 107 FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 108 ));
Chris@16 109
Chris@16 110 return detail::find_format_copy_impl(
Chris@16 111 Input,
Chris@16 112 Formatter,
Chris@16 113 Finder(::boost::begin(Input), ::boost::end(Input)));
Chris@16 114 }
Chris@16 115
Chris@16 116 //! Generic replace algorithm
Chris@16 117 /*!
Chris@16 118 Use the Finder to search for a substring. Use the Formatter to format
Chris@16 119 this substring and replace it in the input. The input is modified in-place.
Chris@16 120
Chris@16 121 \param Input An input sequence
Chris@16 122 \param Finder A Finder object used to search for a match to be replaced
Chris@16 123 \param Formatter A Formatter object used to format a match
Chris@16 124 */
Chris@16 125 template<
Chris@16 126 typename SequenceT,
Chris@16 127 typename FinderT,
Chris@16 128 typename FormatterT>
Chris@16 129 inline void find_format(
Chris@16 130 SequenceT& Input,
Chris@16 131 FinderT Finder,
Chris@16 132 FormatterT Formatter)
Chris@16 133 {
Chris@16 134 // Concept check
Chris@16 135 BOOST_CONCEPT_ASSERT((
Chris@16 136 FinderConcept<
Chris@16 137 FinderT,
Chris@16 138 BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 139 ));
Chris@16 140 BOOST_CONCEPT_ASSERT((
Chris@16 141 FormatterConcept<
Chris@16 142 FormatterT,
Chris@16 143 FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 144 ));
Chris@16 145
Chris@16 146 detail::find_format_impl(
Chris@16 147 Input,
Chris@16 148 Formatter,
Chris@16 149 Finder(::boost::begin(Input), ::boost::end(Input)));
Chris@16 150 }
Chris@16 151
Chris@16 152
Chris@16 153 // find_format_all generic ----------------------------------------------------------------//
Chris@16 154
Chris@16 155 //! Generic replace all algorithm
Chris@16 156 /*!
Chris@16 157 Use the Finder to search for a substring. Use the Formatter to format
Chris@16 158 this substring and replace it in the input. Repeat this for all matching
Chris@16 159 substrings.
Chris@16 160 The result is a modified copy of the input. It is returned as a sequence
Chris@16 161 or copied to the output iterator.
Chris@16 162
Chris@16 163 \param Output An output iterator to which the result will be copied
Chris@16 164 \param Input An input sequence
Chris@16 165 \param Finder A Finder object used to search for a match to be replaced
Chris@16 166 \param Formatter A Formatter object used to format a match
Chris@16 167 \return An output iterator pointing just after the last inserted character or
Chris@16 168 a modified copy of the input
Chris@16 169
Chris@16 170 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 171 */
Chris@16 172 template<
Chris@16 173 typename OutputIteratorT,
Chris@16 174 typename RangeT,
Chris@16 175 typename FinderT,
Chris@16 176 typename FormatterT>
Chris@16 177 inline OutputIteratorT find_format_all_copy(
Chris@16 178 OutputIteratorT Output,
Chris@16 179 const RangeT& Input,
Chris@16 180 FinderT Finder,
Chris@16 181 FormatterT Formatter)
Chris@16 182 {
Chris@16 183 // Concept check
Chris@16 184 BOOST_CONCEPT_ASSERT((
Chris@16 185 FinderConcept<
Chris@16 186 FinderT,
Chris@16 187 BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
Chris@16 188 ));
Chris@16 189 BOOST_CONCEPT_ASSERT((
Chris@16 190 FormatterConcept<
Chris@16 191 FormatterT,
Chris@16 192 FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
Chris@16 193 ));
Chris@16 194
Chris@16 195 iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
Chris@16 196
Chris@16 197 return detail::find_format_all_copy_impl(
Chris@16 198 Output,
Chris@16 199 lit_input,
Chris@16 200 Finder,
Chris@16 201 Formatter,
Chris@16 202 Finder(::boost::begin(lit_input), ::boost::end(lit_input)));
Chris@16 203 }
Chris@16 204
Chris@16 205 //! Generic replace all algorithm
Chris@16 206 /*!
Chris@16 207 \overload
Chris@16 208 */
Chris@16 209 template<
Chris@16 210 typename SequenceT,
Chris@16 211 typename FinderT,
Chris@16 212 typename FormatterT >
Chris@16 213 inline SequenceT find_format_all_copy(
Chris@16 214 const SequenceT& Input,
Chris@16 215 FinderT Finder,
Chris@16 216 FormatterT Formatter )
Chris@16 217 {
Chris@16 218 // Concept check
Chris@16 219 BOOST_CONCEPT_ASSERT((
Chris@16 220 FinderConcept<
Chris@16 221 FinderT,
Chris@16 222 BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 223 ));
Chris@16 224 BOOST_CONCEPT_ASSERT((
Chris@16 225 FormatterConcept<
Chris@16 226 FormatterT,
Chris@16 227 FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 228 ));
Chris@16 229
Chris@16 230 return detail::find_format_all_copy_impl(
Chris@16 231 Input,
Chris@16 232 Finder,
Chris@16 233 Formatter,
Chris@16 234 Finder( ::boost::begin(Input), ::boost::end(Input) ) );
Chris@16 235 }
Chris@16 236
Chris@16 237 //! Generic replace all algorithm
Chris@16 238 /*!
Chris@16 239 Use the Finder to search for a substring. Use the Formatter to format
Chris@16 240 this substring and replace it in the input. Repeat this for all matching
Chris@16 241 substrings.The input is modified in-place.
Chris@16 242
Chris@16 243 \param Input An input sequence
Chris@16 244 \param Finder A Finder object used to search for a match to be replaced
Chris@16 245 \param Formatter A Formatter object used to format a match
Chris@16 246 */
Chris@16 247 template<
Chris@16 248 typename SequenceT,
Chris@16 249 typename FinderT,
Chris@16 250 typename FormatterT >
Chris@16 251 inline void find_format_all(
Chris@16 252 SequenceT& Input,
Chris@16 253 FinderT Finder,
Chris@16 254 FormatterT Formatter )
Chris@16 255 {
Chris@16 256 // Concept check
Chris@16 257 BOOST_CONCEPT_ASSERT((
Chris@16 258 FinderConcept<
Chris@16 259 FinderT,
Chris@16 260 BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 261 ));
Chris@16 262 BOOST_CONCEPT_ASSERT((
Chris@16 263 FormatterConcept<
Chris@16 264 FormatterT,
Chris@16 265 FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
Chris@16 266 ));
Chris@16 267
Chris@16 268 detail::find_format_all_impl(
Chris@16 269 Input,
Chris@16 270 Finder,
Chris@16 271 Formatter,
Chris@16 272 Finder(::boost::begin(Input), ::boost::end(Input)));
Chris@16 273
Chris@16 274 }
Chris@16 275
Chris@16 276 } // namespace algorithm
Chris@16 277
Chris@16 278 // pull the names to the boost namespace
Chris@16 279 using algorithm::find_format_copy;
Chris@16 280 using algorithm::find_format;
Chris@16 281 using algorithm::find_format_all_copy;
Chris@16 282 using algorithm::find_format_all;
Chris@16 283
Chris@16 284 } // namespace boost
Chris@16 285
Chris@16 286
Chris@16 287 #endif // BOOST_STRING_FIND_FORMAT_HPP