Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:04:49

0001 //  Boost string_algo library replace.hpp header file  ---------------------------//
0002 
0003 //  Copyright Pavol Droba 2002-2006.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org/ for updates, documentation, and revision history.
0010 
0011 #ifndef BOOST_STRING_REPLACE_HPP
0012 #define BOOST_STRING_REPLACE_HPP
0013 
0014 #include <boost/algorithm/string/config.hpp>
0015 
0016 #include <boost/range/iterator_range_core.hpp>
0017 #include <boost/range/begin.hpp>
0018 #include <boost/range/end.hpp>
0019 #include <boost/range/iterator.hpp>
0020 #include <boost/range/const_iterator.hpp>
0021 
0022 #include <boost/algorithm/string/find_format.hpp>
0023 #include <boost/algorithm/string/finder.hpp>
0024 #include <boost/algorithm/string/formatter.hpp>
0025 #include <boost/algorithm/string/compare.hpp>
0026 
0027 /*! \file
0028     Defines various replace algorithms. Each algorithm replaces
0029     part(s) of the input according to set of searching and replace criteria.
0030 */
0031 
0032 namespace boost {
0033     namespace algorithm {
0034 
0035 //  replace_range --------------------------------------------------------------------//
0036 
0037         //! Replace range algorithm
0038         /*!
0039             Replace the given range in the input string.
0040             The result is a modified copy of the input. It is returned as a sequence 
0041             or copied to the output iterator.
0042             
0043             \param Output An output iterator to which the result will be copied
0044             \param Input An input string
0045             \param SearchRange A range in the input to be substituted
0046             \param Format A substitute string
0047             \return An output iterator pointing just after the last inserted character or
0048                 a modified copy of the input
0049 
0050               \note The second variant of this function provides the strong exception-safety guarantee
0051         */
0052         template<
0053             typename OutputIteratorT,
0054             typename Range1T, 
0055             typename Range2T>
0056         inline OutputIteratorT replace_range_copy(
0057             OutputIteratorT Output,
0058             const Range1T& Input,
0059             const iterator_range<
0060                 BOOST_STRING_TYPENAME 
0061                     range_const_iterator<Range1T>::type>& SearchRange,
0062             const Range2T& Format)
0063         {
0064             return ::boost::algorithm::find_format_copy(
0065                 Output,
0066                 Input,
0067                 ::boost::algorithm::range_finder(SearchRange),
0068                 ::boost::algorithm::const_formatter(Format));
0069         }
0070 
0071         //! Replace range algorithm
0072         /*!
0073             \overload
0074         */
0075         template<typename SequenceT, typename RangeT>
0076         inline SequenceT replace_range_copy( 
0077             const SequenceT& Input,
0078             const iterator_range<
0079                 BOOST_STRING_TYPENAME 
0080                     range_const_iterator<SequenceT>::type>& SearchRange,
0081             const RangeT& Format)
0082         {
0083             return ::boost::algorithm::find_format_copy(
0084                 Input,
0085                 ::boost::algorithm::range_finder(SearchRange),
0086                 ::boost::algorithm::const_formatter(Format));
0087         }
0088 
0089         //! Replace range algorithm
0090         /*!
0091             Replace the given range in the input string. 
0092             The input sequence is modified in-place.
0093 
0094             \param Input An input string
0095             \param SearchRange A range in the input to be substituted
0096             \param Format A substitute string
0097         */
0098         template<typename SequenceT, typename RangeT>
0099         inline void replace_range( 
0100             SequenceT& Input,
0101             const iterator_range<
0102                 BOOST_STRING_TYPENAME 
0103                     range_iterator<SequenceT>::type>& SearchRange,
0104             const RangeT& Format)
0105         {
0106             ::boost::algorithm::find_format(
0107                 Input,
0108                 ::boost::algorithm::range_finder(SearchRange),
0109                 ::boost::algorithm::const_formatter(Format));
0110         }
0111 
0112 //  replace_first --------------------------------------------------------------------//
0113 
0114         //! Replace first algorithm
0115         /*!
0116             Replace the first match of the search substring in the input 
0117             with the format string. 
0118             The result is a modified copy of the input. It is returned as a sequence 
0119             or copied to the output iterator.
0120             
0121             \param Output An output iterator to which the result will be copied
0122             \param Input An input string
0123             \param Search A substring to be searched for 
0124             \param Format A substitute string
0125             \return An output iterator pointing just after the last inserted character or
0126                     a modified copy of the input
0127 
0128               \note The second variant of this function provides the strong exception-safety guarantee
0129         */
0130         template<
0131             typename OutputIteratorT,
0132             typename Range1T, 
0133             typename Range2T,
0134             typename Range3T>
0135         inline OutputIteratorT replace_first_copy(
0136             OutputIteratorT Output,
0137             const Range1T& Input,
0138             const Range2T& Search,
0139             const Range3T& Format)
0140         {
0141             return ::boost::algorithm::find_format_copy(
0142                 Output,
0143                 Input,
0144                 ::boost::algorithm::first_finder(Search),
0145                 ::boost::algorithm::const_formatter(Format) );
0146         }
0147 
0148         //! Replace first algorithm
0149         /*!
0150             \overload
0151         */
0152         template<typename SequenceT, typename Range1T, typename Range2T>
0153         inline SequenceT replace_first_copy( 
0154             const SequenceT& Input,
0155             const Range1T& Search,
0156             const Range2T& Format )
0157         {
0158             return ::boost::algorithm::find_format_copy( 
0159                 Input,
0160                 ::boost::algorithm::first_finder(Search),
0161                 ::boost::algorithm::const_formatter(Format) );
0162         }
0163 
0164         //! Replace first algorithm
0165         /*!
0166             replace the first match of the search substring in the input 
0167             with the format string. The input sequence is modified in-place.
0168 
0169             \param Input An input string
0170             \param Search A substring to be searched for 
0171             \param Format A substitute string
0172         */
0173         template<typename SequenceT, typename Range1T, typename Range2T>
0174         inline void replace_first( 
0175             SequenceT& Input,
0176             const Range1T& Search,
0177             const Range2T& Format )
0178         {
0179             ::boost::algorithm::find_format( 
0180                 Input, 
0181                 ::boost::algorithm::first_finder(Search),
0182                 ::boost::algorithm::const_formatter(Format) );
0183         }
0184 
0185 //  replace_first ( case insensitive ) ---------------------------------------------//
0186 
0187         //! Replace first algorithm ( case insensitive )
0188         /*!
0189             Replace the first match of the search substring in the input 
0190             with the format string. 
0191             The result is a modified copy of the input. It is returned as a sequence 
0192             or copied to the output iterator.
0193             Searching is case insensitive.
0194 
0195             \param Output An output iterator to which the result will be copied
0196             \param Input An input string
0197             \param Search A substring to be searched for 
0198             \param Format A substitute string
0199             \param Loc A locale used for case insensitive comparison
0200             \return An output iterator pointing just after the last inserted character or
0201                 a modified copy of the input
0202 
0203              \note The second variant of this function provides the strong exception-safety guarantee
0204         */
0205         template<
0206             typename OutputIteratorT,
0207             typename Range1T, 
0208             typename Range2T,
0209             typename Range3T>
0210         inline OutputIteratorT ireplace_first_copy(
0211             OutputIteratorT Output,
0212             const Range1T& Input,
0213             const Range2T& Search,
0214             const Range3T& Format,
0215             const std::locale& Loc=std::locale() )
0216         {
0217             return ::boost::algorithm::find_format_copy(
0218                 Output,
0219                 Input,
0220                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0221                 ::boost::algorithm::const_formatter(Format) );
0222         }
0223 
0224         //! Replace first algorithm ( case insensitive )
0225         /*!
0226             \overload
0227         */
0228         template<typename SequenceT, typename Range2T, typename Range1T>
0229         inline SequenceT ireplace_first_copy( 
0230             const SequenceT& Input,
0231             const Range2T& Search,
0232             const Range1T& Format,
0233             const std::locale& Loc=std::locale() )
0234         {
0235             return ::boost::algorithm::find_format_copy( 
0236                 Input,
0237                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0238                 ::boost::algorithm::const_formatter(Format) );
0239         }
0240 
0241         //! Replace first algorithm ( case insensitive )
0242         /*!
0243             Replace the first match of the search substring in the input 
0244             with the format string. Input sequence is modified in-place.
0245             Searching is case insensitive.
0246 
0247             \param Input An input string
0248             \param Search A substring to be searched for 
0249             \param Format A substitute string
0250             \param Loc A locale used for case insensitive comparison
0251         */
0252         template<typename SequenceT, typename Range1T, typename Range2T>
0253         inline void ireplace_first( 
0254             SequenceT& Input,
0255             const Range1T& Search,
0256             const Range2T& Format,
0257             const std::locale& Loc=std::locale() )
0258         {
0259             ::boost::algorithm::find_format( 
0260                 Input, 
0261                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0262                 ::boost::algorithm::const_formatter(Format) );
0263         }
0264 
0265 //  replace_last --------------------------------------------------------------------//
0266 
0267         //! Replace last algorithm
0268         /*!
0269             Replace the last match of the search string in the input 
0270             with the format string. 
0271             The result is a modified copy of the input. It is returned as a sequence 
0272             or copied to the output iterator.
0273 
0274             \param Output An output iterator to which the result will be copied
0275             \param Input An input string
0276             \param Search A substring to be searched for
0277             \param Format A substitute string
0278             \return An output iterator pointing just after the last inserted character or
0279                     a modified copy of the input            
0280 
0281               \note The second variant of this function provides the strong exception-safety guarantee
0282         */
0283         template<
0284             typename OutputIteratorT,
0285             typename Range1T, 
0286             typename Range2T,
0287             typename Range3T>
0288         inline OutputIteratorT replace_last_copy(
0289             OutputIteratorT Output,
0290             const Range1T& Input,
0291             const Range2T& Search,
0292             const Range3T& Format )
0293         {
0294             return ::boost::algorithm::find_format_copy(
0295                 Output,
0296                 Input,
0297                 ::boost::algorithm::last_finder(Search),
0298                 ::boost::algorithm::const_formatter(Format) );
0299         }
0300 
0301         //! Replace last algorithm
0302         /*!
0303             \overload
0304         */
0305         template<typename SequenceT, typename Range1T, typename Range2T>
0306         inline SequenceT replace_last_copy( 
0307             const SequenceT& Input,
0308             const Range1T& Search,
0309             const Range2T& Format )
0310         {
0311             return ::boost::algorithm::find_format_copy( 
0312                 Input,
0313                 ::boost::algorithm::last_finder(Search),
0314                 ::boost::algorithm::const_formatter(Format) );
0315         }
0316 
0317         //! Replace last algorithm
0318         /*!
0319             Replace the last match of the search string in the input 
0320             with the format string. Input sequence is modified in-place.
0321 
0322             \param Input An input string
0323             \param Search A substring to be searched for 
0324             \param Format A substitute string
0325         */
0326         template<typename SequenceT, typename Range1T, typename Range2T>
0327         inline void replace_last( 
0328             SequenceT& Input,
0329             const Range1T& Search,
0330             const Range2T& Format )
0331         {
0332             ::boost::algorithm::find_format( 
0333                 Input, 
0334                 ::boost::algorithm::last_finder(Search),
0335                 ::boost::algorithm::const_formatter(Format) );
0336         }
0337 
0338 //  replace_last ( case insensitive ) -----------------------------------------------//
0339 
0340         //! Replace last algorithm ( case insensitive )
0341         /*!
0342             Replace the last match of the search string in the input 
0343             with the format string. 
0344             The result is a modified copy of the input. It is returned as a sequence 
0345             or copied to the output iterator.
0346             Searching is case insensitive.
0347 
0348             \param Output An output iterator to which the result will be copied
0349             \param Input An input string
0350             \param Search A substring to be searched for 
0351             \param Format A substitute string
0352             \param Loc A locale used for case insensitive comparison
0353             \return An output iterator pointing just after the last inserted character or
0354                     a modified copy of the input  
0355 
0356             \note The second variant of this function provides the strong exception-safety guarantee
0357         */
0358         template<
0359             typename OutputIteratorT,
0360             typename Range1T, 
0361             typename Range2T,
0362             typename Range3T>
0363         inline OutputIteratorT ireplace_last_copy(
0364             OutputIteratorT Output,
0365             const Range1T& Input,
0366             const Range2T& Search,
0367             const Range3T& Format,
0368             const std::locale& Loc=std::locale() )
0369         {
0370             return ::boost::algorithm::find_format_copy(
0371                 Output,
0372                 Input,
0373                 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
0374                 ::boost::algorithm::const_formatter(Format) );
0375         }
0376 
0377         //! Replace last algorithm ( case insensitive )
0378         /*!
0379             \overload
0380         */
0381         template<typename SequenceT, typename Range1T, typename Range2T>
0382         inline SequenceT ireplace_last_copy( 
0383             const SequenceT& Input,
0384             const Range1T& Search,
0385             const Range2T& Format,
0386             const std::locale& Loc=std::locale() )
0387         {
0388             return ::boost::algorithm::find_format_copy( 
0389                 Input,
0390                 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
0391                 ::boost::algorithm::const_formatter(Format) );
0392         }
0393 
0394         //! Replace last algorithm ( case insensitive )
0395         /*!
0396             Replace the last match of the search string in the input 
0397             with the format string.The input sequence is modified in-place.
0398             Searching is case insensitive.
0399 
0400             \param Input An input string
0401             \param Search A substring to be searched for 
0402             \param Format A substitute string
0403             \param Loc A locale used for case insensitive comparison
0404         */
0405         template<typename SequenceT, typename Range1T, typename Range2T>
0406         inline void ireplace_last( 
0407             SequenceT& Input,
0408             const Range1T& Search,
0409             const Range2T& Format,
0410             const std::locale& Loc=std::locale() )
0411         {
0412             ::boost::algorithm::find_format( 
0413                 Input, 
0414                 ::boost::algorithm::last_finder(Search, is_iequal(Loc)),
0415                 ::boost::algorithm::const_formatter(Format) );
0416         }
0417 
0418 //  replace_nth --------------------------------------------------------------------//
0419 
0420         //! Replace nth algorithm
0421         /*!
0422             Replace an Nth (zero-indexed) match of the search string in the input 
0423             with the format string. 
0424             The result is a modified copy of the input. It is returned as a sequence 
0425             or copied to the output iterator.
0426 
0427             \param Output An output iterator to which the result will be copied
0428             \param Input An input string
0429             \param Search A substring to be searched for 
0430             \param Nth An index of the match to be replaced. The index is 0-based.
0431                 For negative N, matches are counted from the end of string.
0432             \param Format A substitute string
0433             \return An output iterator pointing just after the last inserted character or
0434                 a modified copy of the input
0435 
0436             \note The second variant of this function provides the strong exception-safety guarantee
0437         */
0438         template<
0439             typename OutputIteratorT,
0440             typename Range1T, 
0441             typename Range2T,
0442             typename Range3T>
0443         inline OutputIteratorT replace_nth_copy(
0444             OutputIteratorT Output,
0445             const Range1T& Input,
0446             const Range2T& Search,
0447             int Nth,
0448             const Range3T& Format )
0449         {
0450             return ::boost::algorithm::find_format_copy(
0451                 Output,
0452                 Input,
0453                 ::boost::algorithm::nth_finder(Search, Nth),
0454                 ::boost::algorithm::const_formatter(Format) );
0455         }
0456 
0457         //! Replace nth algorithm
0458         /*!
0459             \overload
0460         */
0461         template<typename SequenceT, typename Range1T, typename Range2T>
0462         inline SequenceT replace_nth_copy( 
0463             const SequenceT& Input,
0464             const Range1T& Search,
0465             int Nth,
0466             const Range2T& Format )
0467         {
0468             return ::boost::algorithm::find_format_copy( 
0469                 Input,
0470                 ::boost::algorithm::nth_finder(Search, Nth),
0471                 ::boost::algorithm::const_formatter(Format) );
0472         }
0473 
0474         //! Replace nth algorithm
0475         /*!
0476             Replace an Nth (zero-indexed) match of the search string in the input 
0477             with the format string. Input sequence is modified in-place.
0478 
0479             \param Input An input string
0480             \param Search A substring to be searched for 
0481             \param Nth An index of the match to be replaced. The index is 0-based.
0482                 For negative N, matches are counted from the end of string.
0483             \param Format A substitute string
0484         */
0485         template<typename SequenceT, typename Range1T, typename Range2T>
0486         inline void replace_nth( 
0487             SequenceT& Input,
0488             const Range1T& Search,
0489             int Nth,
0490             const Range2T& Format )
0491         {
0492             ::boost::algorithm::find_format( 
0493                 Input, 
0494                 ::boost::algorithm::nth_finder(Search, Nth),
0495                 ::boost::algorithm::const_formatter(Format) );
0496         }
0497 
0498 //  replace_nth ( case insensitive ) -----------------------------------------------//
0499         
0500         //! Replace nth algorithm ( case insensitive )
0501         /*!
0502             Replace an Nth (zero-indexed) match of the search string in the input 
0503             with the format string. 
0504             The result is a modified copy of the input. It is returned as a sequence 
0505             or copied to the output iterator.
0506             Searching is case insensitive.
0507 
0508             \param Output An output iterator to which the result will be copied
0509             \param Input An input string
0510             \param Search A substring to be searched for 
0511             \param Nth An index of the match to be replaced. The index is 0-based.
0512                 For negative N, matches are counted from the end of string.
0513             \param Format A substitute string
0514             \param Loc A locale used for case insensitive comparison
0515             \return An output iterator pointing just after the last inserted character or
0516                     a modified copy of the input            
0517 
0518             \note The second variant of this function provides the strong exception-safety guarantee
0519        */
0520         template<
0521             typename OutputIteratorT,
0522             typename Range1T, 
0523             typename Range2T,
0524             typename Range3T>
0525         inline OutputIteratorT ireplace_nth_copy(
0526             OutputIteratorT Output,
0527             const Range1T& Input,
0528             const Range2T& Search,
0529             int Nth,
0530             const Range3T& Format,
0531             const std::locale& Loc=std::locale() )
0532         {
0533             return ::boost::algorithm::find_format_copy(
0534                 Output,
0535                 Input,
0536                 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ),
0537                 ::boost::algorithm::const_formatter(Format) );
0538         }
0539 
0540         //! Replace nth algorithm ( case insensitive )
0541         /*!
0542             \overload
0543         */
0544         template<typename SequenceT, typename Range1T, typename Range2T>
0545         inline SequenceT ireplace_nth_copy( 
0546             const SequenceT& Input,
0547             const Range1T& Search,
0548             int Nth,
0549             const Range2T& Format,
0550             const std::locale& Loc=std::locale() )
0551         {
0552             return ::boost::algorithm::find_format_copy( 
0553                 Input,
0554                 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
0555                 ::boost::algorithm::const_formatter(Format) );
0556         }
0557 
0558         //! Replace nth algorithm ( case insensitive )
0559         /*!
0560             Replace an Nth (zero-indexed) match of the search string in the input 
0561             with the format string. Input sequence is modified in-place.
0562             Searching is case insensitive.
0563 
0564             \param Input An input string
0565             \param Search A substring to be searched for 
0566             \param Nth An index of the match to be replaced. The index is 0-based.
0567                 For negative N, matches are counted from the end of string.
0568             \param Format A substitute string
0569             \param Loc A locale used for case insensitive comparison
0570         */
0571         template<typename SequenceT, typename Range1T, typename Range2T>
0572         inline void ireplace_nth( 
0573             SequenceT& Input,
0574             const Range1T& Search,
0575             int Nth,
0576             const Range2T& Format,
0577             const std::locale& Loc=std::locale() )
0578         {
0579             ::boost::algorithm::find_format( 
0580                 Input, 
0581                 ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
0582                 ::boost::algorithm::const_formatter(Format) );
0583         }
0584 
0585 //  replace_all --------------------------------------------------------------------//
0586 
0587         //! Replace all algorithm
0588         /*!
0589             Replace all occurrences of the search string in the input 
0590             with the format string. 
0591             The result is a modified copy of the input. It is returned as a sequence 
0592             or copied to the output iterator.
0593 
0594             \param Output An output iterator to which the result will be copied
0595             \param Input An input string
0596             \param Search A substring to be searched for 
0597             \param Format A substitute string
0598             \return An output iterator pointing just after the last inserted character or
0599                     a modified copy of the input 
0600 
0601              \note The second variant of this function provides the strong exception-safety guarantee
0602         */
0603         template<
0604             typename OutputIteratorT,
0605             typename Range1T, 
0606             typename Range2T,
0607             typename Range3T>
0608         inline OutputIteratorT replace_all_copy(
0609             OutputIteratorT Output,
0610             const Range1T& Input,
0611             const Range2T& Search,
0612             const Range3T& Format )
0613         {
0614             return ::boost::algorithm::find_format_all_copy(
0615                 Output,
0616                 Input,
0617                 ::boost::algorithm::first_finder(Search),
0618                 ::boost::algorithm::const_formatter(Format) );
0619         }
0620 
0621         //! Replace all algorithm
0622         /*!
0623             \overload
0624         */
0625         template<typename SequenceT, typename Range1T, typename Range2T>
0626         inline SequenceT replace_all_copy( 
0627             const SequenceT& Input,
0628             const Range1T& Search,
0629             const Range2T& Format )
0630         {
0631             return ::boost::algorithm::find_format_all_copy( 
0632                 Input,
0633                 ::boost::algorithm::first_finder(Search),
0634                 ::boost::algorithm::const_formatter(Format) );
0635         }
0636 
0637         //! Replace all algorithm
0638         /*!
0639             Replace all occurrences of the search string in the input 
0640             with the format string. The input sequence is modified in-place.
0641 
0642             \param Input An input string
0643             \param Search A substring to be searched for 
0644             \param Format A substitute string
0645         */
0646         template<typename SequenceT, typename Range1T, typename Range2T>
0647         inline void replace_all( 
0648             SequenceT& Input,
0649             const Range1T& Search,
0650             const Range2T& Format )
0651         {
0652             ::boost::algorithm::find_format_all( 
0653                 Input, 
0654                 ::boost::algorithm::first_finder(Search),
0655                 ::boost::algorithm::const_formatter(Format) );
0656         }
0657         
0658 //  replace_all ( case insensitive ) -----------------------------------------------//
0659 
0660         //! Replace all algorithm ( case insensitive )
0661         /*!
0662             Replace all occurrences of the search string in the input 
0663             with the format string. 
0664             The result is a modified copy of the input. It is returned as a sequence 
0665             or copied to the output iterator.
0666             Searching is case insensitive.
0667 
0668             \param Output An output iterator to which the result will be copied
0669             \param Input An input string
0670             \param Search A substring to be searched for 
0671             \param Format A substitute string
0672             \param Loc A locale used for case insensitive comparison
0673             \return An output iterator pointing just after the last inserted character or
0674                     a modified copy of the input 
0675 
0676             \note The second variant of this function provides the strong exception-safety guarantee
0677         */
0678         template<
0679             typename OutputIteratorT,
0680             typename Range1T, 
0681             typename Range2T,
0682             typename Range3T>
0683         inline OutputIteratorT ireplace_all_copy(
0684             OutputIteratorT Output,
0685             const Range1T& Input,
0686             const Range2T& Search,
0687             const Range3T& Format,
0688             const std::locale& Loc=std::locale() )
0689         {
0690             return ::boost::algorithm::find_format_all_copy(
0691                 Output,
0692                 Input,
0693                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0694                 ::boost::algorithm::const_formatter(Format) );
0695         }
0696 
0697         //! Replace all algorithm ( case insensitive )
0698         /*!
0699             \overload
0700         */
0701         template<typename SequenceT, typename Range1T, typename Range2T>
0702         inline SequenceT ireplace_all_copy( 
0703             const SequenceT& Input,
0704             const Range1T& Search,
0705             const Range2T& Format,
0706             const std::locale& Loc=std::locale() )
0707         {
0708             return ::boost::algorithm::find_format_all_copy( 
0709                 Input,
0710                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0711                 ::boost::algorithm::const_formatter(Format) );
0712         }
0713 
0714         //! Replace all algorithm ( case insensitive )
0715         /*!
0716             Replace all occurrences of the search string in the input 
0717             with the format string.The input sequence is modified in-place.
0718             Searching is case insensitive.
0719 
0720             \param Input An input string
0721             \param Search A substring to be searched for 
0722             \param Format A substitute string
0723             \param Loc A locale used for case insensitive comparison
0724         */
0725         template<typename SequenceT, typename Range1T, typename Range2T>
0726         inline void ireplace_all( 
0727             SequenceT& Input,
0728             const Range1T& Search,
0729             const Range2T& Format,
0730             const std::locale& Loc=std::locale() )
0731         {
0732             ::boost::algorithm::find_format_all( 
0733                 Input, 
0734                 ::boost::algorithm::first_finder(Search, is_iequal(Loc)),
0735                 ::boost::algorithm::const_formatter(Format) );
0736         }
0737         
0738 //  replace_head --------------------------------------------------------------------//
0739 
0740         //! Replace head algorithm
0741         /*!
0742             Replace the head of the input with the given format string. 
0743             The head is a prefix of a string of given size. 
0744             If the sequence is shorter then required, whole string if 
0745             considered to be the head. 
0746             The result is a modified copy of the input. It is returned as a sequence 
0747             or copied to the output iterator.
0748             
0749             \param Output An output iterator to which the result will be copied
0750             \param Input An input string
0751             \param N Length of the head.
0752                 For N>=0, at most N characters are extracted.
0753                 For N<0, size(Input)-|N| characters are extracted.
0754             \param Format A substitute string
0755             \return An output iterator pointing just after the last inserted character or
0756                 a modified copy of the input  
0757 
0758             \note The second variant of this function provides the strong exception-safety guarantee
0759         */
0760         template<
0761             typename OutputIteratorT,
0762             typename Range1T, 
0763             typename Range2T>
0764         inline OutputIteratorT replace_head_copy(
0765             OutputIteratorT Output,
0766             const Range1T& Input,
0767             int N,
0768             const Range2T& Format )
0769         {
0770             return ::boost::algorithm::find_format_copy(
0771                 Output,
0772                 Input,
0773                 ::boost::algorithm::head_finder(N),
0774                 ::boost::algorithm::const_formatter(Format) );
0775         }
0776 
0777         //! Replace head algorithm
0778         /*!
0779             \overload
0780         */
0781         template<typename SequenceT, typename RangeT>
0782         inline SequenceT replace_head_copy( 
0783             const SequenceT& Input,
0784             int N,
0785             const RangeT& Format )
0786         {
0787             return ::boost::algorithm::find_format_copy( 
0788                 Input,
0789                 ::boost::algorithm::head_finder(N),
0790                 ::boost::algorithm::const_formatter(Format) );
0791         }
0792 
0793         //! Replace head algorithm
0794         /*!
0795             Replace the head of the input with the given format string. 
0796             The head is a prefix of a string of given size. 
0797             If the sequence is shorter then required, the whole string is 
0798             considered to be the head. The input sequence is modified in-place.
0799 
0800             \param Input An input string
0801             \param N Length of the head.
0802                 For N>=0, at most N characters are extracted.
0803                 For N<0, size(Input)-|N| characters are extracted.
0804             \param Format A substitute string
0805         */
0806         template<typename SequenceT, typename RangeT>
0807         inline void replace_head( 
0808             SequenceT& Input,
0809             int N,
0810             const RangeT& Format )
0811         {
0812             ::boost::algorithm::find_format( 
0813                 Input, 
0814                 ::boost::algorithm::head_finder(N),
0815                 ::boost::algorithm::const_formatter(Format) );
0816         }
0817 
0818 //  replace_tail --------------------------------------------------------------------//
0819 
0820         //! Replace tail algorithm
0821         /*!
0822             Replace the tail of the input with the given format string. 
0823             The tail is a suffix of a string of given size. 
0824             If the sequence is shorter then required, whole string is 
0825             considered to be the tail. 
0826             The result is a modified copy of the input. It is returned as a sequence 
0827             or copied to the output iterator.
0828 
0829             \param Output An output iterator to which the result will be copied
0830             \param Input An input string
0831             \param N Length of the tail.
0832                 For N>=0, at most N characters are extracted.
0833                 For N<0, size(Input)-|N| characters are extracted.
0834             \param Format A substitute string
0835             \return An output iterator pointing just after the last inserted character or
0836                     a modified copy of the input   
0837 
0838               \note The second variant of this function provides the strong exception-safety guarantee
0839         */
0840         template<
0841             typename OutputIteratorT,
0842             typename Range1T, 
0843             typename Range2T>
0844         inline OutputIteratorT replace_tail_copy(
0845             OutputIteratorT Output,
0846             const Range1T& Input,
0847             int N,
0848             const Range2T& Format )
0849         {
0850             return ::boost::algorithm::find_format_copy(
0851                 Output,
0852                 Input,
0853                 ::boost::algorithm::tail_finder(N),
0854                 ::boost::algorithm::const_formatter(Format) );
0855         }
0856 
0857         //! Replace tail algorithm
0858         /*!
0859             \overload
0860         */
0861         template<typename SequenceT, typename RangeT>
0862         inline SequenceT replace_tail_copy( 
0863             const SequenceT& Input,
0864             int N,
0865             const RangeT& Format )
0866         {
0867             return ::boost::algorithm::find_format_copy( 
0868                 Input,
0869                 ::boost::algorithm::tail_finder(N),
0870                 ::boost::algorithm::const_formatter(Format) );
0871         }
0872 
0873         //! Replace tail algorithm
0874         /*!
0875             Replace the tail of the input with the given format sequence. 
0876             The tail is a suffix of a string of given size. 
0877             If the sequence is shorter then required, the whole string is 
0878             considered to be the tail. The input sequence is modified in-place.
0879 
0880             \param Input An input string
0881             \param N Length of the tail.
0882                 For N>=0, at most N characters are extracted.
0883                 For N<0, size(Input)-|N| characters are extracted.
0884             \param Format A substitute string
0885         */
0886         template<typename SequenceT, typename RangeT>
0887         inline void replace_tail( 
0888             SequenceT& Input,
0889             int N,
0890             const RangeT& Format )
0891         {
0892             ::boost::algorithm::find_format( 
0893                 Input, 
0894                 ::boost::algorithm::tail_finder(N),
0895                 ::boost::algorithm::const_formatter(Format) );
0896         }
0897 
0898     } // namespace algorithm
0899 
0900     // pull names to the boost namespace
0901     using algorithm::replace_range_copy;
0902     using algorithm::replace_range;
0903     using algorithm::replace_first_copy;
0904     using algorithm::replace_first;
0905     using algorithm::ireplace_first_copy;
0906     using algorithm::ireplace_first;
0907     using algorithm::replace_last_copy;
0908     using algorithm::replace_last;
0909     using algorithm::ireplace_last_copy;
0910     using algorithm::ireplace_last;
0911     using algorithm::replace_nth_copy;
0912     using algorithm::replace_nth;
0913     using algorithm::ireplace_nth_copy;
0914     using algorithm::ireplace_nth;
0915     using algorithm::replace_all_copy;
0916     using algorithm::replace_all;
0917     using algorithm::ireplace_all_copy;
0918     using algorithm::ireplace_all;
0919     using algorithm::replace_head_copy;
0920     using algorithm::replace_head;
0921     using algorithm::replace_tail_copy;
0922     using algorithm::replace_tail;
0923 
0924 } // namespace boost
0925 
0926 #endif  // BOOST_REPLACE_HPP