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