Chris@16: // Boost string_algo library erase.hpp header file ---------------------------// Chris@16: Chris@16: // Copyright Pavol Droba 2002-2006. Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org/ for updates, documentation, and revision history. Chris@16: Chris@16: #ifndef BOOST_STRING_ERASE_HPP Chris@16: #define BOOST_STRING_ERASE_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: /*! \file Chris@16: Defines various erase algorithms. Each algorithm removes Chris@16: part(s) of the input according to a searching criteria. Chris@16: */ Chris@16: Chris@16: namespace boost { Chris@16: namespace algorithm { Chris@16: Chris@16: // erase_range -------------------------------------------------------// Chris@16: Chris@16: //! Erase range algorithm Chris@16: /*! Chris@16: Remove the given range from the input. The result is a modified copy of Chris@16: the input. It is returned as a sequence or copied to the output iterator. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input sequence Chris@16: \param SearchRange A range in the input to be removed Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template Chris@16: inline OutputIteratorT erase_range_copy( Chris@16: OutputIteratorT Output, Chris@16: const RangeT& Input, Chris@16: const iterator_range< Chris@16: BOOST_STRING_TYPENAME Chris@16: range_const_iterator::type>& SearchRange ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::range_finder(SearchRange), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase range algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_range_copy( Chris@16: const SequenceT& Input, Chris@16: const iterator_range< Chris@16: BOOST_STRING_TYPENAME Chris@16: range_const_iterator::type>& SearchRange ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::range_finder(SearchRange), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase range algorithm Chris@16: /*! Chris@16: Remove the given range from the input. Chris@16: The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input sequence Chris@16: \param SearchRange A range in the input to be removed Chris@16: */ Chris@16: template Chris@16: inline void erase_range( Chris@16: SequenceT& Input, Chris@16: const iterator_range< Chris@16: BOOST_STRING_TYPENAME Chris@16: range_iterator::type>& SearchRange ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::range_finder(SearchRange), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_first --------------------------------------------------------// Chris@16: Chris@16: //! Erase first algorithm Chris@16: /*! Chris@16: Remove the first occurrence of the substring from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT erase_first_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase first algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_first_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase first algorithm Chris@16: /*! Chris@16: Remove the first occurrence of the substring from the input. Chris@16: The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: */ Chris@16: template Chris@16: inline void erase_first( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_first ( case insensitive ) ------------------------------------// Chris@16: Chris@16: //! Erase first algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove the first occurrence of the substring from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Searching is case insensitive. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT ierase_first_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase first algorithm ( case insensitive ) Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT ierase_first_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase first algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove the first occurrence of the substring from the input. Chris@16: The input sequence is modified in-place. Searching is case insensitive. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: */ Chris@16: template Chris@16: inline void ierase_first( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_last --------------------------------------------------------// Chris@16: Chris@16: //! Erase last algorithm Chris@16: /*! Chris@16: Remove the last occurrence of the substring from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT erase_last_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase last algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_last_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase last algorithm Chris@16: /*! Chris@16: Remove the last occurrence of the substring from the input. Chris@16: The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: */ Chris@16: template Chris@16: inline void erase_last( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_last ( case insensitive ) ------------------------------------// Chris@16: Chris@16: //! Erase last algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove the last occurrence of the substring from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Searching is case insensitive. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT ierase_last_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase last algorithm ( case insensitive ) Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT ierase_last_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase last algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove the last occurrence of the substring from the input. Chris@16: The input sequence is modified in-place. Searching is case insensitive. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: */ Chris@16: template Chris@16: inline void ierase_last( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::last_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_nth --------------------------------------------------------------------// Chris@16: Chris@16: //! Erase nth algorithm Chris@16: /*! Chris@16: Remove the Nth occurrence of the substring in the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Nth An index of the match to be replaced. The index is 0-based. Chris@16: For negative N, matches are counted from the end of string. Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT erase_nth_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search, Chris@16: int Nth ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase nth algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_nth_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: int Nth ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase nth algorithm Chris@16: /*! Chris@16: Remove the Nth occurrence of the substring in the input. Chris@16: The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: \param Nth An index of the match to be replaced. The index is 0-based. Chris@16: For negative N, matches are counted from the end of string. Chris@16: */ Chris@16: template Chris@16: inline void erase_nth( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: int Nth ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_nth ( case insensitive ) ---------------------------------------------// Chris@16: Chris@16: //! Erase nth algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove the Nth occurrence of the substring in the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Searching is case insensitive. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: \param Nth An index of the match to be replaced. The index is 0-based. Chris@16: For negative N, matches are counted from the end of string. Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT ierase_nth_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search, Chris@16: int Nth, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase nth algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT ierase_nth_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: int Nth, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), Chris@16: empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase nth algorithm Chris@16: /*! Chris@16: Remove the Nth occurrence of the substring in the input. Chris@16: The input sequence is modified in-place. Searching is case insensitive. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: \param Nth An index of the match to be replaced. The index is 0-based. Chris@16: For negative N, matches are counted from the end of string. Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: */ Chris@16: template Chris@16: inline void ierase_nth( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: int Nth, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: Chris@16: // erase_all --------------------------------------------------------// Chris@16: Chris@16: //! Erase all algorithm Chris@16: /*! Chris@16: Remove all the occurrences of the string from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input sequence Chris@16: \param Search A substring to be searched for. Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT erase_all_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_all_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase all algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_all_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_all_copy( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase all algorithm Chris@16: /*! Chris@16: Remove all the occurrences of the string from the input. Chris@16: The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: */ Chris@16: template Chris@16: inline void erase_all( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search ) Chris@16: { Chris@16: ::boost::algorithm::find_format_all( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_all ( case insensitive ) ------------------------------------// Chris@16: Chris@16: //! Erase all algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove all the occurrences of the string from the input. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Searching is case insensitive. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename Range1T, Chris@16: typename Range2T> Chris@16: inline OutputIteratorT ierase_all_copy( Chris@16: OutputIteratorT Output, Chris@16: const Range1T& Input, Chris@16: const Range2T& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_all_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase all algorithm ( case insensitive ) Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT ierase_all_copy( Chris@16: const SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_all_copy( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: //! Erase all algorithm ( case insensitive ) Chris@16: /*! Chris@16: Remove all the occurrences of the string from the input. Chris@16: The input sequence is modified in-place. Searching is case insensitive. Chris@16: Chris@16: \param Input An input string Chris@16: \param Search A substring to be searched for. Chris@16: \param Loc A locale used for case insensitive comparison Chris@16: */ Chris@16: template Chris@16: inline void ierase_all( Chris@16: SequenceT& Input, Chris@16: const RangeT& Search, Chris@16: const std::locale& Loc=std::locale() ) Chris@16: { Chris@16: ::boost::algorithm::find_format_all( Chris@16: Input, Chris@16: ::boost::algorithm::first_finder(Search, is_iequal(Loc)), Chris@16: ::boost::algorithm::empty_formatter(Input) ); Chris@16: } Chris@16: Chris@16: // erase_head --------------------------------------------------------------------// Chris@16: Chris@16: //! Erase head algorithm Chris@16: /*! Chris@16: Remove the head from the input. The head is a prefix of a sequence of given size. Chris@16: If the sequence is shorter then required, the whole string is Chris@16: considered to be the head. The result is a modified copy of the input. Chris@16: It is returned as a sequence or copied to the output iterator. Chris@16: Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param N Length of the head. Chris@16: For N>=0, at most N characters are extracted. Chris@16: For N<0, size(Input)-|N| characters are extracted. Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename RangeT> Chris@16: inline OutputIteratorT erase_head_copy( Chris@16: OutputIteratorT Output, Chris@16: const RangeT& Input, Chris@16: int N ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::head_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: //! Erase head algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_head_copy( Chris@16: const SequenceT& Input, Chris@16: int N ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::head_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: //! Erase head algorithm Chris@16: /*! Chris@16: Remove the head from the input. The head is a prefix of a sequence of given size. Chris@16: If the sequence is shorter then required, the whole string is Chris@16: considered to be the head. The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param N Length of the head Chris@16: For N>=0, at most N characters are extracted. Chris@16: For N<0, size(Input)-|N| characters are extracted. Chris@16: */ Chris@16: template Chris@16: inline void erase_head( Chris@16: SequenceT& Input, Chris@16: int N ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::head_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: // erase_tail --------------------------------------------------------------------// Chris@16: Chris@16: //! Erase tail algorithm Chris@16: /*! Chris@16: Remove the tail from the input. The tail is a suffix of a sequence of given size. Chris@16: If the sequence is shorter then required, the whole string is Chris@16: considered to be the tail. Chris@16: The result is a modified copy of the input. It is returned as a sequence Chris@16: or copied to the output iterator. Chris@16: Chris@16: \param Output An output iterator to which the result will be copied Chris@16: \param Input An input string Chris@16: \param N Length of the tail. Chris@16: For N>=0, at most N characters are extracted. Chris@16: For N<0, size(Input)-|N| characters are extracted. Chris@16: \return An output iterator pointing just after the last inserted character or Chris@16: a modified copy of the input Chris@16: Chris@16: \note The second variant of this function provides the strong exception-safety guarantee Chris@16: */ Chris@16: template< Chris@16: typename OutputIteratorT, Chris@16: typename RangeT> Chris@16: inline OutputIteratorT erase_tail_copy( Chris@16: OutputIteratorT Output, Chris@16: const RangeT& Input, Chris@16: int N ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Output, Chris@16: Input, Chris@16: ::boost::algorithm::tail_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: //! Erase tail algorithm Chris@16: /*! Chris@16: \overload Chris@16: */ Chris@16: template Chris@16: inline SequenceT erase_tail_copy( Chris@16: const SequenceT& Input, Chris@16: int N ) Chris@16: { Chris@16: return ::boost::algorithm::find_format_copy( Chris@16: Input, Chris@16: ::boost::algorithm::tail_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: //! Erase tail algorithm Chris@16: /*! Chris@16: Remove the tail from the input. The tail is a suffix of a sequence of given size. Chris@16: If the sequence is shorter then required, the whole string is Chris@16: considered to be the tail. The input sequence is modified in-place. Chris@16: Chris@16: \param Input An input string Chris@16: \param N Length of the tail Chris@16: For N>=0, at most N characters are extracted. Chris@16: For N<0, size(Input)-|N| characters are extracted. Chris@16: */ Chris@16: template Chris@16: inline void erase_tail( Chris@16: SequenceT& Input, Chris@16: int N ) Chris@16: { Chris@16: ::boost::algorithm::find_format( Chris@16: Input, Chris@16: ::boost::algorithm::tail_finder(N), Chris@16: ::boost::algorithm::empty_formatter( Input ) ); Chris@16: } Chris@16: Chris@16: } // namespace algorithm Chris@16: Chris@16: // pull names into the boost namespace Chris@16: using algorithm::erase_range_copy; Chris@16: using algorithm::erase_range; Chris@16: using algorithm::erase_first_copy; Chris@16: using algorithm::erase_first; Chris@16: using algorithm::ierase_first_copy; Chris@16: using algorithm::ierase_first; Chris@16: using algorithm::erase_last_copy; Chris@16: using algorithm::erase_last; Chris@16: using algorithm::ierase_last_copy; Chris@16: using algorithm::ierase_last; Chris@16: using algorithm::erase_nth_copy; Chris@16: using algorithm::erase_nth; Chris@16: using algorithm::ierase_nth_copy; Chris@16: using algorithm::ierase_nth; Chris@16: using algorithm::erase_all_copy; Chris@16: using algorithm::erase_all; Chris@16: using algorithm::ierase_all_copy; Chris@16: using algorithm::ierase_all; Chris@16: using algorithm::erase_head_copy; Chris@16: using algorithm::erase_head; Chris@16: using algorithm::erase_tail_copy; Chris@16: using algorithm::erase_tail; Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_ERASE_HPP