Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/algorithm/string/replace.hpp @ 46

Last change on this file since 46 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

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