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