File indexing completed on 2024-11-16 09:04:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
0028
0029
0030
0031
0032 namespace boost {
0033 namespace algorithm {
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
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
0072
0073
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
0090
0091
0092
0093
0094
0095
0096
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
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
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
0149
0150
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
0165
0166
0167
0168
0169
0170
0171
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
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
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
0225
0226
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
0242
0243
0244
0245
0246
0247
0248
0249
0250
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
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
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
0302
0303
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
0318
0319
0320
0321
0322
0323
0324
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
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
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
0378
0379
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
0395
0396
0397
0398
0399
0400
0401
0402
0403
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
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
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
0458
0459
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
0475
0476
0477
0478
0479
0480
0481
0482
0483
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
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
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
0541
0542
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
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
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
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
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
0622
0623
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
0638
0639
0640
0641
0642
0643
0644
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
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
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
0698
0699
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
0715
0716
0717
0718
0719
0720
0721
0722
0723
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
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
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
0778
0779
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
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
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
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
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
0858
0859
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
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
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 }
0899
0900
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 }
0925
0926 #endif