annotate DEPENDENCIES/generic/include/boost/algorithm/string/replace.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 replace.hpp header file ---------------------------//
Chris@16 2
Chris@16 3 // Copyright Pavol Droba 2002-2006.
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_REPLACE_HPP
Chris@16 12 #define BOOST_STRING_REPLACE_HPP
Chris@16 13
Chris@16 14 #include <boost/algorithm/string/config.hpp>
Chris@16 15
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/iterator.hpp>
Chris@16 20 #include <boost/range/const_iterator.hpp>
Chris@16 21
Chris@16 22 #include <boost/algorithm/string/find_format.hpp>
Chris@16 23 #include <boost/algorithm/string/finder.hpp>
Chris@16 24 #include <boost/algorithm/string/formatter.hpp>
Chris@16 25 #include <boost/algorithm/string/compare.hpp>
Chris@16 26
Chris@16 27 /*! \file
Chris@16 28 Defines various replace algorithms. Each algorithm replaces
Chris@16 29 part(s) of the input according to set of searching and replace criteria.
Chris@16 30 */
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33 namespace algorithm {
Chris@16 34
Chris@16 35 // replace_range --------------------------------------------------------------------//
Chris@16 36
Chris@16 37 //! Replace range algorithm
Chris@16 38 /*!
Chris@16 39 Replace the given range in the input string.
Chris@16 40 The result is a modified copy of the input. It is returned as a sequence
Chris@16 41 or copied to the output iterator.
Chris@16 42
Chris@16 43 \param Output An output iterator to which the result will be copied
Chris@16 44 \param Input An input string
Chris@16 45 \param SearchRange A range in the input to be substituted
Chris@16 46 \param Format A substitute string
Chris@16 47 \return An output iterator pointing just after the last inserted character or
Chris@16 48 a modified copy of the input
Chris@16 49
Chris@16 50 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 51 */
Chris@16 52 template<
Chris@16 53 typename OutputIteratorT,
Chris@16 54 typename Range1T,
Chris@16 55 typename Range2T>
Chris@16 56 inline OutputIteratorT replace_range_copy(
Chris@16 57 OutputIteratorT Output,
Chris@16 58 const Range1T& Input,
Chris@16 59 const iterator_range<
Chris@16 60 BOOST_STRING_TYPENAME
Chris@16 61 range_const_iterator<Range1T>::type>& SearchRange,
Chris@16 62 const Range2T& Format)
Chris@16 63 {
Chris@16 64 return ::boost::algorithm::find_format_copy(
Chris@16 65 Output,
Chris@16 66 Input,
Chris@16 67 ::boost::algorithm::range_finder(SearchRange),
Chris@16 68 ::boost::algorithm::const_formatter(Format));
Chris@16 69 }
Chris@16 70
Chris@16 71 //! Replace range algorithm
Chris@16 72 /*!
Chris@16 73 \overload
Chris@16 74 */
Chris@16 75 template<typename SequenceT, typename RangeT>
Chris@16 76 inline SequenceT replace_range_copy(
Chris@16 77 const SequenceT& Input,
Chris@16 78 const iterator_range<
Chris@16 79 BOOST_STRING_TYPENAME
Chris@16 80 range_const_iterator<SequenceT>::type>& SearchRange,
Chris@16 81 const RangeT& Format)
Chris@16 82 {
Chris@16 83 return ::boost::algorithm::find_format_copy(
Chris@16 84 Input,
Chris@16 85 ::boost::algorithm::range_finder(SearchRange),
Chris@16 86 ::boost::algorithm::const_formatter(Format));
Chris@16 87 }
Chris@16 88
Chris@16 89 //! Replace range algorithm
Chris@16 90 /*!
Chris@16 91 Replace the given range in the input string.
Chris@16 92 The input sequence is modified in-place.
Chris@16 93
Chris@16 94 \param Input An input string
Chris@16 95 \param SearchRange A range in the input to be substituted
Chris@16 96 \param Format A substitute string
Chris@16 97 */
Chris@16 98 template<typename SequenceT, typename RangeT>
Chris@16 99 inline void replace_range(
Chris@16 100 SequenceT& Input,
Chris@16 101 const iterator_range<
Chris@16 102 BOOST_STRING_TYPENAME
Chris@16 103 range_iterator<SequenceT>::type>& SearchRange,
Chris@16 104 const RangeT& Format)
Chris@16 105 {
Chris@16 106 ::boost::algorithm::find_format(
Chris@16 107 Input,
Chris@16 108 ::boost::algorithm::range_finder(SearchRange),
Chris@16 109 ::boost::algorithm::const_formatter(Format));
Chris@16 110 }
Chris@16 111
Chris@16 112 // replace_first --------------------------------------------------------------------//
Chris@16 113
Chris@16 114 //! Replace first algorithm
Chris@16 115 /*!
Chris@16 116 Replace the first match of the search substring in the input
Chris@16 117 with the format string.
Chris@16 118 The result is a modified copy of the input. It is returned as a sequence
Chris@16 119 or copied to the output iterator.
Chris@16 120
Chris@16 121 \param Output An output iterator to which the result will be copied
Chris@16 122 \param Input An input string
Chris@16 123 \param Search A substring to be searched for
Chris@16 124 \param Format A substitute string
Chris@16 125 \return An output iterator pointing just after the last inserted character or
Chris@16 126 a modified copy of the input
Chris@16 127
Chris@16 128 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 129 */
Chris@16 130 template<
Chris@16 131 typename OutputIteratorT,
Chris@16 132 typename Range1T,
Chris@16 133 typename Range2T,
Chris@16 134 typename Range3T>
Chris@16 135 inline OutputIteratorT replace_first_copy(
Chris@16 136 OutputIteratorT Output,
Chris@16 137 const Range1T& Input,
Chris@16 138 const Range2T& Search,
Chris@16 139 const Range3T& Format)
Chris@16 140 {
Chris@16 141 return ::boost::algorithm::find_format_copy(
Chris@16 142 Output,
Chris@16 143 Input,
Chris@16 144 ::boost::algorithm::first_finder(Search),
Chris@16 145 ::boost::algorithm::const_formatter(Format) );
Chris@16 146 }
Chris@16 147
Chris@16 148 //! Replace first algorithm
Chris@16 149 /*!
Chris@16 150 \overload
Chris@16 151 */
Chris@16 152 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 153 inline SequenceT replace_first_copy(
Chris@16 154 const SequenceT& Input,
Chris@16 155 const Range1T& Search,
Chris@16 156 const Range2T& Format )
Chris@16 157 {
Chris@16 158 return ::boost::algorithm::find_format_copy(
Chris@16 159 Input,
Chris@16 160 ::boost::algorithm::first_finder(Search),
Chris@16 161 ::boost::algorithm::const_formatter(Format) );
Chris@16 162 }
Chris@16 163
Chris@16 164 //! Replace first algorithm
Chris@16 165 /*!
Chris@16 166 replace the first match of the search substring in the input
Chris@16 167 with the format string. The input sequence is modified in-place.
Chris@16 168
Chris@16 169 \param Input An input string
Chris@16 170 \param Search A substring to be searched for
Chris@16 171 \param Format A substitute string
Chris@16 172 */
Chris@16 173 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 174 inline void replace_first(
Chris@16 175 SequenceT& Input,
Chris@16 176 const Range1T& Search,
Chris@16 177 const Range2T& Format )
Chris@16 178 {
Chris@16 179 ::boost::algorithm::find_format(
Chris@16 180 Input,
Chris@16 181 ::boost::algorithm::first_finder(Search),
Chris@16 182 ::boost::algorithm::const_formatter(Format) );
Chris@16 183 }
Chris@16 184
Chris@16 185 // replace_first ( case insensitive ) ---------------------------------------------//
Chris@16 186
Chris@16 187 //! Replace first algorithm ( case insensitive )
Chris@16 188 /*!
Chris@16 189 Replace the first match of the search substring in the input
Chris@16 190 with the format string.
Chris@16 191 The result is a modified copy of the input. It is returned as a sequence
Chris@16 192 or copied to the output iterator.
Chris@16 193 Searching is case insensitive.
Chris@16 194
Chris@16 195 \param Output An output iterator to which the result will be copied
Chris@16 196 \param Input An input string
Chris@16 197 \param Search A substring to be searched for
Chris@16 198 \param Format A substitute string
Chris@16 199 \param Loc A locale used for case insensitive comparison
Chris@16 200 \return An output iterator pointing just after the last inserted character or
Chris@16 201 a modified copy of the input
Chris@16 202
Chris@16 203 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 204 */
Chris@16 205 template<
Chris@16 206 typename OutputIteratorT,
Chris@16 207 typename Range1T,
Chris@16 208 typename Range2T,
Chris@16 209 typename Range3T>
Chris@16 210 inline OutputIteratorT ireplace_first_copy(
Chris@16 211 OutputIteratorT Output,
Chris@16 212 const Range1T& Input,
Chris@16 213 const Range2T& Search,
Chris@16 214 const Range3T& Format,
Chris@16 215 const std::locale& Loc=std::locale() )
Chris@16 216 {
Chris@16 217 return ::boost::algorithm::find_format_copy(
Chris@16 218 Output,
Chris@16 219 Input,
Chris@16 220 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 221 ::boost::algorithm::const_formatter(Format) );
Chris@16 222 }
Chris@16 223
Chris@16 224 //! Replace first algorithm ( case insensitive )
Chris@16 225 /*!
Chris@16 226 \overload
Chris@16 227 */
Chris@16 228 template<typename SequenceT, typename Range2T, typename Range1T>
Chris@16 229 inline SequenceT ireplace_first_copy(
Chris@16 230 const SequenceT& Input,
Chris@16 231 const Range2T& Search,
Chris@16 232 const Range1T& Format,
Chris@16 233 const std::locale& Loc=std::locale() )
Chris@16 234 {
Chris@16 235 return ::boost::algorithm::find_format_copy(
Chris@16 236 Input,
Chris@16 237 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 238 ::boost::algorithm::const_formatter(Format) );
Chris@16 239 }
Chris@16 240
Chris@16 241 //! Replace first algorithm ( case insensitive )
Chris@16 242 /*!
Chris@16 243 Replace the first match of the search substring in the input
Chris@16 244 with the format string. Input sequence is modified in-place.
Chris@16 245 Searching is case insensitive.
Chris@16 246
Chris@16 247 \param Input An input string
Chris@16 248 \param Search A substring to be searched for
Chris@16 249 \param Format A substitute string
Chris@16 250 \param Loc A locale used for case insensitive comparison
Chris@16 251 */
Chris@16 252 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 253 inline void ireplace_first(
Chris@16 254 SequenceT& Input,
Chris@16 255 const Range1T& Search,
Chris@16 256 const Range2T& Format,
Chris@16 257 const std::locale& Loc=std::locale() )
Chris@16 258 {
Chris@16 259 ::boost::algorithm::find_format(
Chris@16 260 Input,
Chris@16 261 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 262 ::boost::algorithm::const_formatter(Format) );
Chris@16 263 }
Chris@16 264
Chris@16 265 // replace_last --------------------------------------------------------------------//
Chris@16 266
Chris@16 267 //! Replace last algorithm
Chris@16 268 /*!
Chris@16 269 Replace the last match of the search string in the input
Chris@16 270 with the format string.
Chris@16 271 The result is a modified copy of the input. It is returned as a sequence
Chris@16 272 or copied to the output iterator.
Chris@16 273
Chris@16 274 \param Output An output iterator to which the result will be copied
Chris@16 275 \param Input An input string
Chris@16 276 \param Search A substring to be searched for
Chris@16 277 \param Format A substitute string
Chris@16 278 \return An output iterator pointing just after the last inserted character or
Chris@16 279 a modified copy of the input
Chris@16 280
Chris@16 281 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 282 */
Chris@16 283 template<
Chris@16 284 typename OutputIteratorT,
Chris@16 285 typename Range1T,
Chris@16 286 typename Range2T,
Chris@16 287 typename Range3T>
Chris@16 288 inline OutputIteratorT replace_last_copy(
Chris@16 289 OutputIteratorT Output,
Chris@16 290 const Range1T& Input,
Chris@16 291 const Range2T& Search,
Chris@16 292 const Range3T& Format )
Chris@16 293 {
Chris@16 294 return ::boost::algorithm::find_format_copy(
Chris@16 295 Output,
Chris@16 296 Input,
Chris@16 297 ::boost::algorithm::last_finder(Search),
Chris@16 298 ::boost::algorithm::const_formatter(Format) );
Chris@16 299 }
Chris@16 300
Chris@16 301 //! Replace last algorithm
Chris@16 302 /*!
Chris@16 303 \overload
Chris@16 304 */
Chris@16 305 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 306 inline SequenceT replace_last_copy(
Chris@16 307 const SequenceT& Input,
Chris@16 308 const Range1T& Search,
Chris@16 309 const Range2T& Format )
Chris@16 310 {
Chris@16 311 return ::boost::algorithm::find_format_copy(
Chris@16 312 Input,
Chris@16 313 ::boost::algorithm::last_finder(Search),
Chris@16 314 ::boost::algorithm::const_formatter(Format) );
Chris@16 315 }
Chris@16 316
Chris@16 317 //! Replace last algorithm
Chris@16 318 /*!
Chris@16 319 Replace the last match of the search string in the input
Chris@16 320 with the format string. Input sequence is modified in-place.
Chris@16 321
Chris@16 322 \param Input An input string
Chris@16 323 \param Search A substring to be searched for
Chris@16 324 \param Format A substitute string
Chris@16 325 */
Chris@16 326 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 327 inline void replace_last(
Chris@16 328 SequenceT& Input,
Chris@16 329 const Range1T& Search,
Chris@16 330 const Range2T& Format )
Chris@16 331 {
Chris@16 332 ::boost::algorithm::find_format(
Chris@16 333 Input,
Chris@16 334 ::boost::algorithm::last_finder(Search),
Chris@16 335 ::boost::algorithm::const_formatter(Format) );
Chris@16 336 }
Chris@16 337
Chris@16 338 // replace_last ( case insensitive ) -----------------------------------------------//
Chris@16 339
Chris@16 340 //! Replace last algorithm ( case insensitive )
Chris@16 341 /*!
Chris@16 342 Replace the last match of the search string in the input
Chris@16 343 with the format string.
Chris@16 344 The result is a modified copy of the input. It is returned as a sequence
Chris@16 345 or copied to the output iterator.
Chris@16 346 Searching is case insensitive.
Chris@16 347
Chris@16 348 \param Output An output iterator to which the result will be copied
Chris@16 349 \param Input An input string
Chris@16 350 \param Search A substring to be searched for
Chris@16 351 \param Format A substitute string
Chris@16 352 \param Loc A locale used for case insensitive comparison
Chris@16 353 \return An output iterator pointing just after the last inserted character or
Chris@16 354 a modified copy of the input
Chris@16 355
Chris@16 356 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 357 */
Chris@16 358 template<
Chris@16 359 typename OutputIteratorT,
Chris@16 360 typename Range1T,
Chris@16 361 typename Range2T,
Chris@16 362 typename Range3T>
Chris@16 363 inline OutputIteratorT ireplace_last_copy(
Chris@16 364 OutputIteratorT Output,
Chris@16 365 const Range1T& Input,
Chris@16 366 const Range2T& Search,
Chris@16 367 const Range3T& Format,
Chris@16 368 const std::locale& Loc=std::locale() )
Chris@16 369 {
Chris@16 370 return ::boost::algorithm::find_format_copy(
Chris@16 371 Output,
Chris@16 372 Input,
Chris@16 373 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
Chris@16 374 ::boost::algorithm::const_formatter(Format) );
Chris@16 375 }
Chris@16 376
Chris@16 377 //! Replace last algorithm ( case insensitive )
Chris@16 378 /*!
Chris@16 379 \overload
Chris@16 380 */
Chris@16 381 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 382 inline SequenceT ireplace_last_copy(
Chris@16 383 const SequenceT& Input,
Chris@16 384 const Range1T& Search,
Chris@16 385 const Range2T& Format,
Chris@16 386 const std::locale& Loc=std::locale() )
Chris@16 387 {
Chris@16 388 return ::boost::algorithm::find_format_copy(
Chris@16 389 Input,
Chris@16 390 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
Chris@16 391 ::boost::algorithm::const_formatter(Format) );
Chris@16 392 }
Chris@16 393
Chris@16 394 //! Replace last algorithm ( case insensitive )
Chris@16 395 /*!
Chris@16 396 Replace the last match of the search string in the input
Chris@16 397 with the format string.The input sequence is modified in-place.
Chris@16 398 Searching is case insensitive.
Chris@16 399
Chris@16 400 \param Input An input string
Chris@16 401 \param Search A substring to be searched for
Chris@16 402 \param Format A substitute string
Chris@16 403 \param Loc A locale used for case insensitive comparison
Chris@16 404 \return A reference to the modified input
Chris@16 405 */
Chris@16 406 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 407 inline void ireplace_last(
Chris@16 408 SequenceT& Input,
Chris@16 409 const Range1T& Search,
Chris@16 410 const Range2T& Format,
Chris@16 411 const std::locale& Loc=std::locale() )
Chris@16 412 {
Chris@16 413 ::boost::algorithm::find_format(
Chris@16 414 Input,
Chris@16 415 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
Chris@16 416 ::boost::algorithm::const_formatter(Format) );
Chris@16 417 }
Chris@16 418
Chris@16 419 // replace_nth --------------------------------------------------------------------//
Chris@16 420
Chris@16 421 //! Replace nth algorithm
Chris@16 422 /*!
Chris@16 423 Replace an Nth (zero-indexed) match of the search string in the input
Chris@16 424 with the format string.
Chris@16 425 The result is a modified copy of the input. It is returned as a sequence
Chris@16 426 or copied to the output iterator.
Chris@16 427
Chris@16 428 \param Output An output iterator to which the result will be copied
Chris@16 429 \param Input An input string
Chris@16 430 \param Search A substring to be searched for
Chris@16 431 \param Nth An index of the match to be replaced. The index is 0-based.
Chris@16 432 For negative N, matches are counted from the end of string.
Chris@16 433 \param Format A substitute string
Chris@16 434 \return An output iterator pointing just after the last inserted character or
Chris@16 435 a modified copy of the input
Chris@16 436
Chris@16 437 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 438 */
Chris@16 439 template<
Chris@16 440 typename OutputIteratorT,
Chris@16 441 typename Range1T,
Chris@16 442 typename Range2T,
Chris@16 443 typename Range3T>
Chris@16 444 inline OutputIteratorT replace_nth_copy(
Chris@16 445 OutputIteratorT Output,
Chris@16 446 const Range1T& Input,
Chris@16 447 const Range2T& Search,
Chris@16 448 int Nth,
Chris@16 449 const Range3T& Format )
Chris@16 450 {
Chris@16 451 return ::boost::algorithm::find_format_copy(
Chris@16 452 Output,
Chris@16 453 Input,
Chris@16 454 ::boost::algorithm::nth_finder(Search, Nth),
Chris@16 455 ::boost::algorithm::const_formatter(Format) );
Chris@16 456 }
Chris@16 457
Chris@16 458 //! Replace nth algorithm
Chris@16 459 /*!
Chris@16 460 \overload
Chris@16 461 */
Chris@16 462 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 463 inline SequenceT replace_nth_copy(
Chris@16 464 const SequenceT& Input,
Chris@16 465 const Range1T& Search,
Chris@16 466 int Nth,
Chris@16 467 const Range2T& Format )
Chris@16 468 {
Chris@16 469 return ::boost::algorithm::find_format_copy(
Chris@16 470 Input,
Chris@16 471 ::boost::algorithm::nth_finder(Search, Nth),
Chris@16 472 ::boost::algorithm::const_formatter(Format) );
Chris@16 473 }
Chris@16 474
Chris@16 475 //! Replace nth algorithm
Chris@16 476 /*!
Chris@16 477 Replace an Nth (zero-indexed) match of the search string in the input
Chris@16 478 with the format string. Input sequence is modified in-place.
Chris@16 479
Chris@16 480 \param Input An input string
Chris@16 481 \param Search A substring to be searched for
Chris@16 482 \param Nth An index of the match to be replaced. The index is 0-based.
Chris@16 483 For negative N, matches are counted from the end of string.
Chris@16 484 \param Format A substitute string
Chris@16 485 */
Chris@16 486 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 487 inline void replace_nth(
Chris@16 488 SequenceT& Input,
Chris@16 489 const Range1T& Search,
Chris@16 490 int Nth,
Chris@16 491 const Range2T& Format )
Chris@16 492 {
Chris@16 493 ::boost::algorithm::find_format(
Chris@16 494 Input,
Chris@16 495 ::boost::algorithm::nth_finder(Search, Nth),
Chris@16 496 ::boost::algorithm::const_formatter(Format) );
Chris@16 497 }
Chris@16 498
Chris@16 499 // replace_nth ( case insensitive ) -----------------------------------------------//
Chris@16 500
Chris@16 501 //! Replace nth algorithm ( case insensitive )
Chris@16 502 /*!
Chris@16 503 Replace an Nth (zero-indexed) match of the search string in the input
Chris@16 504 with the format string.
Chris@16 505 The result is a modified copy of the input. It is returned as a sequence
Chris@16 506 or copied to the output iterator.
Chris@16 507 Searching is case insensitive.
Chris@16 508
Chris@16 509 \param Output An output iterator to which the result will be copied
Chris@16 510 \param Input An input string
Chris@16 511 \param Search A substring to be searched for
Chris@16 512 \param Nth An index of the match to be replaced. The index is 0-based.
Chris@16 513 For negative N, matches are counted from the end of string.
Chris@16 514 \param Format A substitute string
Chris@16 515 \param Loc A locale used for case insensitive comparison
Chris@16 516 \return An output iterator pointing just after the last inserted character or
Chris@16 517 a modified copy of the input
Chris@16 518
Chris@16 519 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 520 */
Chris@16 521 template<
Chris@16 522 typename OutputIteratorT,
Chris@16 523 typename Range1T,
Chris@16 524 typename Range2T,
Chris@16 525 typename Range3T>
Chris@16 526 inline OutputIteratorT ireplace_nth_copy(
Chris@16 527 OutputIteratorT Output,
Chris@16 528 const Range1T& Input,
Chris@16 529 const Range2T& Search,
Chris@16 530 int Nth,
Chris@16 531 const Range3T& Format,
Chris@16 532 const std::locale& Loc=std::locale() )
Chris@16 533 {
Chris@16 534 return ::boost::algorithm::find_format_copy(
Chris@16 535 Output,
Chris@16 536 Input,
Chris@16 537 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ),
Chris@16 538 ::boost::algorithm::const_formatter(Format) );
Chris@16 539 }
Chris@16 540
Chris@16 541 //! Replace nth algorithm ( case insensitive )
Chris@16 542 /*!
Chris@16 543 \overload
Chris@16 544 */
Chris@16 545 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 546 inline SequenceT ireplace_nth_copy(
Chris@16 547 const SequenceT& Input,
Chris@16 548 const Range1T& Search,
Chris@16 549 int Nth,
Chris@16 550 const Range2T& Format,
Chris@16 551 const std::locale& Loc=std::locale() )
Chris@16 552 {
Chris@16 553 return ::boost::algorithm::find_format_copy(
Chris@16 554 Input,
Chris@16 555 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
Chris@16 556 ::boost::algorithm::const_formatter(Format) );
Chris@16 557 }
Chris@16 558
Chris@16 559 //! Replace nth algorithm ( case insensitive )
Chris@16 560 /*!
Chris@16 561 Replace an Nth (zero-indexed) match of the search string in the input
Chris@16 562 with the format string. Input sequence is modified in-place.
Chris@16 563 Searching is case insensitive.
Chris@16 564
Chris@16 565 \param Input An input string
Chris@16 566 \param Search A substring to be searched for
Chris@16 567 \param Nth An index of the match to be replaced. The index is 0-based.
Chris@16 568 For negative N, matches are counted from the end of string.
Chris@16 569 \param Format A substitute string
Chris@16 570 \param Loc A locale used for case insensitive comparison
Chris@16 571 */
Chris@16 572 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 573 inline void ireplace_nth(
Chris@16 574 SequenceT& Input,
Chris@16 575 const Range1T& Search,
Chris@16 576 int Nth,
Chris@16 577 const Range2T& Format,
Chris@16 578 const std::locale& Loc=std::locale() )
Chris@16 579 {
Chris@16 580 ::boost::algorithm::find_format(
Chris@16 581 Input,
Chris@16 582 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
Chris@16 583 ::boost::algorithm::const_formatter(Format) );
Chris@16 584 }
Chris@16 585
Chris@16 586 // replace_all --------------------------------------------------------------------//
Chris@16 587
Chris@16 588 //! Replace all algorithm
Chris@16 589 /*!
Chris@16 590 Replace all occurrences of the search string in the input
Chris@16 591 with the format string.
Chris@16 592 The result is a modified copy of the input. It is returned as a sequence
Chris@16 593 or copied to the output iterator.
Chris@16 594
Chris@16 595 \param Output An output iterator to which the result will be copied
Chris@16 596 \param Input An input string
Chris@16 597 \param Search A substring to be searched for
Chris@16 598 \param Format A substitute string
Chris@16 599 \return An output iterator pointing just after the last inserted character or
Chris@16 600 a modified copy of the input
Chris@16 601
Chris@16 602 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 603 */
Chris@16 604 template<
Chris@16 605 typename OutputIteratorT,
Chris@16 606 typename Range1T,
Chris@16 607 typename Range2T,
Chris@16 608 typename Range3T>
Chris@16 609 inline OutputIteratorT replace_all_copy(
Chris@16 610 OutputIteratorT Output,
Chris@16 611 const Range1T& Input,
Chris@16 612 const Range2T& Search,
Chris@16 613 const Range3T& Format )
Chris@16 614 {
Chris@16 615 return ::boost::algorithm::find_format_all_copy(
Chris@16 616 Output,
Chris@16 617 Input,
Chris@16 618 ::boost::algorithm::first_finder(Search),
Chris@16 619 ::boost::algorithm::const_formatter(Format) );
Chris@16 620 }
Chris@16 621
Chris@16 622 //! Replace all algorithm
Chris@16 623 /*!
Chris@16 624 \overload
Chris@16 625 */
Chris@16 626 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 627 inline SequenceT replace_all_copy(
Chris@16 628 const SequenceT& Input,
Chris@16 629 const Range1T& Search,
Chris@16 630 const Range2T& Format )
Chris@16 631 {
Chris@16 632 return ::boost::algorithm::find_format_all_copy(
Chris@16 633 Input,
Chris@16 634 ::boost::algorithm::first_finder(Search),
Chris@16 635 ::boost::algorithm::const_formatter(Format) );
Chris@16 636 }
Chris@16 637
Chris@16 638 //! Replace all algorithm
Chris@16 639 /*!
Chris@16 640 Replace all occurrences of the search string in the input
Chris@16 641 with the format string. The input sequence is modified in-place.
Chris@16 642
Chris@16 643 \param Input An input string
Chris@16 644 \param Search A substring to be searched for
Chris@16 645 \param Format A substitute string
Chris@16 646 \return A reference to the modified input
Chris@16 647 */
Chris@16 648 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 649 inline void replace_all(
Chris@16 650 SequenceT& Input,
Chris@16 651 const Range1T& Search,
Chris@16 652 const Range2T& Format )
Chris@16 653 {
Chris@16 654 ::boost::algorithm::find_format_all(
Chris@16 655 Input,
Chris@16 656 ::boost::algorithm::first_finder(Search),
Chris@16 657 ::boost::algorithm::const_formatter(Format) );
Chris@16 658 }
Chris@16 659
Chris@16 660 // replace_all ( case insensitive ) -----------------------------------------------//
Chris@16 661
Chris@16 662 //! Replace all algorithm ( case insensitive )
Chris@16 663 /*!
Chris@16 664 Replace all occurrences of the search string in the input
Chris@16 665 with the format string.
Chris@16 666 The result is a modified copy of the input. It is returned as a sequence
Chris@16 667 or copied to the output iterator.
Chris@16 668 Searching is case insensitive.
Chris@16 669
Chris@16 670 \param Output An output iterator to which the result will be copied
Chris@16 671 \param Input An input string
Chris@16 672 \param Search A substring to be searched for
Chris@16 673 \param Format A substitute string
Chris@16 674 \param Loc A locale used for case insensitive comparison
Chris@16 675 \return An output iterator pointing just after the last inserted character or
Chris@16 676 a modified copy of the input
Chris@16 677
Chris@16 678 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 679 */
Chris@16 680 template<
Chris@16 681 typename OutputIteratorT,
Chris@16 682 typename Range1T,
Chris@16 683 typename Range2T,
Chris@16 684 typename Range3T>
Chris@16 685 inline OutputIteratorT ireplace_all_copy(
Chris@16 686 OutputIteratorT Output,
Chris@16 687 const Range1T& Input,
Chris@16 688 const Range2T& Search,
Chris@16 689 const Range3T& Format,
Chris@16 690 const std::locale& Loc=std::locale() )
Chris@16 691 {
Chris@16 692 return ::boost::algorithm::find_format_all_copy(
Chris@16 693 Output,
Chris@16 694 Input,
Chris@16 695 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 696 ::boost::algorithm::const_formatter(Format) );
Chris@16 697 }
Chris@16 698
Chris@16 699 //! Replace all algorithm ( case insensitive )
Chris@16 700 /*!
Chris@16 701 \overload
Chris@16 702 */
Chris@16 703 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 704 inline SequenceT ireplace_all_copy(
Chris@16 705 const SequenceT& Input,
Chris@16 706 const Range1T& Search,
Chris@16 707 const Range2T& Format,
Chris@16 708 const std::locale& Loc=std::locale() )
Chris@16 709 {
Chris@16 710 return ::boost::algorithm::find_format_all_copy(
Chris@16 711 Input,
Chris@16 712 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 713 ::boost::algorithm::const_formatter(Format) );
Chris@16 714 }
Chris@16 715
Chris@16 716 //! Replace all algorithm ( case insensitive )
Chris@16 717 /*!
Chris@16 718 Replace all occurrences of the search string in the input
Chris@16 719 with the format string.The input sequence is modified in-place.
Chris@16 720 Searching is case insensitive.
Chris@16 721
Chris@16 722 \param Input An input string
Chris@16 723 \param Search A substring to be searched for
Chris@16 724 \param Format A substitute string
Chris@16 725 \param Loc A locale used for case insensitive comparison
Chris@16 726 */
Chris@16 727 template<typename SequenceT, typename Range1T, typename Range2T>
Chris@16 728 inline void ireplace_all(
Chris@16 729 SequenceT& Input,
Chris@16 730 const Range1T& Search,
Chris@16 731 const Range2T& Format,
Chris@16 732 const std::locale& Loc=std::locale() )
Chris@16 733 {
Chris@16 734 ::boost::algorithm::find_format_all(
Chris@16 735 Input,
Chris@16 736 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
Chris@16 737 ::boost::algorithm::const_formatter(Format) );
Chris@16 738 }
Chris@16 739
Chris@16 740 // replace_head --------------------------------------------------------------------//
Chris@16 741
Chris@16 742 //! Replace head algorithm
Chris@16 743 /*!
Chris@16 744 Replace the head of the input with the given format string.
Chris@16 745 The head is a prefix of a string of given size.
Chris@16 746 If the sequence is shorter then required, whole string if
Chris@16 747 considered to be the head.
Chris@16 748 The result is a modified copy of the input. It is returned as a sequence
Chris@16 749 or copied to the output iterator.
Chris@16 750
Chris@16 751 \param Output An output iterator to which the result will be copied
Chris@16 752 \param Input An input string
Chris@16 753 \param N Length of the head.
Chris@16 754 For N>=0, at most N characters are extracted.
Chris@16 755 For N<0, size(Input)-|N| characters are extracted.
Chris@16 756 \param Format A substitute string
Chris@16 757 \return An output iterator pointing just after the last inserted character or
Chris@16 758 a modified copy of the input
Chris@16 759
Chris@16 760 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 761 */
Chris@16 762 template<
Chris@16 763 typename OutputIteratorT,
Chris@16 764 typename Range1T,
Chris@16 765 typename Range2T>
Chris@16 766 inline OutputIteratorT replace_head_copy(
Chris@16 767 OutputIteratorT Output,
Chris@16 768 const Range1T& Input,
Chris@16 769 int N,
Chris@16 770 const Range2T& Format )
Chris@16 771 {
Chris@16 772 return ::boost::algorithm::find_format_copy(
Chris@16 773 Output,
Chris@16 774 Input,
Chris@16 775 ::boost::algorithm::head_finder(N),
Chris@16 776 ::boost::algorithm::const_formatter(Format) );
Chris@16 777 }
Chris@16 778
Chris@16 779 //! Replace head algorithm
Chris@16 780 /*!
Chris@16 781 \overload
Chris@16 782 */
Chris@16 783 template<typename SequenceT, typename RangeT>
Chris@16 784 inline SequenceT replace_head_copy(
Chris@16 785 const SequenceT& Input,
Chris@16 786 int N,
Chris@16 787 const RangeT& Format )
Chris@16 788 {
Chris@16 789 return ::boost::algorithm::find_format_copy(
Chris@16 790 Input,
Chris@16 791 ::boost::algorithm::head_finder(N),
Chris@16 792 ::boost::algorithm::const_formatter(Format) );
Chris@16 793 }
Chris@16 794
Chris@16 795 //! Replace head algorithm
Chris@16 796 /*!
Chris@16 797 Replace the head of the input with the given format string.
Chris@16 798 The head is a prefix of a string of given size.
Chris@16 799 If the sequence is shorter then required, the whole string is
Chris@16 800 considered to be the head. The input sequence is modified in-place.
Chris@16 801
Chris@16 802 \param Input An input string
Chris@16 803 \param N Length of the head.
Chris@16 804 For N>=0, at most N characters are extracted.
Chris@16 805 For N<0, size(Input)-|N| characters are extracted.
Chris@16 806 \param Format A substitute string
Chris@16 807 */
Chris@16 808 template<typename SequenceT, typename RangeT>
Chris@16 809 inline void replace_head(
Chris@16 810 SequenceT& Input,
Chris@16 811 int N,
Chris@16 812 const RangeT& Format )
Chris@16 813 {
Chris@16 814 ::boost::algorithm::find_format(
Chris@16 815 Input,
Chris@16 816 ::boost::algorithm::head_finder(N),
Chris@16 817 ::boost::algorithm::const_formatter(Format) );
Chris@16 818 }
Chris@16 819
Chris@16 820 // replace_tail --------------------------------------------------------------------//
Chris@16 821
Chris@16 822 //! Replace tail algorithm
Chris@16 823 /*!
Chris@16 824 Replace the tail of the input with the given format string.
Chris@16 825 The tail is a suffix of a string of given size.
Chris@16 826 If the sequence is shorter then required, whole string is
Chris@16 827 considered to be the tail.
Chris@16 828 The result is a modified copy of the input. It is returned as a sequence
Chris@16 829 or copied to the output iterator.
Chris@16 830
Chris@16 831 \param Output An output iterator to which the result will be copied
Chris@16 832 \param Input An input string
Chris@16 833 \param N Length of the tail.
Chris@16 834 For N>=0, at most N characters are extracted.
Chris@16 835 For N<0, size(Input)-|N| characters are extracted.
Chris@16 836 \param Format A substitute string
Chris@16 837 \return An output iterator pointing just after the last inserted character or
Chris@16 838 a modified copy of the input
Chris@16 839
Chris@16 840 \note The second variant of this function provides the strong exception-safety guarantee
Chris@16 841 */
Chris@16 842 template<
Chris@16 843 typename OutputIteratorT,
Chris@16 844 typename Range1T,
Chris@16 845 typename Range2T>
Chris@16 846 inline OutputIteratorT replace_tail_copy(
Chris@16 847 OutputIteratorT Output,
Chris@16 848 const Range1T& Input,
Chris@16 849 int N,
Chris@16 850 const Range2T& Format )
Chris@16 851 {
Chris@16 852 return ::boost::algorithm::find_format_copy(
Chris@16 853 Output,
Chris@16 854 Input,
Chris@16 855 ::boost::algorithm::tail_finder(N),
Chris@16 856 ::boost::algorithm::const_formatter(Format) );
Chris@16 857 }
Chris@16 858
Chris@16 859 //! Replace tail algorithm
Chris@16 860 /*!
Chris@16 861 \overload
Chris@16 862 */
Chris@16 863 template<typename SequenceT, typename RangeT>
Chris@16 864 inline SequenceT replace_tail_copy(
Chris@16 865 const SequenceT& Input,
Chris@16 866 int N,
Chris@16 867 const RangeT& Format )
Chris@16 868 {
Chris@16 869 return ::boost::algorithm::find_format_copy(
Chris@16 870 Input,
Chris@16 871 ::boost::algorithm::tail_finder(N),
Chris@16 872 ::boost::algorithm::const_formatter(Format) );
Chris@16 873 }
Chris@16 874
Chris@16 875 //! Replace tail algorithm
Chris@16 876 /*!
Chris@16 877 Replace the tail of the input with the given format sequence.
Chris@16 878 The tail is a suffix of a string of given size.
Chris@16 879 If the sequence is shorter then required, the whole string is
Chris@16 880 considered to be the tail. The input sequence is modified in-place.
Chris@16 881
Chris@16 882 \param Input An input string
Chris@16 883 \param N Length of the tail.
Chris@16 884 For N>=0, at most N characters are extracted.
Chris@16 885 For N<0, size(Input)-|N| characters are extracted.
Chris@16 886 \param Format A substitute string
Chris@16 887 */
Chris@16 888 template<typename SequenceT, typename RangeT>
Chris@16 889 inline void replace_tail(
Chris@16 890 SequenceT& Input,
Chris@16 891 int N,
Chris@16 892 const RangeT& Format )
Chris@16 893 {
Chris@16 894 ::boost::algorithm::find_format(
Chris@16 895 Input,
Chris@16 896 ::boost::algorithm::tail_finder(N),
Chris@16 897 ::boost::algorithm::const_formatter(Format) );
Chris@16 898 }
Chris@16 899
Chris@16 900 } // namespace algorithm
Chris@16 901
Chris@16 902 // pull names to the boost namespace
Chris@16 903 using algorithm::replace_range_copy;
Chris@16 904 using algorithm::replace_range;
Chris@16 905 using algorithm::replace_first_copy;
Chris@16 906 using algorithm::replace_first;
Chris@16 907 using algorithm::ireplace_first_copy;
Chris@16 908 using algorithm::ireplace_first;
Chris@16 909 using algorithm::replace_last_copy;
Chris@16 910 using algorithm::replace_last;
Chris@16 911 using algorithm::ireplace_last_copy;
Chris@16 912 using algorithm::ireplace_last;
Chris@16 913 using algorithm::replace_nth_copy;
Chris@16 914 using algorithm::replace_nth;
Chris@16 915 using algorithm::ireplace_nth_copy;
Chris@16 916 using algorithm::ireplace_nth;
Chris@16 917 using algorithm::replace_all_copy;
Chris@16 918 using algorithm::replace_all;
Chris@16 919 using algorithm::ireplace_all_copy;
Chris@16 920 using algorithm::ireplace_all;
Chris@16 921 using algorithm::replace_head_copy;
Chris@16 922 using algorithm::replace_head;
Chris@16 923 using algorithm::replace_tail_copy;
Chris@16 924 using algorithm::replace_tail;
Chris@16 925
Chris@16 926 } // namespace boost
Chris@16 927
Chris@16 928 #endif // BOOST_REPLACE_HPP