00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 namespace std
00034 {
00035 _GLIBCXX_BEGIN_NAMESPACE_TR1
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 namespace regex_constants
00047 {
00048
00049
00050
00051
00052 enum __syntax_option
00053 {
00054 _S_icase,
00055 _S_nosubs,
00056 _S_optimize,
00057 _S_collate,
00058 _S_ECMAScript,
00059 _S_basic,
00060 _S_extended,
00061 _S_awk,
00062 _S_grep,
00063 _S_egrep,
00064 _S_syntax_last
00065 };
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 typedef unsigned int syntax_option_type;
00079
00080
00081
00082
00083
00084 static const syntax_option_type icase = 1 << _S_icase;
00085
00086
00087
00088
00089
00090
00091 static const syntax_option_type nosubs = 1 << _S_nosubs;
00092
00093
00094
00095
00096
00097
00098
00099 static const syntax_option_type optimize = 1 << _S_optimize;
00100
00101
00102
00103
00104
00105 static const syntax_option_type collate = 1 << _S_collate;
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 static const syntax_option_type ECMAScript = 1 << _S_ECMAScript;
00116
00117
00118
00119
00120
00121
00122
00123
00124 static const syntax_option_type basic = 1 << _S_basic;
00125
00126
00127
00128
00129
00130
00131
00132 static const syntax_option_type extended = 1 << _S_extended;
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 static const syntax_option_type awk = 1 << _S_awk;
00145
00146
00147
00148
00149
00150
00151
00152 static const syntax_option_type grep = 1 << _S_grep;
00153
00154
00155
00156
00157
00158
00159
00160 static const syntax_option_type egrep = 1 << _S_egrep;
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 enum __match_flag
00176 {
00177 _S_not_bol,
00178 _S_not_eol,
00179 _S_not_bow,
00180 _S_not_eow,
00181 _S_any,
00182 _S_not_null,
00183 _S_continuous,
00184 _S_prev_avail,
00185 _S_sed,
00186 _S_no_copy,
00187 _S_first_only,
00188 _S_match_flag_last
00189 };
00190
00191
00192
00193
00194
00195
00196
00197
00198 typedef std::bitset<_S_match_flag_last> match_flag_type;
00199
00200
00201
00202
00203 static const match_flag_type match_default = 0;
00204
00205
00206
00207
00208
00209
00210 static const match_flag_type match_not_bol = 1 << _S_not_bol;
00211
00212
00213
00214
00215
00216
00217 static const match_flag_type match_not_eol = 1 << _S_not_eol;
00218
00219
00220
00221
00222
00223 static const match_flag_type match_not_bow = 1 << _S_not_bow;
00224
00225
00226
00227
00228
00229 static const match_flag_type match_not_eow = 1 << _S_not_eow;
00230
00231
00232
00233
00234
00235 static const match_flag_type match_any = 1 << _S_any;
00236
00237
00238
00239
00240 static const match_flag_type match_not_null = 1 << _S_not_null;
00241
00242
00243
00244
00245 static const match_flag_type match_continuous = 1 << _S_continuous;
00246
00247
00248
00249
00250
00251
00252 static const match_flag_type match_prev_avail = 1 << _S_prev_avail;
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 static const match_flag_type format_default = 0;
00281
00282
00283
00284
00285
00286
00287
00288 static const match_flag_type format_sed = 1 << _S_sed;
00289
00290
00291
00292
00293
00294
00295 static const match_flag_type format_no_copy = 1 << _S_no_copy;
00296
00297
00298
00299
00300
00301 static const match_flag_type format_first_only = 1 << _S_first_only;
00302
00303
00304
00305
00306
00307
00308
00309
00310 enum error_type
00311 {
00312 _S_error_collate,
00313 _S_error_ctype,
00314 _S_error_escape,
00315 _S_error_backref,
00316 _S_error_brack,
00317 _S_error_paren,
00318 _S_error_brace,
00319 _S_error_badbrace,
00320 _S_error_range,
00321 _S_error_space,
00322 _S_error_badrepeat,
00323 _S_error_complexity,
00324 _S_error_stack,
00325 _S_error_last
00326 };
00327
00328
00329 static const error_type error_collate(_S_error_collate);
00330
00331
00332 static const error_type error_ctype(_S_error_ctype);
00333
00334
00335
00336
00337
00338 static const error_type error_escape(_S_error_escape);
00339
00340
00341 static const error_type error_backref(_S_error_backref);
00342
00343
00344 static const error_type error_brack(_S_error_brack);
00345
00346
00347 static const error_type error_paren(_S_error_paren);
00348
00349
00350 static const error_type error_brace(_S_error_brace);
00351
00352
00353 static const error_type error_badbrace(_S_error_badbrace);
00354
00355
00356
00357
00358
00359 static const error_type error_range(_S_error_range);
00360
00361
00362
00363
00364
00365 static const error_type error_space(_S_error_space);
00366
00367
00368
00369
00370 static const error_type error_badrepeat(_S_error_badrepeat);
00371
00372
00373
00374
00375
00376 static const error_type error_complexity(_S_error_complexity);
00377
00378
00379
00380
00381
00382 static const error_type error_stack(_S_error_stack);
00383
00384
00385 }
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 class regex_error
00396 : public std::runtime_error
00397 {
00398 public:
00399
00400
00401
00402
00403
00404 explicit
00405 regex_error(regex_constants::error_type __ecode)
00406 : std::runtime_error("regex_error"), _M_code(__ecode)
00407 { }
00408
00409
00410
00411
00412
00413
00414 regex_constants::error_type
00415 code() const
00416 { return _M_code; }
00417
00418 protected:
00419 regex_constants::error_type _M_code;
00420 };
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433 template<typename _Ch_type>
00434 struct regex_traits
00435 {
00436 public:
00437 typedef _Ch_type char_type;
00438 typedef std::basic_string<char_type> string_type;
00439 typedef std::locale locale_type;
00440 typedef std::ctype_base::mask char_class_type;
00441
00442 public:
00443
00444
00445
00446 regex_traits()
00447 { }
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 static std::size_t
00460 length(const char_type* __p)
00461 { return string_type::traits_type::length(__p); }
00462
00463
00464
00465
00466
00467
00468
00469
00470 char_type
00471 translate(char_type __c) const
00472 { return __c; }
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483 char_type
00484 translate_nocase(char_type __c) const
00485 {
00486 using std::ctype;
00487 using std::use_facet;
00488 return use_facet<ctype<char_type> >(_M_locale).tolower(__c);
00489 }
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 template<typename _Fwd_iter>
00512 string_type
00513 transform(_Fwd_iter __first, _Fwd_iter __last) const
00514 {
00515 using std::collate;
00516 using std::use_facet;
00517 const collate<_Ch_type>& __c(use_facet<
00518 collate<_Ch_type> >(_M_locale));
00519 string_type __s(__first, __last);
00520 return __c.transform(__s.data(), __s.data() + __s.size());
00521 }
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537 template<typename _Fwd_iter>
00538 string_type
00539 transform_primary(_Fwd_iter __first, _Fwd_iter __last) const;
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554 template<typename _Fwd_iter>
00555 string_type
00556 lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const;
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 template<typename _Fwd_iter>
00592 char_class_type
00593 lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const;
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607 bool
00608 isctype(_Ch_type __c, char_class_type __f) const;
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 int
00621 value(_Ch_type __ch, int __radix) const;
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634 locale_type
00635 imbue(locale_type __loc)
00636 {
00637 std::swap(_M_locale, __loc);
00638 return __loc;
00639 }
00640
00641
00642
00643
00644
00645 locale_type
00646 getloc() const
00647 { return _M_locale; }
00648
00649 protected:
00650 locale_type _M_locale;
00651 };
00652
00653 template<typename _Ch_type>
00654 bool regex_traits<_Ch_type>::
00655 isctype(_Ch_type __c, char_class_type __f) const
00656 {
00657 using std::ctype;
00658 using std::use_facet;
00659 const ctype<_Ch_type>& __ctype(use_facet<
00660 ctype<_Ch_type> >(_M_locale));
00661
00662 if (__ctype.is(__c, __f))
00663 return true;
00664
00665
00666 if (__c == __ctype.widen('_'))
00667 {
00668 const char* const __wb[] = "w";
00669 char_class_type __wt = this->lookup_classname(__wb,
00670 __wb + sizeof(__wb));
00671 if (__f | __wt)
00672 return true;
00673 }
00674
00675
00676 if (__c == __ctype.isspace(__c))
00677 {
00678 const char* const __bb[] = "blank";
00679 char_class_type __bt = this->lookup_classname(__bb,
00680 __bb + sizeof(__bb));
00681 if (__f | __bt)
00682 return true;
00683 }
00684
00685 return false;
00686 }
00687
00688 template<typename _Ch_type>
00689 int regex_traits<_Ch_type>::
00690 value(_Ch_type __ch, int __radix) const
00691 {
00692 std::basic_istringstream<_Ch_type> __is(string_type(1, __ch));
00693 int __v;
00694 if (__radix == 8)
00695 __is >> std::oct;
00696 else if (__radix == 16)
00697 __is >> std::hex;
00698 __is >> __v;
00699 return __is.fail() ? -1 : __v;
00700 }
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710 template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
00711 class basic_regex
00712 {
00713 public:
00714
00715 typedef _Ch_type value_type;
00716 typedef regex_constants::syntax_option_type flag_type;
00717 typedef typename _Rx_traits::locale_type locale_type;
00718 typedef typename _Rx_traits::string_type string_type;
00719
00720
00721
00722
00723
00724
00725 static const regex_constants::syntax_option_type icase
00726 = regex_constants::icase;
00727 static const regex_constants::syntax_option_type nosubs
00728 = regex_constants::nosubs;
00729 static const regex_constants::syntax_option_type optimize
00730 = regex_constants::optimize;
00731 static const regex_constants::syntax_option_type collate
00732 = regex_constants::collate;
00733 static const regex_constants::syntax_option_type ECMAScript
00734 = regex_constants::ECMAScript;
00735 static const regex_constants::syntax_option_type basic
00736 = regex_constants::basic;
00737 static const regex_constants::syntax_option_type extended
00738 = regex_constants::extended;
00739 static const regex_constants::syntax_option_type awk
00740 = regex_constants::awk;
00741 static const regex_constants::syntax_option_type grep
00742 = regex_constants::grep;
00743 static const regex_constants::syntax_option_type egrep
00744 = regex_constants::egrep;
00745
00746
00747
00748
00749
00750
00751
00752 basic_regex()
00753 : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0)
00754 { _M_compile(); }
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767 explicit
00768 basic_regex(const _Ch_type* __p,
00769 flag_type __f = regex_constants::ECMAScript)
00770 : _M_flags(__f), _M_pattern(__p), _M_mark_count(0)
00771 { _M_compile(); }
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
00785 : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0)
00786 { _M_compile(); }
00787
00788
00789
00790
00791
00792
00793 basic_regex(const basic_regex& __rhs)
00794 : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern),
00795 _M_mark_count(__rhs._M_mark_count)
00796 { _M_compile(); }
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807 template<typename _Ch_traits, typename _Ch_alloc>
00808 explicit
00809 basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
00810 flag_type __f = regex_constants::ECMAScript)
00811 : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0)
00812 { _M_compile(); }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827 template<typename _InputIterator>
00828 basic_regex(_InputIterator __first, _InputIterator __last,
00829 flag_type __f = regex_constants::ECMAScript)
00830 : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0)
00831 { _M_compile(); }
00832
00833 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00834
00835
00836
00837
00838
00839
00840
00841
00842 basic_regex(initializer_list<_Ch_type> __l,
00843 flag_type __f = regex_constants::ECMAScript)
00844 : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0)
00845 { _M_compile(); }
00846 #endif
00847
00848
00849
00850
00851 ~basic_regex()
00852 { }
00853
00854
00855
00856
00857 basic_regex&
00858 operator=(const basic_regex& __rhs)
00859 { return this->assign(__rhs); }
00860
00861
00862
00863
00864
00865
00866
00867
00868 basic_regex&
00869 operator=(const _Ch_type* __p)
00870 { return this->assign(__p, flags()); }
00871
00872
00873
00874
00875
00876
00877
00878 template<typename _Ch_typeraits, typename _Allocator>
00879 basic_regex&
00880 operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s)
00881 { return this->assign(__s, flags()); }
00882
00883
00884
00885
00886
00887
00888
00889 basic_regex&
00890 assign(const basic_regex& __that)
00891 {
00892 basic_regex __tmp(__that);
00893 this->swap(__tmp);
00894 return *this;
00895 }
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910 basic_regex&
00911 assign(const _Ch_type* __p,
00912 flag_type __flags = regex_constants::ECMAScript)
00913 { return this->assign(string_type(__p), __flags); }
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928 basic_regex&
00929 assign(const _Ch_type* __p, std::size_t __len, flag_type __flags)
00930 { return this->assign(string_type(__p, __len), __flags); }
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943 template<typename _Ch_typeraits, typename _Allocator>
00944 basic_regex&
00945 assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s,
00946 flag_type __f = regex_constants::ECMAScript)
00947 {
00948 basic_regex __tmp(__s, __f);
00949 this->swap(__tmp);
00950 return *this;
00951 }
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966 template<typename _InputIterator>
00967 basic_regex&
00968 assign(_InputIterator __first, _InputIterator __last,
00969 flag_type __flags = regex_constants::ECMAScript)
00970 { return this->assign(string_type(__first, __last), __flags); }
00971
00972 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983 basic_regex&
00984 assign(initializer_list<_Ch_type> __l,
00985 flag_type __f = regex_constants::ECMAScript)
00986 { return this->assign(__l.begin(), __l.end(), __f); }
00987 #endif
00988
00989
00990
00991
00992
00993
00994 unsigned int
00995 mark_count() const
00996 { return _M_mark_count; }
00997
00998
00999
01000
01001
01002 flag_type
01003 flags() const
01004 { return _M_flags; }
01005
01006
01007
01008
01009
01010
01011
01012 locale_type
01013 imbue(locale_type __loc)
01014 { return _M_traits.imbue(__loc); }
01015
01016
01017
01018
01019
01020 locale_type
01021 getloc() const
01022 { return _M_traits.getloc(); }
01023
01024
01025
01026
01027
01028
01029
01030 void
01031 swap(basic_regex& __rhs)
01032 {
01033 std::swap(_M_flags, __rhs._M_flags);
01034 std::swap(_M_pattern, __rhs._M_pattern);
01035 std::swap(_M_mark_count, __rhs._M_mark_count);
01036 std::swap(_M_traits, __rhs._M_traits);
01037 }
01038
01039 private:
01040
01041
01042
01043
01044 void _M_compile();
01045
01046 protected:
01047 flag_type _M_flags;
01048 string_type _M_pattern;
01049 unsigned int _M_mark_count;
01050 _Rx_traits _M_traits;
01051 };
01052
01053
01054 typedef basic_regex<char> regex;
01055 #ifdef _GLIBCXX_USE_WCHAR_T
01056
01057 typedef basic_regex<wchar_t> wregex;
01058 #endif
01059
01060
01061
01062
01063
01064
01065
01066
01067 template<typename _Ch_type, typename _Rx_traits>
01068 inline void
01069 swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
01070 basic_regex<_Ch_type, _Rx_traits>& __rhs)
01071 { __lhs.swap(__rhs); }
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087 template<typename _BiIter>
01088 class sub_match : public std::pair<_BiIter, _BiIter>
01089 {
01090 public:
01091 typedef typename iterator_traits<_BiIter>::value_type value_type;
01092 typedef typename iterator_traits<_BiIter>::difference_type
01093 difference_type;
01094 typedef _BiIter iterator;
01095
01096 public:
01097 bool matched;
01098
01099
01100
01101
01102 difference_type
01103 length() const
01104 { return this->matched ? std::distance(this->first, this->second) : 0; }
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116 operator basic_string<value_type>() const
01117 {
01118 return this->matched
01119 ? std::basic_string<value_type>(this->first, this->second)
01120 : std::basic_string<value_type>();
01121 }
01122
01123
01124
01125
01126
01127
01128 basic_string<value_type>
01129 str() const
01130 {
01131 return this->matched
01132 ? std::basic_string<value_type>(this->first, this->second)
01133 : std::basic_string<value_type>();
01134 }
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145 int
01146 compare(const sub_match& __s) const
01147 { return this->str().compare(__s.str()); }
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 int
01159 compare(const basic_string<value_type>& __s) const
01160 { return this->str().compare(__s); }
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171 int
01172 compare(const value_type* __s) const
01173 { return this->str().compare(__s); }
01174 };
01175
01176
01177
01178 typedef sub_match<const char*> csub_match;
01179
01180 typedef sub_match<string::const_iterator> ssub_match;
01181 #ifdef _GLIBCXX_USE_WCHAR_T
01182
01183 typedef sub_match<const wchar_t*> wcsub_match;
01184
01185 typedef sub_match<wstring::const_iterator> wssub_match;
01186 #endif
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196 template<typename _BiIter>
01197 inline bool
01198 operator==(const sub_match<_BiIter>& __lhs,
01199 const sub_match<_BiIter>& __rhs)
01200 { return __lhs.compare(__rhs) == 0; }
01201
01202
01203
01204
01205
01206
01207
01208 template<typename _BiIter>
01209 inline bool
01210 operator!=(const sub_match<_BiIter>& __lhs,
01211 const sub_match<_BiIter>& __rhs)
01212 { return __lhs.compare(__rhs) != 0; }
01213
01214
01215
01216
01217
01218
01219
01220 template<typename _BiIter>
01221 inline bool
01222 operator<(const sub_match<_BiIter>& __lhs,
01223 const sub_match<_BiIter>& __rhs)
01224 { return __lhs.compare(__rhs) < 0; }
01225
01226
01227
01228
01229
01230
01231
01232 template<typename _BiIter>
01233 inline bool
01234 operator<=(const sub_match<_BiIter>& __lhs,
01235 const sub_match<_BiIter>& __rhs)
01236 { return __lhs.compare(__rhs) <= 0; }
01237
01238
01239
01240
01241
01242
01243
01244 template<typename _BiIter>
01245 inline bool
01246 operator>=(const sub_match<_BiIter>& __lhs,
01247 const sub_match<_BiIter>& __rhs)
01248 { return __lhs.compare(__rhs) >= 0; }
01249
01250
01251
01252
01253
01254
01255
01256 template<typename _BiIter>
01257 inline bool
01258 operator>(const sub_match<_BiIter>& __lhs,
01259 const sub_match<_BiIter>& __rhs)
01260 { return __lhs.compare(__rhs) > 0; }
01261
01262
01263
01264
01265
01266
01267
01268
01269 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01270 inline bool
01271 operator==(const basic_string<
01272 typename iterator_traits<_Bi_iter>::value_type,
01273 _Ch_traits, _Ch_alloc>& __lhs,
01274 const sub_match<_Bi_iter>& __rhs)
01275 { return __lhs == __rhs.str(); }
01276
01277
01278
01279
01280
01281
01282
01283
01284 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01285 inline bool
01286 operator!=(const basic_string<
01287 typename iterator_traits<_Bi_iter>::value_type,
01288 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
01289 { return __lhs != __rhs.str(); }
01290
01291
01292
01293
01294
01295
01296
01297 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01298 inline bool
01299 operator<(const basic_string<
01300 typename iterator_traits<_Bi_iter>::value_type,
01301 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
01302 { return __lhs < __rhs.str(); }
01303
01304
01305
01306
01307
01308
01309
01310 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01311 inline bool
01312 operator>(const basic_string<
01313 typename iterator_traits<_Bi_iter>::value_type,
01314 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
01315 { return __lhs > __rhs.str(); }
01316
01317
01318
01319
01320
01321
01322
01323 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01324 inline bool
01325 operator>=(const basic_string<
01326 typename iterator_traits<_Bi_iter>::value_type,
01327 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
01328 { return __lhs >= __rhs.str(); }
01329
01330
01331
01332
01333
01334
01335
01336 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01337 inline bool
01338 operator<=(const basic_string<
01339 typename iterator_traits<_Bi_iter>::value_type,
01340 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
01341 { return __lhs <= __rhs.str(); }
01342
01343
01344
01345
01346
01347
01348
01349
01350 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01351 inline bool
01352 operator==(const sub_match<_Bi_iter>& __lhs,
01353 const basic_string<
01354 typename iterator_traits<_Bi_iter>::value_type,
01355 _Ch_traits, _Ch_alloc>& __rhs)
01356 { return __lhs.str() == __rhs; }
01357
01358
01359
01360
01361
01362
01363
01364
01365 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
01366 inline bool
01367 operator!=(const sub_match<_Bi_iter>& __lhs,
01368 const basic_string<
01369 typename iterator_traits<_Bi_iter>::value_type,
01370 _Ch_traits, _Ch_alloc>& __rhs)
01371 { return __lhs.str() != __rhs; }
01372
01373
01374
01375
01376
01377
01378
01379 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
01380 inline bool
01381 operator<(const sub_match<_Bi_iter>& __lhs,
01382 const basic_string<
01383 typename iterator_traits<_Bi_iter>::value_type,
01384 _Ch_traits, _Ch_alloc>& __rhs)
01385 { return __lhs.str() < __rhs; }
01386
01387
01388
01389
01390
01391
01392
01393 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
01394 inline bool
01395 operator>(const sub_match<_Bi_iter>& __lhs,
01396 const basic_string<
01397 typename iterator_traits<_Bi_iter>::value_type,
01398 _Ch_traits, _Ch_alloc>& __rhs)
01399 { return __lhs.str() > __rhs; }
01400
01401
01402
01403
01404
01405
01406
01407 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
01408 inline bool
01409 operator>=(const sub_match<_Bi_iter>& __lhs,
01410 const basic_string<
01411 typename iterator_traits<_Bi_iter>::value_type,
01412 _Ch_traits, _Ch_alloc>& __rhs)
01413 { return __lhs.str() >= __rhs; }
01414
01415
01416
01417
01418
01419
01420
01421 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
01422 inline bool
01423 operator<=(const sub_match<_Bi_iter>& __lhs,
01424 const basic_string<
01425 typename iterator_traits<_Bi_iter>::value_type,
01426 _Ch_traits, _Ch_alloc>& __rhs)
01427 { return __lhs.str() <= __rhs; }
01428
01429
01430
01431
01432
01433
01434
01435
01436 template<typename _Bi_iter>
01437 inline bool
01438 operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01439 const sub_match<_Bi_iter>& __rhs)
01440 { return __lhs == __rhs.str(); }
01441
01442
01443
01444
01445
01446
01447
01448
01449 template<typename _Bi_iter>
01450 inline bool
01451 operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01452 const sub_match<_Bi_iter>& __rhs)
01453 { return __lhs != __rhs.str(); }
01454
01455
01456
01457
01458
01459
01460
01461 template<typename _Bi_iter>
01462 inline bool
01463 operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01464 const sub_match<_Bi_iter>& __rhs)
01465 { return __lhs < __rhs.str(); }
01466
01467
01468
01469
01470
01471
01472
01473 template<typename _Bi_iter>
01474 inline bool
01475 operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01476 const sub_match<_Bi_iter>& __rhs)
01477 { return __lhs > __rhs.str(); }
01478
01479
01480
01481
01482
01483
01484
01485 template<typename _Bi_iter>
01486 inline bool
01487 operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01488 const sub_match<_Bi_iter>& __rhs)
01489 { return __lhs >= __rhs.str(); }
01490
01491
01492
01493
01494
01495
01496
01497 template<typename _Bi_iter>
01498 inline bool
01499 operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
01500 const sub_match<_Bi_iter>& __rhs)
01501 { return __lhs <= __rhs.str(); }
01502
01503
01504
01505
01506
01507
01508
01509
01510 template<typename _Bi_iter>
01511 inline bool
01512 operator==(const sub_match<_Bi_iter>& __lhs,
01513 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01514 { return __lhs.str() == __rhs; }
01515
01516
01517
01518
01519
01520
01521
01522
01523 template<typename _Bi_iter>
01524 inline bool
01525 operator!=(const sub_match<_Bi_iter>& __lhs,
01526 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01527 { return __lhs.str() != __rhs; }
01528
01529
01530
01531
01532
01533
01534
01535 template<typename _Bi_iter>
01536 inline bool
01537 operator<(const sub_match<_Bi_iter>& __lhs,
01538 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01539 { return __lhs.str() < __rhs; }
01540
01541
01542
01543
01544
01545
01546
01547 template<typename _Bi_iter>
01548 inline bool
01549 operator>(const sub_match<_Bi_iter>& __lhs,
01550 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01551 { return __lhs.str() > __rhs; }
01552
01553
01554
01555
01556
01557
01558
01559 template<typename _Bi_iter>
01560 inline bool
01561 operator>=(const sub_match<_Bi_iter>& __lhs,
01562 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01563 { return __lhs.str() >= __rhs; }
01564
01565
01566
01567
01568
01569
01570
01571 template<typename _Bi_iter>
01572 inline bool
01573 operator<=(const sub_match<_Bi_iter>& __lhs,
01574 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
01575 { return __lhs.str() <= __rhs; }
01576
01577
01578
01579
01580
01581
01582
01583
01584 template<typename _Bi_iter>
01585 inline bool
01586 operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01587 const sub_match<_Bi_iter>& __rhs)
01588 { return __lhs == __rhs.str(); }
01589
01590
01591
01592
01593
01594
01595
01596
01597 template<typename _Bi_iter>
01598 inline bool
01599 operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01600 const sub_match<_Bi_iter>& __rhs)
01601 { return __lhs != __rhs.str(); }
01602
01603
01604
01605
01606
01607
01608
01609 template<typename _Bi_iter>
01610 inline bool
01611 operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01612 const sub_match<_Bi_iter>& __rhs)
01613 { return __lhs < __rhs.str(); }
01614
01615
01616
01617
01618
01619
01620
01621 template<typename _Bi_iter>
01622 inline bool
01623 operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01624 const sub_match<_Bi_iter>& __rhs)
01625 { return __lhs > __rhs.str(); }
01626
01627
01628
01629
01630
01631
01632
01633 template<typename _Bi_iter>
01634 inline bool
01635 operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01636 const sub_match<_Bi_iter>& __rhs)
01637 { return __lhs >= __rhs.str(); }
01638
01639
01640
01641
01642
01643
01644
01645 template<typename _Bi_iter>
01646 inline bool
01647 operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
01648 const sub_match<_Bi_iter>& __rhs)
01649 { return __lhs <= __rhs.str(); }
01650
01651
01652
01653
01654
01655
01656
01657
01658 template<typename _Bi_iter>
01659 inline bool
01660 operator==(const sub_match<_Bi_iter>& __lhs,
01661 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01662 { return __lhs.str() == __rhs; }
01663
01664
01665
01666
01667
01668
01669
01670
01671 template<typename _Bi_iter>
01672 inline bool
01673 operator!=(const sub_match<_Bi_iter>& __lhs,
01674 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01675 { return __lhs.str() != __rhs; }
01676
01677
01678
01679
01680
01681
01682
01683 template<typename _Bi_iter>
01684 inline bool
01685 operator<(const sub_match<_Bi_iter>& __lhs,
01686 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01687 { return __lhs.str() < __rhs; }
01688
01689
01690
01691
01692
01693
01694
01695 template<typename _Bi_iter>
01696 inline bool
01697 operator>(const sub_match<_Bi_iter>& __lhs,
01698 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01699 { return __lhs.str() > __rhs; }
01700
01701
01702
01703
01704
01705
01706
01707 template<typename _Bi_iter>
01708 inline bool
01709 operator>=(const sub_match<_Bi_iter>& __lhs,
01710 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01711 { return __lhs.str() >= __rhs; }
01712
01713
01714
01715
01716
01717
01718
01719 template<typename _Bi_iter>
01720 inline bool
01721 operator<=(const sub_match<_Bi_iter>& __lhs,
01722 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
01723 { return __lhs.str() <= __rhs; }
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733 template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
01734 inline
01735 basic_ostream<_Ch_type, _Ch_traits>&
01736 operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
01737 const sub_match<_Bi_iter>& __m)
01738 { return __os << __m.str(); }
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763 template<typename _Bi_iter,
01764 typename _Allocator = allocator<sub_match<_Bi_iter> > >
01765 class match_results
01766 : private std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator>
01767 {
01768 private:
01769 typedef std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator>
01770 _Base_type;
01771
01772 public:
01773
01774
01775
01776
01777 typedef sub_match<_Bi_iter> value_type;
01778 typedef typename _Allocator::const_reference const_reference;
01779 typedef const_reference reference;
01780 typedef typename _Base_type::const_iterator const_iterator;
01781 typedef const_iterator iterator;
01782 typedef typename iterator_traits<_Bi_iter>::difference_type
01783 difference_type;
01784 typedef typename _Allocator::size_type size_type;
01785 typedef _Allocator allocator_type;
01786 typedef typename iterator_traits<_Bi_iter>::value_type char_type;
01787 typedef basic_string<char_type> string_type;
01788
01789
01790 public:
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800 explicit
01801 match_results(const _Allocator& __a = _Allocator())
01802 : _Base_type(__a), _M_matched(false)
01803 { }
01804
01805
01806
01807
01808 match_results(const match_results& __rhs)
01809 : _Base_type(__rhs), _M_matched(__rhs._M_matched),
01810 _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix)
01811 { }
01812
01813
01814
01815
01816 match_results&
01817 operator=(const match_results& __rhs)
01818 {
01819 match_results __tmp(__rhs);
01820 this->swap(__tmp);
01821 return *this;
01822 }
01823
01824
01825
01826
01827 ~match_results()
01828 { }
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846 size_type
01847 size() const
01848 { return _M_matched ? _Base_type::size() + 1 : 0; }
01849
01850
01851
01852 using _Base_type::max_size;
01853
01854
01855
01856
01857
01858
01859 bool
01860 empty() const
01861 { return size() == 0; }
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877 difference_type
01878 length(size_type __sub = 0) const
01879 { return _M_matched ? this->str(__sub).length() : 0; }
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891 difference_type
01892 position(size_type __sub = 0) const
01893 {
01894 return _M_matched ? std::distance(this->prefix().first,
01895 (*this)[__sub].first) : 0;
01896 }
01897
01898
01899
01900
01901
01902
01903
01904
01905 string_type
01906 str(size_type __sub = 0) const
01907 { return _M_matched ? (*this)[__sub].str() : string_type(); }
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919 const_reference
01920 operator[](size_type __sub) const
01921 { return _Base_type::operator[](__sub); }
01922
01923
01924
01925
01926
01927
01928
01929
01930 const_reference
01931 prefix() const
01932 { return _M_prefix; }
01933
01934
01935
01936
01937
01938
01939
01940
01941 const_reference
01942 suffix() const
01943 { return _M_suffix; }
01944
01945
01946
01947
01948 const_iterator
01949 begin() const
01950 { return _Base_type::begin(); }
01951
01952 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
01953
01954
01955
01956 const_iterator
01957 cbegin() const
01958 { return _Base_type::begin(); }
01959 #endif
01960
01961
01962
01963
01964 const_iterator
01965 end() const
01966 { return _Base_type::end(); }
01967
01968 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
01969
01970
01971
01972 const_iterator
01973 cend() const
01974 { return _Base_type::end(); }
01975 #endif
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992 template<typename _Out_iter>
01993 _Out_iter
01994 format(_Out_iter __out, const string_type& __fmt,
01995 regex_constants::match_flag_type __flags
01996 = regex_constants::format_default) const;
01997
01998
01999
02000
02001 string_type
02002 format(const string_type& __fmt,
02003 regex_constants::match_flag_type __flags
02004 = regex_constants::format_default) const;
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018 using _Base_type::get_allocator;
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030 void
02031 swap(match_results& __that)
02032 {
02033 _Base_type::swap(__that);
02034 std::swap(_M_matched, __that._M_matched);
02035 std::swap(_M_prefix, __that._M_prefix);
02036 std::swap(_M_suffix, __that._M_suffix);
02037 }
02038
02039
02040 private:
02041 bool _M_matched;
02042 value_type _M_prefix;
02043 value_type _M_suffix;
02044 };
02045
02046 typedef match_results<const char*> cmatch;
02047 typedef match_results<string::const_iterator> smatch;
02048 #ifdef _GLIBCXX_USE_WCHAR_T
02049 typedef match_results<const wchar_t*> wcmatch;
02050 typedef match_results<wstring::const_iterator> wsmatch;
02051 #endif
02052
02053
02054
02055
02056
02057
02058
02059
02060 template<typename _Bi_iter, typename _Allocator>
02061 inline bool
02062 operator==(const match_results<_Bi_iter, _Allocator>& __m1,
02063 const match_results<_Bi_iter, _Allocator>& __m2);
02064
02065
02066
02067
02068
02069
02070 template<typename _Bi_iter, class _Allocator>
02071 inline bool
02072 operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
02073 const match_results<_Bi_iter, _Allocator>& __m2)
02074 { return !(__m1 == __m2); }
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084 template<typename _Bi_iter, typename _Allocator>
02085 inline void
02086 swap(match_results<_Bi_iter, _Allocator>& __lhs,
02087 match_results<_Bi_iter, _Allocator>& __rhs)
02088 { __lhs.swap(__rhs); }
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113 template<typename _Bi_iter, typename _Allocator,
02114 typename _Ch_type, typename _Rx_traits>
02115 bool
02116 regex_match(_Bi_iter __first, _Bi_iter __last,
02117 match_results<_Bi_iter, _Allocator>& __m,
02118 const basic_regex<_Ch_type, _Rx_traits>& __re,
02119 regex_constants::match_flag_type __flags
02120 = regex_constants::match_default);
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
02137 bool
02138 regex_match(_Bi_iter __first, _Bi_iter __last,
02139 const basic_regex<_Ch_type, _Rx_traits>& __re,
02140 regex_constants::match_flag_type __flags
02141 = regex_constants::match_default)
02142 {
02143 match_results<_Bi_iter> __what;
02144 return regex_match(__first, __last, __what, __re, __flags);
02145 }
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161 template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
02162 inline bool
02163 regex_match(const _Ch_type* __s,
02164 match_results<const _Ch_type*, _Allocator>& __m,
02165 const basic_regex<_Ch_type, _Rx_traits>& __re,
02166 regex_constants::match_flag_type __f
02167 = regex_constants::match_default)
02168 { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184 template<typename _Ch_traits, typename _Ch_alloc,
02185 typename _Allocator, typename _Ch_type, typename _Rx_traits>
02186 inline bool
02187 regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
02188 match_results<typename basic_string<_Ch_type,
02189 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
02190 const basic_regex<_Ch_type, _Rx_traits>& __re,
02191 regex_constants::match_flag_type __flags
02192 = regex_constants::match_default)
02193 { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208 template<typename _Ch_type, class _Rx_traits>
02209 inline bool
02210 regex_match(const _Ch_type* __s,
02211 const basic_regex<_Ch_type, _Rx_traits>& __re,
02212 regex_constants::match_flag_type __f
02213 = regex_constants::match_default)
02214 { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229 template<typename _Ch_traits, typename _Str_allocator,
02230 typename _Ch_type, typename _Rx_traits>
02231 inline bool
02232 regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s,
02233 const basic_regex<_Ch_type, _Rx_traits>& __re,
02234 regex_constants::match_flag_type __flags
02235 = regex_constants::match_default)
02236 { return regex_match(__s.begin(), __s.end(), __re, __flags); }
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254 template<typename _Bi_iter, typename _Allocator,
02255 typename _Ch_type, typename _Rx_traits>
02256 inline bool
02257 regex_search(_Bi_iter __first, _Bi_iter __last,
02258 match_results<_Bi_iter, _Allocator>& __m,
02259 const basic_regex<_Ch_type, _Rx_traits>& __re,
02260 regex_constants::match_flag_type __flags
02261 = regex_constants::match_default);
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
02276 inline bool
02277 regex_search(_Bi_iter __first, _Bi_iter __last,
02278 const basic_regex<_Ch_type, _Rx_traits>& __re,
02279 regex_constants::match_flag_type __flags
02280 = regex_constants::match_default)
02281 {
02282 match_results<_Bi_iter> __what;
02283 return regex_search(__first, __last, __what, __re, __flags);
02284 }
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299 template<typename _Ch_type, class _Allocator, class _Rx_traits>
02300 inline bool
02301 regex_search(const _Ch_type* __s,
02302 match_results<const _Ch_type*, _Allocator>& __m,
02303 const basic_regex<_Ch_type, _Rx_traits>& __e,
02304 regex_constants::match_flag_type __f
02305 = regex_constants::match_default)
02306 { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319 template<typename _Ch_type, typename _Rx_traits>
02320 inline bool
02321 regex_search(const _Ch_type* __s,
02322 const basic_regex<_Ch_type, _Rx_traits>& __e,
02323 regex_constants::match_flag_type __f
02324 = regex_constants::match_default)
02325 { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338 template<typename _Ch_traits, typename _String_allocator,
02339 typename _Ch_type, typename _Rx_traits>
02340 inline bool
02341 regex_search(const basic_string<_Ch_type, _Ch_traits,
02342 _String_allocator>& __s,
02343 const basic_regex<_Ch_type, _Rx_traits>& __e,
02344 regex_constants::match_flag_type __flags
02345 = regex_constants::match_default)
02346 { return regex_search(__s.begin(), __s.end(), __e, __flags); }
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360 template<typename _Ch_traits, typename _Ch_alloc,
02361 typename _Allocator, typename _Ch_type,
02362 typename _Rx_traits>
02363 inline bool
02364 regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
02365 match_results<typename basic_string<_Ch_type,
02366 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
02367 const basic_regex<_Ch_type, _Rx_traits>& __e,
02368 regex_constants::match_flag_type __f
02369 = regex_constants::match_default)
02370 { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387 template<typename _Out_iter, typename _Bi_iter,
02388 typename _Rx_traits, typename _Ch_type>
02389 inline _Out_iter
02390 regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
02391 const basic_regex<_Ch_type, _Rx_traits>& __e,
02392 const basic_string<_Ch_type>& __fmt,
02393 regex_constants::match_flag_type __flags
02394 = regex_constants::match_default);
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407 template<typename _Rx_traits, typename _Ch_type>
02408 inline basic_string<_Ch_type>
02409 regex_replace(const basic_string<_Ch_type>& __s,
02410 const basic_regex<_Ch_type, _Rx_traits>& __e,
02411 const basic_string<_Ch_type>& __fmt,
02412 regex_constants::match_flag_type __flags
02413 = regex_constants::match_default)
02414 {
02415 std::string __result;
02416 regex_replace(std::back_inserter(__result),
02417 __s.begin(), __s.end(), __e, __fmt, __flags);
02418 return __result;
02419 }
02420
02421
02422
02423
02424
02425
02426
02427
02428 template<typename _Bi_iter,
02429 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
02430 typename _Rx_traits = regex_traits<_Ch_type> >
02431 class regex_iterator
02432 {
02433 public:
02434 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
02435 typedef match_results<_Bi_iter> value_type;
02436 typedef std::ptrdiff_t difference_type;
02437 typedef const value_type* pointer;
02438 typedef const value_type& reference;
02439 typedef std::forward_iterator_tag iterator_category;
02440
02441 public:
02442
02443
02444
02445
02446
02447
02448 regex_iterator();
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459 regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
02460 regex_constants::match_flag_type __m
02461 = regex_constants::match_default);
02462
02463
02464
02465
02466
02467
02468 regex_iterator(const regex_iterator& __rhs);
02469
02470
02471
02472
02473
02474 regex_iterator&
02475 operator=(const regex_iterator& __rhs);
02476
02477
02478
02479
02480
02481 bool
02482 operator==(const regex_iterator& __rhs);
02483
02484
02485
02486
02487
02488 bool
02489 operator!=(const regex_iterator& __rhs);
02490
02491
02492
02493
02494
02495 const value_type&
02496 operator*();
02497
02498
02499
02500
02501
02502 const value_type*
02503 operator->();
02504
02505
02506
02507
02508
02509 regex_iterator&
02510 operator++();
02511
02512
02513
02514
02515
02516 regex_iterator
02517 operator++(int);
02518
02519 private:
02520
02521 _Bi_iter begin;
02522 _Bi_iter end;
02523 const regex_type* pregex;
02524 regex_constants::match_flag_type flags;
02525 match_results<_Bi_iter> match;
02526 };
02527
02528 typedef regex_iterator<const char*> cregex_iterator;
02529 typedef regex_iterator<string::const_iterator> sregex_iterator;
02530 #ifdef _GLIBCXX_USE_WCHAR_T
02531 typedef regex_iterator<const wchar_t*> wcregex_iterator;
02532 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
02533 #endif
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543 template<typename _Bi_iter,
02544 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
02545 typename _Rx_traits = regex_traits<_Ch_type> >
02546 class regex_token_iterator
02547 {
02548 public:
02549 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
02550 typedef sub_match<_Bi_iter> value_type;
02551 typedef std::ptrdiff_t difference_type;
02552 typedef const value_type* pointer;
02553 typedef const value_type& reference;
02554 typedef std::forward_iterator_tag iterator_category;
02555
02556 public:
02557
02558
02559
02560
02561
02562
02563
02564
02565 regex_token_iterator();
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587 regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
02588 int __submatch = 0,
02589 regex_constants::match_flag_type __m
02590 = regex_constants::match_default);
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
02605 const regex_type& __re,
02606 const std::vector<int>& __submatches,
02607 regex_constants::match_flag_type __m
02608 = regex_constants::match_default);
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622 template<std::size_t _Nm>
02623 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
02624 const regex_type& __re,
02625 const int (&__submatches)[_Nm],
02626 regex_constants::match_flag_type __m
02627 = regex_constants::match_default);
02628
02629
02630
02631
02632
02633
02634 regex_token_iterator(const regex_token_iterator& __rhs);
02635
02636
02637
02638
02639
02640
02641 regex_token_iterator&
02642 operator=(const regex_token_iterator& __rhs);
02643
02644
02645
02646
02647
02648 bool
02649 operator==(const regex_token_iterator& __rhs);
02650
02651
02652
02653
02654
02655 bool
02656 operator!=(const regex_token_iterator& __rhs);
02657
02658
02659
02660
02661
02662 const value_type&
02663 operator*();
02664
02665
02666
02667
02668
02669 const value_type*
02670 operator->();
02671
02672
02673
02674
02675
02676 regex_token_iterator&
02677 operator++();
02678
02679
02680
02681
02682
02683 regex_token_iterator
02684 operator++(int);
02685
02686 private:
02687 typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
02688
02689 position_iterator __position;
02690 const value_type* __result;
02691 value_type __suffix;
02692 std::size_t __n;
02693 std::vector<int> __subs;
02694 };
02695
02696
02697 typedef regex_token_iterator<const char*> cregex_token_iterator;
02698
02699 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
02700 #ifdef _GLIBCXX_USE_WCHAR_T
02701
02702 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
02703
02704 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
02705 #endif
02706
02707
02708
02709 _GLIBCXX_END_NAMESPACE_TR1
02710 }