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