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<std::sub_match<_Bi_iter>, _Allocator>
01463 {
01464 private:
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476 typedef std::vector<std::sub_match<_Bi_iter>, _Allocator>
01477 _Base_type;
01478
01479 public:
01480
01481
01482
01483
01484 typedef sub_match<_Bi_iter> value_type;
01485 typedef const value_type& const_reference;
01486 typedef const_reference reference;
01487 typedef typename _Base_type::const_iterator const_iterator;
01488 typedef const_iterator iterator;
01489 typedef typename std::iterator_traits<_Bi_iter>::difference_type
01490 difference_type;
01491
01492 typedef typename _Allocator::size_type size_type;
01493 typedef _Allocator allocator_type;
01494 typedef typename std::iterator_traits<_Bi_iter>::value_type
01495 char_type;
01496 typedef std::basic_string<char_type> string_type;
01497
01498
01499 public:
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509 explicit
01510 match_results(const _Allocator& __a = _Allocator())
01511 : _Base_type(__a)
01512 { }
01513
01514
01515
01516
01517 match_results(const match_results& __rhs)
01518 : _Base_type(__rhs)
01519 { }
01520
01521
01522
01523
01524 match_results(match_results&& __rhs) noexcept
01525 : _Base_type(std::move(__rhs))
01526 { }
01527
01528
01529
01530
01531 match_results&
01532 operator=(const match_results& __rhs)
01533 {
01534 match_results(__rhs).swap(*this);
01535 return *this;
01536 }
01537
01538
01539
01540
01541 match_results&
01542 operator=(match_results&& __rhs)
01543 {
01544 match_results(std::move(__rhs)).swap(*this);
01545 return *this;
01546 }
01547
01548
01549
01550
01551 ~match_results()
01552 { }
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562 bool ready() const { return !_Base_type::empty(); }
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578 size_type
01579 size() const
01580 {
01581 size_type __size = _Base_type::size();
01582 return (__size && _Base_type::operator[](0).matched) ? __size - 2 : 0;
01583 }
01584
01585 size_type
01586 max_size() const
01587 { return _Base_type::max_size(); }
01588
01589
01590
01591
01592
01593
01594 bool
01595 empty() const
01596 { return size() == 0; }
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613 difference_type
01614 length(size_type __sub = 0) const
01615 { return (*this)[__sub].length(); }
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630 difference_type
01631 position(size_type __sub = 0) const
01632 {
01633 return __sub < size() ? std::distance(this->prefix().first,
01634 (*this)[__sub].first) : -1;
01635 }
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645 string_type
01646 str(size_type __sub = 0) const
01647 { return (*this)[__sub].str(); }
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660 const_reference
01661 operator[](size_type __sub) const
01662 {
01663 _GLIBCXX_DEBUG_ASSERT( ready() );
01664 return __sub < size()
01665 ? _Base_type::operator[](__sub)
01666 : __unmatched_sub<_Bi_iter>();
01667 }
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677 const_reference
01678 prefix() const
01679 {
01680 _GLIBCXX_DEBUG_ASSERT( ready() );
01681 return !empty()
01682 ? _Base_type::operator[](_Base_type::size() - 2)
01683 : __unmatched_sub<_Bi_iter>();
01684 }
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694 const_reference
01695 suffix() const
01696 {
01697 _GLIBCXX_DEBUG_ASSERT( ready() );
01698 return !empty()
01699 ? _Base_type::operator[](_Base_type::size() - 1)
01700 : __unmatched_sub<_Bi_iter>();
01701 }
01702
01703
01704
01705
01706 const_iterator
01707 begin() const
01708 { return _Base_type::begin(); }
01709
01710
01711
01712
01713 const_iterator
01714 cbegin() const
01715 { return _Base_type::cbegin(); }
01716
01717
01718
01719
01720 const_iterator
01721 end() const
01722 { return !empty() ? _Base_type::end() - 2 : _Base_type::end(); }
01723
01724
01725
01726
01727 const_iterator
01728 cend() const
01729 { return end(); }
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747 template<typename _Out_iter>
01748 _Out_iter
01749 format(_Out_iter __out, const char_type* __fmt_first,
01750 const char_type* __fmt_last,
01751 regex_constants::match_flag_type __flags
01752 = regex_constants::format_default) const
01753 { return __out; }
01754
01755
01756
01757
01758 template<typename _Out_iter, typename _St, typename _Sa>
01759 _Out_iter
01760 format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
01761 regex_constants::match_flag_type __flags
01762 = regex_constants::format_default) const
01763 {
01764 return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
01765 __flags);
01766 }
01767
01768
01769
01770
01771 template<typename _Out_iter, typename _St, typename _Sa>
01772 basic_string<char_type, _St, _Sa>
01773 format(const basic_string<char_type, _St, _Sa>& __fmt,
01774 regex_constants::match_flag_type __flags
01775 = regex_constants::format_default) const
01776 {
01777 basic_string<char_type, _St, _Sa> __result;
01778 format(std::back_inserter(__result), __fmt, __flags);
01779 return __result;
01780 }
01781
01782
01783
01784
01785 string_type
01786 format(const char_type* __fmt,
01787 regex_constants::match_flag_type __flags
01788 = regex_constants::format_default) const
01789 {
01790 string_type __result;
01791 format(std::back_inserter(__result),
01792 __fmt + char_traits<char_type>::length(__fmt),
01793 __flags);
01794 return __result;
01795 }
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807 allocator_type
01808 get_allocator() const
01809 { return _Base_type::get_allocator(); }
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821 void
01822 swap(match_results& __that)
01823 { _Base_type::swap(__that); }
01824
01825
01826 private:
01827 friend class __regex::_SpecializedResults<_Bi_iter, _Allocator>;
01828 };
01829
01830 typedef match_results<const char*> cmatch;
01831 typedef match_results<string::const_iterator> smatch;
01832 #ifdef _GLIBCXX_USE_WCHAR_T
01833 typedef match_results<const wchar_t*> wcmatch;
01834 typedef match_results<wstring::const_iterator> wsmatch;
01835 #endif
01836
01837
01838
01839
01840
01841
01842
01843 template<typename _Bi_iter, typename _Allocator>
01844 inline bool
01845 operator==(const match_results<_Bi_iter, _Allocator>& __m1,
01846 const match_results<_Bi_iter, _Allocator>& __m2)
01847 {
01848 if (__m1.ready() != __m2.ready())
01849 return false;
01850 if (!__m1.ready())
01851 return true;
01852 if (__m1.empty() != __m2.empty())
01853 return false;
01854 if (__m1.empty())
01855 return true;
01856 return __m1.prefix() == __m2.prefix()
01857 && __m1.size() == __m2.size()
01858 && std::equal(__m1.begin(), __m1.end(), __m2.begin())
01859 && __m1.suffix() == __m2.suffix();
01860 }
01861
01862
01863
01864
01865
01866
01867 template<typename _Bi_iter, class _Allocator>
01868 inline bool
01869 operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
01870 const match_results<_Bi_iter, _Allocator>& __m2)
01871 { return !(__m1 == __m2); }
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881 template<typename _Bi_iter, typename _Allocator>
01882 inline void
01883 swap(match_results<_Bi_iter, _Allocator>& __lhs,
01884 match_results<_Bi_iter, _Allocator>& __rhs)
01885 { __lhs.swap(__rhs); }
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910 template<typename _Bi_iter, typename _Allocator,
01911 typename _Ch_type, typename _Rx_traits>
01912 bool
01913 regex_match(_Bi_iter __s,
01914 _Bi_iter __e,
01915 match_results<_Bi_iter, _Allocator>& __m,
01916 const basic_regex<_Ch_type, _Rx_traits>& __re,
01917 regex_constants::match_flag_type __flags
01918 = regex_constants::match_default)
01919 {
01920 __regex::_AutomatonPtr __a = __re._M_get_automaton();
01921 __regex::_Automaton::_SizeT __sz = __a->_M_sub_count();
01922 __regex::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
01923 __regex::_SpecializedResults<_Bi_iter, _Allocator> __r(__sz, __cs, __m);
01924 __regex::_Grep_matcher __matcher(__cs, __r, __a, __flags);
01925 return __m[0].matched;
01926 }
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
01943 bool
01944 regex_match(_Bi_iter __first, _Bi_iter __last,
01945 const basic_regex<_Ch_type, _Rx_traits>& __re,
01946 regex_constants::match_flag_type __flags
01947 = regex_constants::match_default)
01948 {
01949 match_results<_Bi_iter> __what;
01950 return regex_match(__first, __last, __what, __re, __flags);
01951 }
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967 template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
01968 inline bool
01969 regex_match(const _Ch_type* __s,
01970 match_results<const _Ch_type*, _Allocator>& __m,
01971 const basic_regex<_Ch_type, _Rx_traits>& __re,
01972 regex_constants::match_flag_type __f
01973 = regex_constants::match_default)
01974 { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990 template<typename _Ch_traits, typename _Ch_alloc,
01991 typename _Allocator, typename _Ch_type, typename _Rx_traits>
01992 inline bool
01993 regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
01994 match_results<typename basic_string<_Ch_type,
01995 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
01996 const basic_regex<_Ch_type, _Rx_traits>& __re,
01997 regex_constants::match_flag_type __flags
01998 = regex_constants::match_default)
01999 { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014 template<typename _Ch_type, class _Rx_traits>
02015 inline bool
02016 regex_match(const _Ch_type* __s,
02017 const basic_regex<_Ch_type, _Rx_traits>& __re,
02018 regex_constants::match_flag_type __f
02019 = regex_constants::match_default)
02020 { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035 template<typename _Ch_traits, typename _Str_allocator,
02036 typename _Ch_type, typename _Rx_traits>
02037 inline bool
02038 regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s,
02039 const basic_regex<_Ch_type, _Rx_traits>& __re,
02040 regex_constants::match_flag_type __flags
02041 = regex_constants::match_default)
02042 { return regex_match(__s.begin(), __s.end(), __re, __flags); }
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060 template<typename _Bi_iter, typename _Allocator,
02061 typename _Ch_type, typename _Rx_traits>
02062 inline bool
02063 regex_search(_Bi_iter __first, _Bi_iter __last,
02064 match_results<_Bi_iter, _Allocator>& __m,
02065 const basic_regex<_Ch_type, _Rx_traits>& __re,
02066 regex_constants::match_flag_type __flags
02067 = regex_constants::match_default)
02068 { return false; }
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
02083 inline bool
02084 regex_search(_Bi_iter __first, _Bi_iter __last,
02085 const basic_regex<_Ch_type, _Rx_traits>& __re,
02086 regex_constants::match_flag_type __flags
02087 = regex_constants::match_default)
02088 {
02089 match_results<_Bi_iter> __what;
02090 return regex_search(__first, __last, __what, __re, __flags);
02091 }
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106 template<typename _Ch_type, class _Allocator, class _Rx_traits>
02107 inline bool
02108 regex_search(const _Ch_type* __s,
02109 match_results<const _Ch_type*, _Allocator>& __m,
02110 const basic_regex<_Ch_type, _Rx_traits>& __e,
02111 regex_constants::match_flag_type __f
02112 = regex_constants::match_default)
02113 { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126 template<typename _Ch_type, typename _Rx_traits>
02127 inline bool
02128 regex_search(const _Ch_type* __s,
02129 const basic_regex<_Ch_type, _Rx_traits>& __e,
02130 regex_constants::match_flag_type __f
02131 = regex_constants::match_default)
02132 { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145 template<typename _Ch_traits, typename _String_allocator,
02146 typename _Ch_type, typename _Rx_traits>
02147 inline bool
02148 regex_search(const basic_string<_Ch_type, _Ch_traits,
02149 _String_allocator>& __s,
02150 const basic_regex<_Ch_type, _Rx_traits>& __e,
02151 regex_constants::match_flag_type __flags
02152 = regex_constants::match_default)
02153 { return regex_search(__s.begin(), __s.end(), __e, __flags); }
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167 template<typename _Ch_traits, typename _Ch_alloc,
02168 typename _Allocator, typename _Ch_type,
02169 typename _Rx_traits>
02170 inline bool
02171 regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
02172 match_results<typename basic_string<_Ch_type,
02173 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
02174 const basic_regex<_Ch_type, _Rx_traits>& __e,
02175 regex_constants::match_flag_type __f
02176 = regex_constants::match_default)
02177 { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194 template<typename _Out_iter, typename _Bi_iter,
02195 typename _Rx_traits, typename _Ch_type>
02196 inline _Out_iter
02197 regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
02198 const basic_regex<_Ch_type, _Rx_traits>& __e,
02199 const basic_string<_Ch_type>& __fmt,
02200 regex_constants::match_flag_type __flags
02201 = regex_constants::match_default)
02202 { return __out; }
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215 template<typename _Rx_traits, typename _Ch_type>
02216 inline basic_string<_Ch_type>
02217 regex_replace(const basic_string<_Ch_type>& __s,
02218 const basic_regex<_Ch_type, _Rx_traits>& __e,
02219 const basic_string<_Ch_type>& __fmt,
02220 regex_constants::match_flag_type __flags
02221 = regex_constants::match_default)
02222 {
02223 std::string __result;
02224 regex_replace(std::back_inserter(__result),
02225 __s.begin(), __s.end(), __e, __fmt, __flags);
02226 return __result;
02227 }
02228
02229
02230
02231
02232
02233
02234
02235
02236 template<typename _Bi_iter,
02237 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
02238 typename _Rx_traits = regex_traits<_Ch_type> >
02239 class regex_iterator
02240 {
02241 public:
02242 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
02243 typedef match_results<_Bi_iter> value_type;
02244 typedef std::ptrdiff_t difference_type;
02245 typedef const value_type* pointer;
02246 typedef const value_type& reference;
02247 typedef std::forward_iterator_tag iterator_category;
02248
02249 public:
02250
02251
02252
02253
02254
02255
02256 regex_iterator();
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267 regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
02268 regex_constants::match_flag_type __m
02269 = regex_constants::match_default);
02270
02271
02272
02273
02274
02275
02276 regex_iterator(const regex_iterator& __rhs);
02277
02278
02279
02280
02281
02282 regex_iterator&
02283 operator=(const regex_iterator& __rhs);
02284
02285
02286
02287
02288
02289 bool
02290 operator==(const regex_iterator& __rhs);
02291
02292
02293
02294
02295
02296 bool
02297 operator!=(const regex_iterator& __rhs);
02298
02299
02300
02301
02302
02303 const value_type&
02304 operator*();
02305
02306
02307
02308
02309
02310 const value_type*
02311 operator->();
02312
02313
02314
02315
02316
02317 regex_iterator&
02318 operator++();
02319
02320
02321
02322
02323
02324 regex_iterator
02325 operator++(int);
02326
02327 private:
02328
02329 _Bi_iter begin;
02330 _Bi_iter end;
02331 const regex_type* pregex;
02332 regex_constants::match_flag_type flags;
02333 match_results<_Bi_iter> match;
02334 };
02335
02336 typedef regex_iterator<const char*> cregex_iterator;
02337 typedef regex_iterator<string::const_iterator> sregex_iterator;
02338 #ifdef _GLIBCXX_USE_WCHAR_T
02339 typedef regex_iterator<const wchar_t*> wcregex_iterator;
02340 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
02341 #endif
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351 template<typename _Bi_iter,
02352 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
02353 typename _Rx_traits = regex_traits<_Ch_type> >
02354 class regex_token_iterator
02355 {
02356 public:
02357 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
02358 typedef sub_match<_Bi_iter> value_type;
02359 typedef std::ptrdiff_t difference_type;
02360 typedef const value_type* pointer;
02361 typedef const value_type& reference;
02362 typedef std::forward_iterator_tag iterator_category;
02363
02364 public:
02365
02366
02367
02368
02369
02370
02371
02372
02373 regex_token_iterator();
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395 regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
02396 int __submatch = 0,
02397 regex_constants::match_flag_type __m
02398 = regex_constants::match_default);
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
02413 const regex_type& __re,
02414 const std::vector<int>& __submatches,
02415 regex_constants::match_flag_type __m
02416 = regex_constants::match_default);
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430 template<std::size_t _Nm>
02431 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
02432 const regex_type& __re,
02433 const int (&__submatches)[_Nm],
02434 regex_constants::match_flag_type __m
02435 = regex_constants::match_default);
02436
02437
02438
02439
02440
02441
02442 regex_token_iterator(const regex_token_iterator& __rhs);
02443
02444
02445
02446
02447
02448
02449 regex_token_iterator&
02450 operator=(const regex_token_iterator& __rhs);
02451
02452
02453
02454
02455
02456 bool
02457 operator==(const regex_token_iterator& __rhs);
02458
02459
02460
02461
02462
02463 bool
02464 operator!=(const regex_token_iterator& __rhs);
02465
02466
02467
02468
02469
02470 const value_type&
02471 operator*();
02472
02473
02474
02475
02476
02477 const value_type*
02478 operator->();
02479
02480
02481
02482
02483
02484 regex_token_iterator&
02485 operator++();
02486
02487
02488
02489
02490
02491 regex_token_iterator
02492 operator++(int);
02493
02494 private:
02495 typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
02496
02497 position_iterator __position;
02498 const value_type* __result;
02499 value_type __suffix;
02500 std::size_t __n;
02501 std::vector<int> __subs;
02502 };
02503
02504
02505 typedef regex_token_iterator<const char*> cregex_token_iterator;
02506
02507 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
02508 #ifdef _GLIBCXX_USE_WCHAR_T
02509
02510 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
02511
02512 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
02513 #endif
02514
02515
02516 _GLIBCXX_END_NAMESPACE_VERSION
02517 }
02518