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