2
//===--------------------------- regex ------------------------------------===//
4
// The LLVM Compiler Infrastructure
6
// This file is dual licensed under the MIT and the University of Illinois Open
7
// Source Licenses. See LICENSE.TXT for details.
9
//===----------------------------------------------------------------------===//
17
#include <initializer_list>
22
namespace regex_constants
25
emum syntax_option_type
29
optimize = unspecified,
30
collate = unspecified,
31
ECMAScript = unspecified,
33
extended = unspecified,
39
constexpr syntax_option_type operator~(syntax_option_type f);
40
constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);
41
constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);
46
match_not_bol = unspecified,
47
match_not_eol = unspecified,
48
match_not_bow = unspecified,
49
match_not_eow = unspecified,
50
match_any = unspecified,
51
match_not_null = unspecified,
52
match_continuous = unspecified,
53
match_prev_avail = unspecified,
55
format_sed = unspecified,
56
format_no_copy = unspecified,
57
format_first_only = unspecified
60
constexpr match_flag_type operator~(match_flag_type f);
61
constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);
62
constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);
66
error_collate = unspecified,
67
error_ctype = unspecified,
68
error_escape = unspecified,
69
error_backref = unspecified,
70
error_brack = unspecified,
71
error_paren = unspecified,
72
error_brace = unspecified,
73
error_badbrace = unspecified,
74
error_range = unspecified,
75
error_space = unspecified,
76
error_badrepeat = unspecified,
77
error_complexity = unspecified,
78
error_stack = unspecified
84
: public runtime_error
87
explicit regex_error(regex_constants::error_type ecode);
88
regex_constants::error_type code() const;
91
template <class charT>
95
typedef charT char_type;
96
typedef basic_string<char_type> string_type;
97
typedef locale locale_type;
98
typedef /bitmask_type/ char_class_type;
102
static size_t length(const char_type* p);
103
charT translate(charT c) const;
104
charT translate_nocase(charT c) const;
105
template <class ForwardIterator>
107
transform(ForwardIterator first, ForwardIterator last) const;
108
template <class ForwardIterator>
110
transform_primary( ForwardIterator first, ForwardIterator last) const;
111
template <class ForwardIterator>
113
lookup_collatename(ForwardIterator first, ForwardIterator last) const;
114
template <class ForwardIterator>
116
lookup_classname(ForwardIterator first, ForwardIterator last,
117
bool icase = false) const;
118
bool isctype(charT c, char_class_type f) const;
119
int value(charT ch, int radix) const;
120
locale_type imbue(locale_type l);
121
locale_type getloc()const;
124
template <class charT, class traits = regex_traits<charT>>
129
typedef charT value_type;
130
typedef regex_constants::syntax_option_type flag_type;
131
typedef typename traits::locale_type locale_type;
134
static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
135
static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
136
static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
137
static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
138
static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
139
static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
140
static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
141
static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
142
static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
143
static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
145
// construct/copy/destroy:
147
explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
148
basic_regex(const charT* p, size_t len, flag_type f);
149
basic_regex(const basic_regex&);
150
basic_regex(basic_regex&&) noexcept;
151
template <class ST, class SA>
152
explicit basic_regex(const basic_string<charT, ST, SA>& p,
153
flag_type f = regex_constants::ECMAScript);
154
template <class ForwardIterator>
155
basic_regex(ForwardIterator first, ForwardIterator last,
156
flag_type f = regex_constants::ECMAScript);
157
basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
161
basic_regex& operator=(const basic_regex&);
162
basic_regex& operator=(basic_regex&&) noexcept;
163
basic_regex& operator=(const charT* ptr);
164
basic_regex& operator=(initializer_list<charT> il);
165
template <class ST, class SA>
166
basic_regex& operator=(const basic_string<charT, ST, SA>& p);
169
basic_regex& assign(const basic_regex& that);
170
basic_regex& assign(basic_regex&& that) noexcept;
171
basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
172
basic_regex& assign(const charT* p, size_t len, flag_type f);
173
template <class string_traits, class A>
174
basic_regex& assign(const basic_string<charT, string_traits, A>& s,
175
flag_type f = regex_constants::ECMAScript);
176
template <class InputIterator>
177
basic_regex& assign(InputIterator first, InputIterator last,
178
flag_type f = regex_constants::ECMAScript);
179
basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
182
unsigned mark_count() const;
183
flag_type flags() const;
186
locale_type imbue(locale_type loc);
187
locale_type getloc() const;
190
void swap(basic_regex&);
193
typedef basic_regex<char> regex;
194
typedef basic_regex<wchar_t> wregex;
196
template <class charT, class traits>
197
void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
199
template <class BidirectionalIterator>
201
: public pair<BidirectionalIterator, BidirectionalIterator>
204
typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
205
typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
206
typedef BidirectionalIterator iterator;
207
typedef basic_string<value_type> string_type;
211
constexpr sub_match();
213
difference_type length() const;
214
operator string_type() const;
215
string_type str() const;
217
int compare(const sub_match& s) const;
218
int compare(const string_type& s) const;
219
int compare(const value_type* s) const;
222
typedef sub_match<const char*> csub_match;
223
typedef sub_match<const wchar_t*> wcsub_match;
224
typedef sub_match<string::const_iterator> ssub_match;
225
typedef sub_match<wstring::const_iterator> wssub_match;
227
template <class BiIter>
229
operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
231
template <class BiIter>
233
operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
235
template <class BiIter>
237
operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
239
template <class BiIter>
241
operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
243
template <class BiIter>
245
operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
247
template <class BiIter>
249
operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
251
template <class BiIter, class ST, class SA>
253
operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
254
const sub_match<BiIter>& rhs);
256
template <class BiIter, class ST, class SA>
258
operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
259
const sub_match<BiIter>& rhs);
261
template <class BiIter, class ST, class SA>
263
operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
264
const sub_match<BiIter>& rhs);
266
template <class BiIter, class ST, class SA>
268
operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
269
const sub_match<BiIter>& rhs);
271
template <class BiIter, class ST, class SA>
272
bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
273
const sub_match<BiIter>& rhs);
275
template <class BiIter, class ST, class SA>
277
operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
278
const sub_match<BiIter>& rhs);
280
template <class BiIter, class ST, class SA>
282
operator==(const sub_match<BiIter>& lhs,
283
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
285
template <class BiIter, class ST, class SA>
287
operator!=(const sub_match<BiIter>& lhs,
288
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
290
template <class BiIter, class ST, class SA>
292
operator<(const sub_match<BiIter>& lhs,
293
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
295
template <class BiIter, class ST, class SA>
296
bool operator>(const sub_match<BiIter>& lhs,
297
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
299
template <class BiIter, class ST, class SA>
301
operator>=(const sub_match<BiIter>& lhs,
302
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
304
template <class BiIter, class ST, class SA>
306
operator<=(const sub_match<BiIter>& lhs,
307
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
309
template <class BiIter>
311
operator==(typename iterator_traits<BiIter>::value_type const* lhs,
312
const sub_match<BiIter>& rhs);
314
template <class BiIter>
316
operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
317
const sub_match<BiIter>& rhs);
319
template <class BiIter>
321
operator<(typename iterator_traits<BiIter>::value_type const* lhs,
322
const sub_match<BiIter>& rhs);
324
template <class BiIter>
326
operator>(typename iterator_traits<BiIter>::value_type const* lhs,
327
const sub_match<BiIter>& rhs);
329
template <class BiIter>
331
operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
332
const sub_match<BiIter>& rhs);
334
template <class BiIter>
336
operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
337
const sub_match<BiIter>& rhs);
339
template <class BiIter>
341
operator==(const sub_match<BiIter>& lhs,
342
typename iterator_traits<BiIter>::value_type const* rhs);
344
template <class BiIter>
346
operator!=(const sub_match<BiIter>& lhs,
347
typename iterator_traits<BiIter>::value_type const* rhs);
349
template <class BiIter>
351
operator<(const sub_match<BiIter>& lhs,
352
typename iterator_traits<BiIter>::value_type const* rhs);
354
template <class BiIter>
356
operator>(const sub_match<BiIter>& lhs,
357
typename iterator_traits<BiIter>::value_type const* rhs);
359
template <class BiIter>
361
operator>=(const sub_match<BiIter>& lhs,
362
typename iterator_traits<BiIter>::value_type const* rhs);
364
template <class BiIter>
366
operator<=(const sub_match<BiIter>& lhs,
367
typename iterator_traits<BiIter>::value_type const* rhs);
369
template <class BiIter>
371
operator==(typename iterator_traits<BiIter>::value_type const& lhs,
372
const sub_match<BiIter>& rhs);
374
template <class BiIter>
376
operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
377
const sub_match<BiIter>& rhs);
379
template <class BiIter>
381
operator<(typename iterator_traits<BiIter>::value_type const& lhs,
382
const sub_match<BiIter>& rhs);
384
template <class BiIter>
386
operator>(typename iterator_traits<BiIter>::value_type const& lhs,
387
const sub_match<BiIter>& rhs);
389
template <class BiIter>
391
operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
392
const sub_match<BiIter>& rhs);
394
template <class BiIter>
396
operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
397
const sub_match<BiIter>& rhs);
399
template <class BiIter>
401
operator==(const sub_match<BiIter>& lhs,
402
typename iterator_traits<BiIter>::value_type const& rhs);
404
template <class BiIter>
406
operator!=(const sub_match<BiIter>& lhs,
407
typename iterator_traits<BiIter>::value_type const& rhs);
409
template <class BiIter>
411
operator<(const sub_match<BiIter>& lhs,
412
typename iterator_traits<BiIter>::value_type const& rhs);
414
template <class BiIter>
416
operator>(const sub_match<BiIter>& lhs,
417
typename iterator_traits<BiIter>::value_type const& rhs);
419
template <class BiIter>
421
operator>=(const sub_match<BiIter>& lhs,
422
typename iterator_traits<BiIter>::value_type const& rhs);
424
template <class BiIter>
426
operator<=(const sub_match<BiIter>& lhs,
427
typename iterator_traits<BiIter>::value_type const& rhs);
429
template <class charT, class ST, class BiIter>
430
basic_ostream<charT, ST>&
431
operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
433
template <class BidirectionalIterator,
434
class Allocator = allocator<sub_match<BidirectionalIterator>>>
438
typedef sub_match<BidirectionalIterator> value_type;
439
typedef const value_type& const_reference;
440
typedef const_reference reference;
441
typedef /implementation-defined/ const_iterator;
442
typedef const_iterator iterator;
443
typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
444
typedef typename allocator_traits<Allocator>::size_type size_type;
445
typedef Allocator allocator_type;
446
typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
447
typedef basic_string<char_type> string_type;
449
// construct/copy/destroy:
450
explicit match_results(const Allocator& a = Allocator());
451
match_results(const match_results& m);
452
match_results(match_results&& m) noexcept;
453
match_results& operator=(const match_results& m);
454
match_results& operator=(match_results&& m);
460
size_type size() const;
461
size_type max_size() const;
465
difference_type length(size_type sub = 0) const;
466
difference_type position(size_type sub = 0) const;
467
string_type str(size_type sub = 0) const;
468
const_reference operator[](size_type n) const;
470
const_reference prefix() const;
471
const_reference suffix() const;
473
const_iterator begin() const;
474
const_iterator end() const;
475
const_iterator cbegin() const;
476
const_iterator cend() const;
479
template <class OutputIter>
481
format(OutputIter out, const char_type* fmt_first,
482
const char_type* fmt_last,
483
regex_constants::match_flag_type flags = regex_constants::format_default) const;
484
template <class OutputIter, class ST, class SA>
486
format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
487
regex_constants::match_flag_type flags = regex_constants::format_default) const;
488
template <class ST, class SA>
489
basic_string<char_type, ST, SA>
490
format(const basic_string<char_type, ST, SA>& fmt,
491
regex_constants::match_flag_type flags = regex_constants::format_default) const;
493
format(const char_type* fmt,
494
regex_constants::match_flag_type flags = regex_constants::format_default) const;
497
allocator_type get_allocator() const;
500
void swap(match_results& that);
503
typedef match_results<const char*> cmatch;
504
typedef match_results<const wchar_t*> wcmatch;
505
typedef match_results<string::const_iterator> smatch;
506
typedef match_results<wstring::const_iterator> wsmatch;
508
template <class BidirectionalIterator, class Allocator>
510
operator==(const match_results<BidirectionalIterator, Allocator>& m1,
511
const match_results<BidirectionalIterator, Allocator>& m2);
513
template <class BidirectionalIterator, class Allocator>
515
operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
516
const match_results<BidirectionalIterator, Allocator>& m2);
518
template <class BidirectionalIterator, class Allocator>
520
swap(match_results<BidirectionalIterator, Allocator>& m1,
521
match_results<BidirectionalIterator, Allocator>& m2);
523
template <class BidirectionalIterator, class Allocator, class charT, class traits>
525
regex_match(BidirectionalIterator first, BidirectionalIterator last,
526
match_results<BidirectionalIterator, Allocator>& m,
527
const basic_regex<charT, traits>& e,
528
regex_constants::match_flag_type flags = regex_constants::match_default);
530
template <class BidirectionalIterator, class charT, class traits>
532
regex_match(BidirectionalIterator first, BidirectionalIterator last,
533
const basic_regex<charT, traits>& e,
534
regex_constants::match_flag_type flags = regex_constants::match_default);
536
template <class charT, class Allocator, class traits>
538
regex_match(const charT* str, match_results<const charT*, Allocator>& m,
539
const basic_regex<charT, traits>& e,
540
regex_constants::match_flag_type flags = regex_constants::match_default);
542
template <class ST, class SA, class Allocator, class charT, class traits>
544
regex_match(const basic_string<charT, ST, SA>& s,
545
match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
546
const basic_regex<charT, traits>& e,
547
regex_constants::match_flag_type flags = regex_constants::match_default);
549
template <class charT, class traits>
551
regex_match(const charT* str, const basic_regex<charT, traits>& e,
552
regex_constants::match_flag_type flags = regex_constants::match_default);
554
template <class ST, class SA, class charT, class traits>
556
regex_match(const basic_string<charT, ST, SA>& s,
557
const basic_regex<charT, traits>& e,
558
regex_constants::match_flag_type flags = regex_constants::match_default);
560
template <class BidirectionalIterator, class Allocator, class charT, class traits>
562
regex_search(BidirectionalIterator first, BidirectionalIterator last,
563
match_results<BidirectionalIterator, Allocator>& m,
564
const basic_regex<charT, traits>& e,
565
regex_constants::match_flag_type flags = regex_constants::match_default);
567
template <class BidirectionalIterator, class charT, class traits>
569
regex_search(BidirectionalIterator first, BidirectionalIterator last,
570
const basic_regex<charT, traits>& e,
571
regex_constants::match_flag_type flags = regex_constants::match_default);
573
template <class charT, class Allocator, class traits>
575
regex_search(const charT* str, match_results<const charT*, Allocator>& m,
576
const basic_regex<charT, traits>& e,
577
regex_constants::match_flag_type flags = regex_constants::match_default);
579
template <class charT, class traits>
581
regex_search(const charT* str, const basic_regex<charT, traits>& e,
582
regex_constants::match_flag_type flags = regex_constants::match_default);
584
template <class ST, class SA, class charT, class traits>
586
regex_search(const basic_string<charT, ST, SA>& s,
587
const basic_regex<charT, traits>& e,
588
regex_constants::match_flag_type flags = regex_constants::match_default);
590
template <class ST, class SA, class Allocator, class charT, class traits>
592
regex_search(const basic_string<charT, ST, SA>& s,
593
match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
594
const basic_regex<charT, traits>& e,
595
regex_constants::match_flag_type flags = regex_constants::match_default);
597
template <class OutputIterator, class BidirectionalIterator,
598
class traits, class charT, class ST, class SA>
600
regex_replace(OutputIterator out,
601
BidirectionalIterator first, BidirectionalIterator last,
602
const basic_regex<charT, traits>& e,
603
const basic_string<charT, ST, SA>& fmt,
604
regex_constants::match_flag_type flags = regex_constants::match_default);
606
template <class OutputIterator, class BidirectionalIterator,
607
class traits, class charT>
609
regex_replace(OutputIterator out,
610
BidirectionalIterator first, BidirectionalIterator last,
611
const basic_regex<charT, traits>& e, const charT* fmt,
612
regex_constants::match_flag_type flags = regex_constants::match_default);
614
template <class traits, class charT, class ST, class SA, class FST, class FSA>>
615
basic_string<charT, ST, SA>
616
regex_replace(const basic_string<charT, ST, SA>& s,
617
const basic_regex<charT, traits>& e,
618
const basic_string<charT, FST, FSA>& fmt,
619
regex_constants::match_flag_type flags = regex_constants::match_default);
621
template <class traits, class charT, class ST, class SA>
622
basic_string<charT, ST, SA>
623
regex_replace(const basic_string<charT, ST, SA>& s,
624
const basic_regex<charT, traits>& e, const charT* fmt,
625
regex_constants::match_flag_type flags = regex_constants::match_default);
627
template <class traits, class charT, class ST, class SA>
629
regex_replace(const charT* s,
630
const basic_regex<charT, traits>& e,
631
const basic_string<charT, ST, SA>& fmt,
632
regex_constants::match_flag_type flags = regex_constants::match_default);
634
template <class traits, class charT>
636
regex_replace(const charT* s,
637
const basic_regex<charT, traits>& e,
639
regex_constants::match_flag_type flags = regex_constants::match_default);
641
template <class BidirectionalIterator,
642
class charT = typename iterator_traits< BidirectionalIterator>::value_type,
643
class traits = regex_traits<charT>>
647
typedef basic_regex<charT, traits> regex_type;
648
typedef match_results<BidirectionalIterator> value_type;
649
typedef ptrdiff_t difference_type;
650
typedef const value_type* pointer;
651
typedef const value_type& reference;
652
typedef forward_iterator_tag iterator_category;
655
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
656
const regex_type& re,
657
regex_constants::match_flag_type m = regex_constants::match_default);
658
regex_iterator(const regex_iterator&);
659
regex_iterator& operator=(const regex_iterator&);
661
bool operator==(const regex_iterator&) const;
662
bool operator!=(const regex_iterator&) const;
664
const value_type& operator*() const;
665
const value_type* operator->() const;
667
regex_iterator& operator++();
668
regex_iterator operator++(int);
671
typedef regex_iterator<const char*> cregex_iterator;
672
typedef regex_iterator<const wchar_t*> wcregex_iterator;
673
typedef regex_iterator<string::const_iterator> sregex_iterator;
674
typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
676
template <class BidirectionalIterator,
677
class charT = typename iterator_traits< BidirectionalIterator>::value_type,
678
class traits = regex_traits<charT>>
679
class regex_token_iterator
682
typedef basic_regex<charT, traits> regex_type;
683
typedef sub_match<BidirectionalIterator> value_type;
684
typedef ptrdiff_t difference_type;
685
typedef const value_type* pointer;
686
typedef const value_type& reference;
687
typedef forward_iterator_tag iterator_category;
689
regex_token_iterator();
690
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
691
const regex_type& re, int submatch = 0,
692
regex_constants::match_flag_type m = regex_constants::match_default);
693
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
694
const regex_type& re, const vector<int>& submatches,
695
regex_constants::match_flag_type m = regex_constants::match_default);
696
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
697
const regex_type& re, initializer_list<int> submatches,
698
regex_constants::match_flag_type m = regex_constants::match_default);
700
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
701
const regex_type& re, const int (&submatches)[N],
702
regex_constants::match_flag_type m = regex_constants::match_default);
703
regex_token_iterator(const regex_token_iterator&);
704
regex_token_iterator& operator=(const regex_token_iterator&);
706
bool operator==(const regex_token_iterator&) const;
707
bool operator!=(const regex_token_iterator&) const;
709
const value_type& operator*() const;
710
const value_type* operator->() const;
712
regex_token_iterator& operator++();
713
regex_token_iterator operator++(int);
716
typedef regex_token_iterator<const char*> cregex_token_iterator;
717
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
718
typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
719
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
727
#include <initializer_list>
735
#include <__undef_min_max>
737
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
738
#pragma GCC system_header
741
_LIBCPP_BEGIN_NAMESPACE_STD
743
namespace regex_constants
746
// syntax_option_type
748
enum syntax_option_type
762
inline _LIBCPP_INLINE_VISIBILITY
765
operator~(syntax_option_type __x)
767
return syntax_option_type(~int(__x) & 0x1FF);
770
inline _LIBCPP_INLINE_VISIBILITY
773
operator&(syntax_option_type __x, syntax_option_type __y)
775
return syntax_option_type(int(__x) & int(__y));
778
inline _LIBCPP_INLINE_VISIBILITY
781
operator|(syntax_option_type __x, syntax_option_type __y)
783
return syntax_option_type(int(__x) | int(__y));
786
inline _LIBCPP_INLINE_VISIBILITY
789
operator^(syntax_option_type __x, syntax_option_type __y)
791
return syntax_option_type(int(__x) ^ int(__y));
794
inline _LIBCPP_INLINE_VISIBILITY
796
operator&=(syntax_option_type& __x, syntax_option_type __y)
802
inline _LIBCPP_INLINE_VISIBILITY
804
operator|=(syntax_option_type& __x, syntax_option_type __y)
810
inline _LIBCPP_INLINE_VISIBILITY
812
operator^=(syntax_option_type& __x, syntax_option_type __y)
823
match_not_bol = 1 << 0,
824
match_not_eol = 1 << 1,
825
match_not_bow = 1 << 2,
826
match_not_eow = 1 << 3,
828
match_not_null = 1 << 5,
829
match_continuous = 1 << 6,
830
match_prev_avail = 1 << 7,
833
format_no_copy = 1 << 9,
834
format_first_only = 1 << 10,
835
__no_update_pos = 1 << 11
838
inline _LIBCPP_INLINE_VISIBILITY
841
operator~(match_flag_type __x)
843
return match_flag_type(~int(__x) & 0x0FFF);
846
inline _LIBCPP_INLINE_VISIBILITY
849
operator&(match_flag_type __x, match_flag_type __y)
851
return match_flag_type(int(__x) & int(__y));
854
inline _LIBCPP_INLINE_VISIBILITY
857
operator|(match_flag_type __x, match_flag_type __y)
859
return match_flag_type(int(__x) | int(__y));
862
inline _LIBCPP_INLINE_VISIBILITY
865
operator^(match_flag_type __x, match_flag_type __y)
867
return match_flag_type(int(__x) ^ int(__y));
870
inline _LIBCPP_INLINE_VISIBILITY
872
operator&=(match_flag_type& __x, match_flag_type __y)
878
inline _LIBCPP_INLINE_VISIBILITY
880
operator|=(match_flag_type& __x, match_flag_type __y)
886
inline _LIBCPP_INLINE_VISIBILITY
888
operator^=(match_flag_type& __x, match_flag_type __y)
916
class _LIBCPP_EXCEPTION_ABI regex_error
917
: public runtime_error
919
regex_constants::error_type __code_;
921
explicit regex_error(regex_constants::error_type __ecode);
922
virtual ~regex_error() throw();
923
_LIBCPP_INLINE_VISIBILITY
924
regex_constants::error_type code() const {return __code_;}
927
template <class _CharT>
928
struct _LIBCPP_TYPE_VIS regex_traits
931
typedef _CharT char_type;
932
typedef basic_string<char_type> string_type;
933
typedef locale locale_type;
934
typedef ctype_base::mask char_class_type;
936
static const char_class_type __regex_word = 0x80;
939
const ctype<char_type>* __ct_;
940
const collate<char_type>* __col_;
945
_LIBCPP_INLINE_VISIBILITY
946
static size_t length(const char_type* __p)
947
{return char_traits<char_type>::length(__p);}
948
_LIBCPP_INLINE_VISIBILITY
949
char_type translate(char_type __c) const {return __c;}
950
char_type translate_nocase(char_type __c) const;
951
template <class _ForwardIterator>
953
transform(_ForwardIterator __f, _ForwardIterator __l) const;
954
template <class _ForwardIterator>
955
_LIBCPP_INLINE_VISIBILITY
957
transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
958
{return __transform_primary(__f, __l, char_type());}
959
template <class _ForwardIterator>
960
_LIBCPP_INLINE_VISIBILITY
962
lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
963
{return __lookup_collatename(__f, __l, char_type());}
964
template <class _ForwardIterator>
965
_LIBCPP_INLINE_VISIBILITY
967
lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
968
bool __icase = false) const
969
{return __lookup_classname(__f, __l, __icase, char_type());}
970
bool isctype(char_type __c, char_class_type __m) const;
971
_LIBCPP_INLINE_VISIBILITY
972
int value(char_type __ch, int __radix) const
973
{return __value(__ch, __radix);}
974
locale_type imbue(locale_type __l);
975
_LIBCPP_INLINE_VISIBILITY
976
locale_type getloc()const {return __loc_;}
981
template <class _ForwardIterator>
983
__transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
984
template <class _ForwardIterator>
986
__transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
988
template <class _ForwardIterator>
990
__lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
991
template <class _ForwardIterator>
993
__lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
995
template <class _ForwardIterator>
997
__lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
998
bool __icase, char) const;
999
template <class _ForwardIterator>
1001
__lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1002
bool __icase, wchar_t) const;
1004
static int __value(unsigned char __ch, int __radix);
1005
_LIBCPP_INLINE_VISIBILITY
1006
int __value(char __ch, int __radix) const
1007
{return __value(static_cast<unsigned char>(__ch), __radix);}
1008
int __value(wchar_t __ch, int __radix) const;
1011
template <class _CharT>
1012
const typename regex_traits<_CharT>::char_class_type
1013
regex_traits<_CharT>::__regex_word;
1015
template <class _CharT>
1016
regex_traits<_CharT>::regex_traits()
1021
template <class _CharT>
1022
typename regex_traits<_CharT>::char_type
1023
regex_traits<_CharT>::translate_nocase(char_type __c) const
1025
return __ct_->tolower(__c);
1028
template <class _CharT>
1029
template <class _ForwardIterator>
1030
typename regex_traits<_CharT>::string_type
1031
regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
1033
string_type __s(__f, __l);
1034
return __col_->transform(__s.data(), __s.data() + __s.size());
1037
template <class _CharT>
1039
regex_traits<_CharT>::__init()
1041
__ct_ = &use_facet<ctype<char_type> >(__loc_);
1042
__col_ = &use_facet<collate<char_type> >(__loc_);
1045
template <class _CharT>
1046
typename regex_traits<_CharT>::locale_type
1047
regex_traits<_CharT>::imbue(locale_type __l)
1049
locale __r = __loc_;
1055
// transform_primary is very FreeBSD-specific
1057
template <class _CharT>
1058
template <class _ForwardIterator>
1059
typename regex_traits<_CharT>::string_type
1060
regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1061
_ForwardIterator __l, char) const
1063
const string_type __s(__f, __l);
1064
string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1079
template <class _CharT>
1080
template <class _ForwardIterator>
1081
typename regex_traits<_CharT>::string_type
1082
regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1083
_ForwardIterator __l, wchar_t) const
1085
const string_type __s(__f, __l);
1086
string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1101
// lookup_collatename is very FreeBSD-specific
1103
string __get_collation_name(const char* __s);
1105
template <class _CharT>
1106
template <class _ForwardIterator>
1107
typename regex_traits<_CharT>::string_type
1108
regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1109
_ForwardIterator __l, char) const
1111
string_type __s(__f, __l);
1115
__r = __get_collation_name(__s.c_str());
1116
if (__r.empty() && __s.size() <= 2)
1118
__r = __col_->transform(__s.data(), __s.data() + __s.size());
1119
if (__r.size() == 1 || __r.size() == 12)
1128
template <class _CharT>
1129
template <class _ForwardIterator>
1130
typename regex_traits<_CharT>::string_type
1131
regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1132
_ForwardIterator __l, wchar_t) const
1134
string_type __s(__f, __l);
1136
__n.reserve(__s.size());
1137
for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1140
if (static_cast<unsigned>(*__i) >= 127)
1141
return string_type();
1142
__n.push_back(char(*__i));
1147
__n = __get_collation_name(__n.c_str());
1149
__r.assign(__n.begin(), __n.end());
1150
else if (__s.size() <= 2)
1152
__r = __col_->transform(__s.data(), __s.data() + __s.size());
1153
if (__r.size() == 1 || __r.size() == 3)
1164
ctype_base::mask __get_classname(const char* __s, bool __icase);
1166
template <class _CharT>
1167
template <class _ForwardIterator>
1168
typename regex_traits<_CharT>::char_class_type
1169
regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1170
_ForwardIterator __l,
1171
bool __icase, char) const
1173
string_type __s(__f, __l);
1174
__ct_->tolower(&__s[0], &__s[0] + __s.size());
1175
return __get_classname(__s.c_str(), __icase);
1178
template <class _CharT>
1179
template <class _ForwardIterator>
1180
typename regex_traits<_CharT>::char_class_type
1181
regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1182
_ForwardIterator __l,
1183
bool __icase, wchar_t) const
1185
string_type __s(__f, __l);
1186
__ct_->tolower(&__s[0], &__s[0] + __s.size());
1188
__n.reserve(__s.size());
1189
for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1192
if (static_cast<unsigned>(*__i) >= 127)
1193
return char_class_type();
1194
__n.push_back(char(*__i));
1196
return __get_classname(__n.c_str(), __icase);
1199
template <class _CharT>
1201
regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1203
if (__ct_->is(__m, __c))
1205
return (__c == '_' && (__m & __regex_word));
1208
template <class _CharT>
1210
regex_traits<_CharT>::__value(unsigned char __ch, int __radix)
1212
if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7'
1216
if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9'
1220
__ch |= 0x20; // tolower
1221
if ('a' <= __ch && __ch <= 'f')
1222
return __ch - ('a' - 10);
1228
template <class _CharT>
1229
inline _LIBCPP_INLINE_VISIBILITY
1231
regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const
1233
return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1236
template <class _CharT> class __node;
1238
template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS sub_match;
1240
template <class _BidirectionalIterator,
1241
class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1242
class _LIBCPP_TYPE_VIS match_results;
1244
template <class _CharT>
1249
__end_state = -1000,
1250
__consume_input, // -999
1251
__begin_marked_expr, // -998
1252
__end_marked_expr, // -997
1253
__pop_state, // -996
1254
__accept_and_consume, // -995
1255
__accept_but_not_consume, // -994
1262
const _CharT* __first_;
1263
const _CharT* __current_;
1264
const _CharT* __last_;
1265
vector<sub_match<const _CharT*> > __sub_matches_;
1266
vector<pair<size_t, const _CharT*> > __loop_data_;
1267
const __node<_CharT>* __node_;
1268
regex_constants::match_flag_type __flags_;
1271
_LIBCPP_INLINE_VISIBILITY
1273
: __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
1274
__node_(nullptr), __flags_() {}
1279
template <class _CharT>
1282
__node(const __node&);
1283
__node& operator=(const __node&);
1285
typedef _VSTD::__state<_CharT> __state;
1287
_LIBCPP_INLINE_VISIBILITY
1289
_LIBCPP_INLINE_VISIBILITY
1290
virtual ~__node() {}
1292
_LIBCPP_INLINE_VISIBILITY
1293
virtual void __exec(__state&) const {};
1294
_LIBCPP_INLINE_VISIBILITY
1295
virtual void __exec_split(bool, __state&) const {};
1300
template <class _CharT>
1302
: public __node<_CharT>
1305
typedef _VSTD::__state<_CharT> __state;
1307
_LIBCPP_INLINE_VISIBILITY
1310
virtual void __exec(__state&) const;
1313
template <class _CharT>
1315
__end_state<_CharT>::__exec(__state& __s) const
1317
__s.__do_ = __state::__end_state;
1322
template <class _CharT>
1323
class __has_one_state
1324
: public __node<_CharT>
1326
__node<_CharT>* __first_;
1329
_LIBCPP_INLINE_VISIBILITY
1330
explicit __has_one_state(__node<_CharT>* __s)
1333
_LIBCPP_INLINE_VISIBILITY
1334
__node<_CharT>* first() const {return __first_;}
1335
_LIBCPP_INLINE_VISIBILITY
1336
__node<_CharT>*& first() {return __first_;}
1341
template <class _CharT>
1342
class __owns_one_state
1343
: public __has_one_state<_CharT>
1345
typedef __has_one_state<_CharT> base;
1348
_LIBCPP_INLINE_VISIBILITY
1349
explicit __owns_one_state(__node<_CharT>* __s)
1352
virtual ~__owns_one_state();
1355
template <class _CharT>
1356
__owns_one_state<_CharT>::~__owns_one_state()
1358
delete this->first();
1363
template <class _CharT>
1365
: public __owns_one_state<_CharT>
1367
typedef __owns_one_state<_CharT> base;
1370
typedef _VSTD::__state<_CharT> __state;
1372
_LIBCPP_INLINE_VISIBILITY
1373
explicit __empty_state(__node<_CharT>* __s)
1376
virtual void __exec(__state&) const;
1379
template <class _CharT>
1381
__empty_state<_CharT>::__exec(__state& __s) const
1383
__s.__do_ = __state::__accept_but_not_consume;
1384
__s.__node_ = this->first();
1387
// __empty_non_own_state
1389
template <class _CharT>
1390
class __empty_non_own_state
1391
: public __has_one_state<_CharT>
1393
typedef __has_one_state<_CharT> base;
1396
typedef _VSTD::__state<_CharT> __state;
1398
_LIBCPP_INLINE_VISIBILITY
1399
explicit __empty_non_own_state(__node<_CharT>* __s)
1402
virtual void __exec(__state&) const;
1405
template <class _CharT>
1407
__empty_non_own_state<_CharT>::__exec(__state& __s) const
1409
__s.__do_ = __state::__accept_but_not_consume;
1410
__s.__node_ = this->first();
1413
// __repeat_one_loop
1415
template <class _CharT>
1416
class __repeat_one_loop
1417
: public __has_one_state<_CharT>
1419
typedef __has_one_state<_CharT> base;
1422
typedef _VSTD::__state<_CharT> __state;
1424
_LIBCPP_INLINE_VISIBILITY
1425
explicit __repeat_one_loop(__node<_CharT>* __s)
1428
virtual void __exec(__state&) const;
1431
template <class _CharT>
1433
__repeat_one_loop<_CharT>::__exec(__state& __s) const
1435
__s.__do_ = __state::__repeat;
1436
__s.__node_ = this->first();
1439
// __owns_two_states
1441
template <class _CharT>
1442
class __owns_two_states
1443
: public __owns_one_state<_CharT>
1445
typedef __owns_one_state<_CharT> base;
1450
_LIBCPP_INLINE_VISIBILITY
1451
explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
1452
: base(__s1), __second_(__s2) {}
1454
virtual ~__owns_two_states();
1456
_LIBCPP_INLINE_VISIBILITY
1457
base* second() const {return __second_;}
1458
_LIBCPP_INLINE_VISIBILITY
1459
base*& second() {return __second_;}
1462
template <class _CharT>
1463
__owns_two_states<_CharT>::~__owns_two_states()
1470
template <class _CharT>
1472
: public __owns_two_states<_CharT>
1474
typedef __owns_two_states<_CharT> base;
1478
unsigned __loop_id_;
1479
unsigned __mexp_begin_;
1480
unsigned __mexp_end_;
1484
typedef _VSTD::__state<_CharT> __state;
1486
_LIBCPP_INLINE_VISIBILITY
1487
explicit __loop(unsigned __loop_id,
1488
__node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
1489
unsigned __mexp_begin, unsigned __mexp_end,
1490
bool __greedy = true,
1492
size_t __max = numeric_limits<size_t>::max())
1493
: base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
1494
__mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
1495
__greedy_(__greedy) {}
1497
virtual void __exec(__state& __s) const;
1498
virtual void __exec_split(bool __second, __state& __s) const;
1501
_LIBCPP_INLINE_VISIBILITY
1502
void __init_repeat(__state& __s) const
1504
__s.__loop_data_[__loop_id_].second = __s.__current_;
1505
for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
1507
__s.__sub_matches_[__i].first = __s.__last_;
1508
__s.__sub_matches_[__i].second = __s.__last_;
1509
__s.__sub_matches_[__i].matched = false;
1514
template <class _CharT>
1516
__loop<_CharT>::__exec(__state& __s) const
1518
if (__s.__do_ == __state::__repeat)
1520
bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
1521
bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
1522
if (__do_repeat && __do_alt &&
1523
__s.__loop_data_[__loop_id_].second == __s.__current_)
1524
__do_repeat = false;
1525
if (__do_repeat && __do_alt)
1526
__s.__do_ = __state::__split;
1527
else if (__do_repeat)
1529
__s.__do_ = __state::__accept_but_not_consume;
1530
__s.__node_ = this->first();
1535
__s.__do_ = __state::__accept_but_not_consume;
1536
__s.__node_ = this->second();
1541
__s.__loop_data_[__loop_id_].first = 0;
1542
bool __do_repeat = 0 < __max_;
1543
bool __do_alt = 0 >= __min_;
1544
if (__do_repeat && __do_alt)
1545
__s.__do_ = __state::__split;
1546
else if (__do_repeat)
1548
__s.__do_ = __state::__accept_but_not_consume;
1549
__s.__node_ = this->first();
1554
__s.__do_ = __state::__accept_but_not_consume;
1555
__s.__node_ = this->second();
1560
template <class _CharT>
1562
__loop<_CharT>::__exec_split(bool __second, __state& __s) const
1564
__s.__do_ = __state::__accept_but_not_consume;
1565
if (__greedy_ != __second)
1567
__s.__node_ = this->first();
1571
__s.__node_ = this->second();
1576
template <class _CharT>
1578
: public __owns_two_states<_CharT>
1580
typedef __owns_two_states<_CharT> base;
1583
typedef _VSTD::__state<_CharT> __state;
1585
_LIBCPP_INLINE_VISIBILITY
1586
explicit __alternate(__owns_one_state<_CharT>* __s1,
1587
__owns_one_state<_CharT>* __s2)
1588
: base(__s1, __s2) {}
1590
virtual void __exec(__state& __s) const;
1591
virtual void __exec_split(bool __second, __state& __s) const;
1594
template <class _CharT>
1596
__alternate<_CharT>::__exec(__state& __s) const
1598
__s.__do_ = __state::__split;
1601
template <class _CharT>
1603
__alternate<_CharT>::__exec_split(bool __second, __state& __s) const
1605
__s.__do_ = __state::__accept_but_not_consume;
1607
__s.__node_ = this->second();
1609
__s.__node_ = this->first();
1612
// __begin_marked_subexpression
1614
template <class _CharT>
1615
class __begin_marked_subexpression
1616
: public __owns_one_state<_CharT>
1618
typedef __owns_one_state<_CharT> base;
1622
typedef _VSTD::__state<_CharT> __state;
1624
_LIBCPP_INLINE_VISIBILITY
1625
explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1626
: base(__s), __mexp_(__mexp) {}
1628
virtual void __exec(__state&) const;
1631
template <class _CharT>
1633
__begin_marked_subexpression<_CharT>::__exec(__state& __s) const
1635
__s.__do_ = __state::__accept_but_not_consume;
1636
__s.__sub_matches_[__mexp_-1].first = __s.__current_;
1637
__s.__node_ = this->first();
1640
// __end_marked_subexpression
1642
template <class _CharT>
1643
class __end_marked_subexpression
1644
: public __owns_one_state<_CharT>
1646
typedef __owns_one_state<_CharT> base;
1650
typedef _VSTD::__state<_CharT> __state;
1652
_LIBCPP_INLINE_VISIBILITY
1653
explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1654
: base(__s), __mexp_(__mexp) {}
1656
virtual void __exec(__state&) const;
1659
template <class _CharT>
1661
__end_marked_subexpression<_CharT>::__exec(__state& __s) const
1663
__s.__do_ = __state::__accept_but_not_consume;
1664
__s.__sub_matches_[__mexp_-1].second = __s.__current_;
1665
__s.__sub_matches_[__mexp_-1].matched = true;
1666
__s.__node_ = this->first();
1671
template <class _CharT>
1673
: public __owns_one_state<_CharT>
1675
typedef __owns_one_state<_CharT> base;
1679
typedef _VSTD::__state<_CharT> __state;
1681
_LIBCPP_INLINE_VISIBILITY
1682
explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
1683
: base(__s), __mexp_(__mexp) {}
1685
virtual void __exec(__state&) const;
1688
template <class _CharT>
1690
__back_ref<_CharT>::__exec(__state& __s) const
1692
sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1695
ptrdiff_t __len = __sm.second - __sm.first;
1696
if (__s.__last_ - __s.__current_ >= __len &&
1697
_VSTD::equal(__sm.first, __sm.second, __s.__current_))
1699
__s.__do_ = __state::__accept_but_not_consume;
1700
__s.__current_ += __len;
1701
__s.__node_ = this->first();
1705
__s.__do_ = __state::__reject;
1706
__s.__node_ = nullptr;
1711
__s.__do_ = __state::__reject;
1712
__s.__node_ = nullptr;
1718
template <class _CharT, class _Traits>
1719
class __back_ref_icase
1720
: public __owns_one_state<_CharT>
1722
typedef __owns_one_state<_CharT> base;
1727
typedef _VSTD::__state<_CharT> __state;
1729
_LIBCPP_INLINE_VISIBILITY
1730
explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
1731
__node<_CharT>* __s)
1732
: base(__s), __traits_(__traits), __mexp_(__mexp) {}
1734
virtual void __exec(__state&) const;
1737
template <class _CharT, class _Traits>
1739
__back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
1741
sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1744
ptrdiff_t __len = __sm.second - __sm.first;
1745
if (__s.__last_ - __s.__current_ >= __len)
1747
for (ptrdiff_t __i = 0; __i < __len; ++__i)
1749
if (__traits_.translate_nocase(__sm.first[__i]) !=
1750
__traits_.translate_nocase(__s.__current_[__i]))
1753
__s.__do_ = __state::__accept_but_not_consume;
1754
__s.__current_ += __len;
1755
__s.__node_ = this->first();
1759
__s.__do_ = __state::__reject;
1760
__s.__node_ = nullptr;
1766
__s.__do_ = __state::__reject;
1767
__s.__node_ = nullptr;
1771
// __back_ref_collate
1773
template <class _CharT, class _Traits>
1774
class __back_ref_collate
1775
: public __owns_one_state<_CharT>
1777
typedef __owns_one_state<_CharT> base;
1782
typedef _VSTD::__state<_CharT> __state;
1784
_LIBCPP_INLINE_VISIBILITY
1785
explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
1786
__node<_CharT>* __s)
1787
: base(__s), __traits_(__traits), __mexp_(__mexp) {}
1789
virtual void __exec(__state&) const;
1792
template <class _CharT, class _Traits>
1794
__back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
1796
sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1799
ptrdiff_t __len = __sm.second - __sm.first;
1800
if (__s.__last_ - __s.__current_ >= __len)
1802
for (ptrdiff_t __i = 0; __i < __len; ++__i)
1804
if (__traits_.translate(__sm.first[__i]) !=
1805
__traits_.translate(__s.__current_[__i]))
1808
__s.__do_ = __state::__accept_but_not_consume;
1809
__s.__current_ += __len;
1810
__s.__node_ = this->first();
1814
__s.__do_ = __state::__reject;
1815
__s.__node_ = nullptr;
1821
__s.__do_ = __state::__reject;
1822
__s.__node_ = nullptr;
1828
template <class _CharT, class _Traits>
1829
class __word_boundary
1830
: public __owns_one_state<_CharT>
1832
typedef __owns_one_state<_CharT> base;
1837
typedef _VSTD::__state<_CharT> __state;
1839
_LIBCPP_INLINE_VISIBILITY
1840
explicit __word_boundary(const _Traits& __traits, bool __invert,
1841
__node<_CharT>* __s)
1842
: base(__s), __traits_(__traits), __invert_(__invert) {}
1844
virtual void __exec(__state&) const;
1847
template <class _CharT, class _Traits>
1849
__word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1851
bool __is_word_b = false;
1852
if (__s.__first_ != __s.__last_)
1854
if (__s.__current_ == __s.__last_)
1856
if (!(__s.__flags_ & regex_constants::match_not_eow))
1858
_CharT __c = __s.__current_[-1];
1859
__is_word_b = __c == '_' ||
1860
__traits_.isctype(__c, ctype_base::alnum);
1863
else if (__s.__current_ == __s.__first_ &&
1864
!(__s.__flags_ & regex_constants::match_prev_avail))
1866
if (!(__s.__flags_ & regex_constants::match_not_bow))
1868
_CharT __c = *__s.__current_;
1869
__is_word_b = __c == '_' ||
1870
__traits_.isctype(__c, ctype_base::alnum);
1875
_CharT __c1 = __s.__current_[-1];
1876
_CharT __c2 = *__s.__current_;
1877
bool __is_c1_b = __c1 == '_' ||
1878
__traits_.isctype(__c1, ctype_base::alnum);
1879
bool __is_c2_b = __c2 == '_' ||
1880
__traits_.isctype(__c2, ctype_base::alnum);
1881
__is_word_b = __is_c1_b != __is_c2_b;
1884
if (__is_word_b != __invert_)
1886
__s.__do_ = __state::__accept_but_not_consume;
1887
__s.__node_ = this->first();
1891
__s.__do_ = __state::__reject;
1892
__s.__node_ = nullptr;
1898
template <class _CharT>
1900
: public __owns_one_state<_CharT>
1902
typedef __owns_one_state<_CharT> base;
1905
typedef _VSTD::__state<_CharT> __state;
1907
_LIBCPP_INLINE_VISIBILITY
1908
__l_anchor(__node<_CharT>* __s)
1911
virtual void __exec(__state&) const;
1914
template <class _CharT>
1916
__l_anchor<_CharT>::__exec(__state& __s) const
1918
if (__s.__at_first_ && __s.__current_ == __s.__first_)
1920
__s.__do_ = __state::__accept_but_not_consume;
1921
__s.__node_ = this->first();
1925
__s.__do_ = __state::__reject;
1926
__s.__node_ = nullptr;
1932
template <class _CharT>
1934
: public __owns_one_state<_CharT>
1936
typedef __owns_one_state<_CharT> base;
1939
typedef _VSTD::__state<_CharT> __state;
1941
_LIBCPP_INLINE_VISIBILITY
1942
__r_anchor(__node<_CharT>* __s)
1945
virtual void __exec(__state&) const;
1948
template <class _CharT>
1950
__r_anchor<_CharT>::__exec(__state& __s) const
1952
if (__s.__current_ == __s.__last_)
1954
__s.__do_ = __state::__accept_but_not_consume;
1955
__s.__node_ = this->first();
1959
__s.__do_ = __state::__reject;
1960
__s.__node_ = nullptr;
1966
template <class _CharT>
1968
: public __owns_one_state<_CharT>
1970
typedef __owns_one_state<_CharT> base;
1973
typedef _VSTD::__state<_CharT> __state;
1975
_LIBCPP_INLINE_VISIBILITY
1976
__match_any(__node<_CharT>* __s)
1979
virtual void __exec(__state&) const;
1982
template <class _CharT>
1984
__match_any<_CharT>::__exec(__state& __s) const
1986
if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
1988
__s.__do_ = __state::__accept_and_consume;
1990
__s.__node_ = this->first();
1994
__s.__do_ = __state::__reject;
1995
__s.__node_ = nullptr;
1999
// __match_any_but_newline
2001
template <class _CharT>
2002
class __match_any_but_newline
2003
: public __owns_one_state<_CharT>
2005
typedef __owns_one_state<_CharT> base;
2008
typedef _VSTD::__state<_CharT> __state;
2010
_LIBCPP_INLINE_VISIBILITY
2011
__match_any_but_newline(__node<_CharT>* __s)
2014
virtual void __exec(__state&) const;
2019
template <class _CharT>
2021
: public __owns_one_state<_CharT>
2023
typedef __owns_one_state<_CharT> base;
2027
__match_char(const __match_char&);
2028
__match_char& operator=(const __match_char&);
2030
typedef _VSTD::__state<_CharT> __state;
2032
_LIBCPP_INLINE_VISIBILITY
2033
__match_char(_CharT __c, __node<_CharT>* __s)
2034
: base(__s), __c_(__c) {}
2036
virtual void __exec(__state&) const;
2039
template <class _CharT>
2041
__match_char<_CharT>::__exec(__state& __s) const
2043
if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
2045
__s.__do_ = __state::__accept_and_consume;
2047
__s.__node_ = this->first();
2051
__s.__do_ = __state::__reject;
2052
__s.__node_ = nullptr;
2056
// __match_char_icase
2058
template <class _CharT, class _Traits>
2059
class __match_char_icase
2060
: public __owns_one_state<_CharT>
2062
typedef __owns_one_state<_CharT> base;
2067
__match_char_icase(const __match_char_icase&);
2068
__match_char_icase& operator=(const __match_char_icase&);
2070
typedef _VSTD::__state<_CharT> __state;
2072
_LIBCPP_INLINE_VISIBILITY
2073
__match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2074
: base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
2076
virtual void __exec(__state&) const;
2079
template <class _CharT, class _Traits>
2081
__match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
2083
if (__s.__current_ != __s.__last_ &&
2084
__traits_.translate_nocase(*__s.__current_) == __c_)
2086
__s.__do_ = __state::__accept_and_consume;
2088
__s.__node_ = this->first();
2092
__s.__do_ = __state::__reject;
2093
__s.__node_ = nullptr;
2097
// __match_char_collate
2099
template <class _CharT, class _Traits>
2100
class __match_char_collate
2101
: public __owns_one_state<_CharT>
2103
typedef __owns_one_state<_CharT> base;
2108
__match_char_collate(const __match_char_collate&);
2109
__match_char_collate& operator=(const __match_char_collate&);
2111
typedef _VSTD::__state<_CharT> __state;
2113
_LIBCPP_INLINE_VISIBILITY
2114
__match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2115
: base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
2117
virtual void __exec(__state&) const;
2120
template <class _CharT, class _Traits>
2122
__match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
2124
if (__s.__current_ != __s.__last_ &&
2125
__traits_.translate(*__s.__current_) == __c_)
2127
__s.__do_ = __state::__accept_and_consume;
2129
__s.__node_ = this->first();
2133
__s.__do_ = __state::__reject;
2134
__s.__node_ = nullptr;
2138
// __bracket_expression
2140
template <class _CharT, class _Traits>
2141
class __bracket_expression
2142
: public __owns_one_state<_CharT>
2144
typedef __owns_one_state<_CharT> base;
2145
typedef typename _Traits::string_type string_type;
2148
vector<_CharT> __chars_;
2149
vector<_CharT> __neg_chars_;
2150
vector<pair<string_type, string_type> > __ranges_;
2151
vector<pair<_CharT, _CharT> > __digraphs_;
2152
vector<string_type> __equivalences_;
2153
ctype_base::mask __mask_;
2154
ctype_base::mask __neg_mask_;
2158
bool __might_have_digraph_;
2160
__bracket_expression(const __bracket_expression&);
2161
__bracket_expression& operator=(const __bracket_expression&);
2163
typedef _VSTD::__state<_CharT> __state;
2165
_LIBCPP_INLINE_VISIBILITY
2166
__bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
2167
bool __negate, bool __icase, bool __collate)
2168
: base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
2169
__negate_(__negate), __icase_(__icase), __collate_(__collate),
2170
__might_have_digraph_(__traits_.getloc().name() != "C") {}
2172
virtual void __exec(__state&) const;
2174
_LIBCPP_INLINE_VISIBILITY
2175
bool __negated() const {return __negate_;}
2177
_LIBCPP_INLINE_VISIBILITY
2178
void __add_char(_CharT __c)
2181
__chars_.push_back(__traits_.translate_nocase(__c));
2182
else if (__collate_)
2183
__chars_.push_back(__traits_.translate(__c));
2185
__chars_.push_back(__c);
2187
_LIBCPP_INLINE_VISIBILITY
2188
void __add_neg_char(_CharT __c)
2191
__neg_chars_.push_back(__traits_.translate_nocase(__c));
2192
else if (__collate_)
2193
__neg_chars_.push_back(__traits_.translate(__c));
2195
__neg_chars_.push_back(__c);
2197
_LIBCPP_INLINE_VISIBILITY
2198
void __add_range(string_type __b, string_type __e)
2204
for (size_t __i = 0; __i < __b.size(); ++__i)
2205
__b[__i] = __traits_.translate_nocase(__b[__i]);
2206
for (size_t __i = 0; __i < __e.size(); ++__i)
2207
__e[__i] = __traits_.translate_nocase(__e[__i]);
2211
for (size_t __i = 0; __i < __b.size(); ++__i)
2212
__b[__i] = __traits_.translate(__b[__i]);
2213
for (size_t __i = 0; __i < __e.size(); ++__i)
2214
__e[__i] = __traits_.translate(__e[__i]);
2216
__ranges_.push_back(make_pair(
2217
__traits_.transform(__b.begin(), __b.end()),
2218
__traits_.transform(__e.begin(), __e.end())));
2222
#ifndef _LIBCPP_NO_EXCEPTIONS
2223
if (__b.size() != 1 || __e.size() != 1)
2224
throw regex_error(regex_constants::error_collate);
2225
#endif // _LIBCPP_NO_EXCEPTIONS
2228
__b[0] = __traits_.translate_nocase(__b[0]);
2229
__e[0] = __traits_.translate_nocase(__e[0]);
2231
__ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2234
_LIBCPP_INLINE_VISIBILITY
2235
void __add_digraph(_CharT __c1, _CharT __c2)
2238
__digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2239
__traits_.translate_nocase(__c2)));
2240
else if (__collate_)
2241
__digraphs_.push_back(make_pair(__traits_.translate(__c1),
2242
__traits_.translate(__c2)));
2244
__digraphs_.push_back(make_pair(__c1, __c2));
2246
_LIBCPP_INLINE_VISIBILITY
2247
void __add_equivalence(const string_type& __s)
2248
{__equivalences_.push_back(__s);}
2249
_LIBCPP_INLINE_VISIBILITY
2250
void __add_class(ctype_base::mask __mask)
2251
{__mask_ |= __mask;}
2252
_LIBCPP_INLINE_VISIBILITY
2253
void __add_neg_class(ctype_base::mask __mask)
2254
{__neg_mask_ |= __mask;}
2257
template <class _CharT, class _Traits>
2259
__bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2261
bool __found = false;
2262
unsigned __consumed = 0;
2263
if (__s.__current_ != __s.__last_)
2266
if (__might_have_digraph_)
2268
const _CharT* __next = _VSTD::next(__s.__current_);
2269
if (__next != __s.__last_)
2271
pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
2274
__ch2.first = __traits_.translate_nocase(__ch2.first);
2275
__ch2.second = __traits_.translate_nocase(__ch2.second);
2277
else if (__collate_)
2279
__ch2.first = __traits_.translate(__ch2.first);
2280
__ch2.second = __traits_.translate(__ch2.second);
2282
if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
2284
// __ch2 is a digraph in this locale
2286
for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
2288
if (__ch2 == __digraphs_[__i])
2294
if (__collate_ && !__ranges_.empty())
2296
string_type __s2 = __traits_.transform(&__ch2.first,
2298
for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2300
if (__ranges_[__i].first <= __s2 &&
2301
__s2 <= __ranges_[__i].second)
2308
if (!__equivalences_.empty())
2310
string_type __s2 = __traits_.transform_primary(&__ch2.first,
2312
for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2314
if (__s2 == __equivalences_[__i])
2321
if (__traits_.isctype(__ch2.first, __mask_) &&
2322
__traits_.isctype(__ch2.second, __mask_))
2327
if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
2328
!__traits_.isctype(__ch2.second, __neg_mask_))
2337
// test *__s.__current_ as not a digraph
2338
_CharT __ch = *__s.__current_;
2340
__ch = __traits_.translate_nocase(__ch);
2341
else if (__collate_)
2342
__ch = __traits_.translate(__ch);
2343
for (size_t __i = 0; __i < __chars_.size(); ++__i)
2345
if (__ch == __chars_[__i])
2351
if (!__neg_chars_.empty())
2353
for (size_t __i = 0; __i < __neg_chars_.size(); ++__i)
2355
if (__ch == __neg_chars_[__i])
2362
if (!__ranges_.empty())
2364
string_type __s2 = __collate_ ?
2365
__traits_.transform(&__ch, &__ch + 1) :
2366
string_type(1, __ch);
2367
for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2369
if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
2376
if (!__equivalences_.empty())
2378
string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
2379
for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2381
if (__s2 == __equivalences_[__i])
2388
if (__traits_.isctype(__ch, __mask_))
2393
if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_))
2400
__found = __negate_; // force reject
2402
if (__found != __negate_)
2404
__s.__do_ = __state::__accept_and_consume;
2405
__s.__current_ += __consumed;
2406
__s.__node_ = this->first();
2410
__s.__do_ = __state::__reject;
2411
__s.__node_ = nullptr;
2415
template <class _CharT, class _Traits> class __lookahead;
2417
template <class _CharT, class _Traits = regex_traits<_CharT> >
2418
class _LIBCPP_TYPE_VIS basic_regex
2422
typedef _CharT value_type;
2423
typedef regex_constants::syntax_option_type flag_type;
2424
typedef typename _Traits::locale_type locale_type;
2429
unsigned __marked_count_;
2430
unsigned __loop_count_;
2432
shared_ptr<__empty_state<_CharT> > __start_;
2433
__owns_one_state<_CharT>* __end_;
2435
typedef _VSTD::__state<_CharT> __state;
2436
typedef _VSTD::__node<_CharT> __node;
2440
static const regex_constants::syntax_option_type icase = regex_constants::icase;
2441
static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
2442
static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
2443
static const regex_constants::syntax_option_type collate = regex_constants::collate;
2444
static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
2445
static const regex_constants::syntax_option_type basic = regex_constants::basic;
2446
static const regex_constants::syntax_option_type extended = regex_constants::extended;
2447
static const regex_constants::syntax_option_type awk = regex_constants::awk;
2448
static const regex_constants::syntax_option_type grep = regex_constants::grep;
2449
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2451
// construct/copy/destroy:
2452
_LIBCPP_INLINE_VISIBILITY
2454
: __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
2457
_LIBCPP_INLINE_VISIBILITY
2458
explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2459
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2461
{__parse(__p, __p + __traits_.length(__p));}
2462
_LIBCPP_INLINE_VISIBILITY
2463
basic_regex(const value_type* __p, size_t __len, flag_type __f)
2464
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2466
{__parse(__p, __p + __len);}
2467
// basic_regex(const basic_regex&) = default;
2468
// basic_regex(basic_regex&&) = default;
2469
template <class _ST, class _SA>
2470
_LIBCPP_INLINE_VISIBILITY
2471
explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2472
flag_type __f = regex_constants::ECMAScript)
2473
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2475
{__parse(__p.begin(), __p.end());}
2476
template <class _ForwardIterator>
2477
_LIBCPP_INLINE_VISIBILITY
2478
basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2479
flag_type __f = regex_constants::ECMAScript)
2480
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2482
{__parse(__first, __last);}
2483
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2484
_LIBCPP_INLINE_VISIBILITY
2485
basic_regex(initializer_list<value_type> __il,
2486
flag_type __f = regex_constants::ECMAScript)
2487
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2489
{__parse(__il.begin(), __il.end());}
2490
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2492
// ~basic_regex() = default;
2494
// basic_regex& operator=(const basic_regex&) = default;
2495
// basic_regex& operator=(basic_regex&&) = default;
2496
_LIBCPP_INLINE_VISIBILITY
2497
basic_regex& operator=(const value_type* __p)
2498
{return assign(__p);}
2499
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2500
_LIBCPP_INLINE_VISIBILITY
2501
basic_regex& operator=(initializer_list<value_type> __il)
2502
{return assign(__il);}
2503
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2504
template <class _ST, class _SA>
2505
_LIBCPP_INLINE_VISIBILITY
2506
basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
2507
{return assign(__p);}
2510
_LIBCPP_INLINE_VISIBILITY
2511
basic_regex& assign(const basic_regex& __that)
2512
{return *this = __that;}
2513
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2514
_LIBCPP_INLINE_VISIBILITY
2515
basic_regex& assign(basic_regex&& __that) _NOEXCEPT
2516
{return *this = _VSTD::move(__that);}
2518
_LIBCPP_INLINE_VISIBILITY
2519
basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2520
{return assign(__p, __p + __traits_.length(__p), __f);}
2521
_LIBCPP_INLINE_VISIBILITY
2522
basic_regex& assign(const value_type* __p, size_t __len, flag_type __f)
2523
{return assign(__p, __p + __len, __f);}
2524
template <class _ST, class _SA>
2525
_LIBCPP_INLINE_VISIBILITY
2526
basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
2527
flag_type __f = regex_constants::ECMAScript)
2528
{return assign(__s.begin(), __s.end(), __f);}
2530
template <class _InputIterator>
2531
_LIBCPP_INLINE_VISIBILITY
2534
__is_input_iterator <_InputIterator>::value &&
2535
!__is_forward_iterator<_InputIterator>::value,
2538
assign(_InputIterator __first, _InputIterator __last,
2539
flag_type __f = regex_constants::ECMAScript)
2541
basic_string<_CharT> __t(__first, __last);
2542
return assign(__t.begin(), __t.end(), __f);
2546
_LIBCPP_INLINE_VISIBILITY
2547
void __member_init(flag_type __f)
2550
__marked_count_ = 0;
2557
template <class _ForwardIterator>
2558
_LIBCPP_INLINE_VISIBILITY
2561
__is_forward_iterator<_ForwardIterator>::value,
2564
assign(_ForwardIterator __first, _ForwardIterator __last,
2565
flag_type __f = regex_constants::ECMAScript)
2568
__parse(__first, __last);
2572
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2574
_LIBCPP_INLINE_VISIBILITY
2575
basic_regex& assign(initializer_list<value_type> __il,
2576
flag_type __f = regex_constants::ECMAScript)
2577
{return assign(__il.begin(), __il.end(), __f);}
2579
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2581
// const operations:
2582
_LIBCPP_INLINE_VISIBILITY
2583
unsigned mark_count() const {return __marked_count_;}
2584
_LIBCPP_INLINE_VISIBILITY
2585
flag_type flags() const {return __flags_;}
2588
_LIBCPP_INLINE_VISIBILITY
2589
locale_type imbue(locale_type __loc)
2591
__member_init(ECMAScript);
2593
return __traits_.imbue(__loc);
2595
_LIBCPP_INLINE_VISIBILITY
2596
locale_type getloc() const {return __traits_.getloc();}
2599
void swap(basic_regex& __r);
2602
_LIBCPP_INLINE_VISIBILITY
2603
unsigned __loop_count() const {return __loop_count_;}
2605
template <class _ForwardIterator>
2607
__parse(_ForwardIterator __first, _ForwardIterator __last);
2608
template <class _ForwardIterator>
2610
__parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2611
template <class _ForwardIterator>
2613
__parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
2614
template <class _ForwardIterator>
2616
__parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
2617
template <class _ForwardIterator>
2619
__parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
2620
template <class _ForwardIterator>
2622
__parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
2623
template <class _ForwardIterator>
2625
__parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
2626
template <class _ForwardIterator>
2628
__parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
2629
template <class _ForwardIterator>
2631
__parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
2632
template <class _ForwardIterator>
2634
__parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
2635
template <class _ForwardIterator>
2637
__parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
2638
template <class _ForwardIterator>
2640
__parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2641
template <class _ForwardIterator>
2643
__parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2644
template <class _ForwardIterator>
2646
__parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2647
__owns_one_state<_CharT>* __s,
2648
unsigned __mexp_begin, unsigned __mexp_end);
2649
template <class _ForwardIterator>
2651
__parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2652
__owns_one_state<_CharT>* __s,
2653
unsigned __mexp_begin, unsigned __mexp_end);
2654
template <class _ForwardIterator>
2656
__parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
2657
template <class _ForwardIterator>
2659
__parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
2660
__bracket_expression<_CharT, _Traits>* __ml);
2661
template <class _ForwardIterator>
2663
__parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
2664
__bracket_expression<_CharT, _Traits>* __ml);
2665
template <class _ForwardIterator>
2667
__parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
2668
__bracket_expression<_CharT, _Traits>* __ml);
2669
template <class _ForwardIterator>
2671
__parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
2672
__bracket_expression<_CharT, _Traits>* __ml);
2673
template <class _ForwardIterator>
2675
__parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
2676
basic_string<_CharT>& __col_sym);
2677
template <class _ForwardIterator>
2679
__parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
2680
template <class _ForwardIterator>
2682
__parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2683
template <class _ForwardIterator>
2685
__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
2686
template <class _ForwardIterator>
2688
__parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
2689
template <class _ForwardIterator>
2691
__parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
2692
template <class _ForwardIterator>
2694
__parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2695
template <class _ForwardIterator>
2697
__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2698
template <class _ForwardIterator>
2700
__parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
2701
template <class _ForwardIterator>
2703
__parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
2704
template <class _ForwardIterator>
2706
__parse_term(_ForwardIterator __first, _ForwardIterator __last);
2707
template <class _ForwardIterator>
2709
__parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
2710
template <class _ForwardIterator>
2712
__parse_atom(_ForwardIterator __first, _ForwardIterator __last);
2713
template <class _ForwardIterator>
2715
__parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
2716
template <class _ForwardIterator>
2718
__parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
2719
template <class _ForwardIterator>
2721
__parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
2722
template <class _ForwardIterator>
2724
__parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
2725
basic_string<_CharT>* __str = nullptr);
2726
template <class _ForwardIterator>
2728
__parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
2729
template <class _ForwardIterator>
2731
__parse_grep(_ForwardIterator __first, _ForwardIterator __last);
2732
template <class _ForwardIterator>
2734
__parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
2735
template <class _ForwardIterator>
2737
__parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
2738
basic_string<_CharT>& __str,
2739
__bracket_expression<_CharT, _Traits>* __ml);
2740
template <class _ForwardIterator>
2742
__parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2743
basic_string<_CharT>* __str = nullptr);
2745
_LIBCPP_INLINE_VISIBILITY
2746
void __push_l_anchor();
2747
void __push_r_anchor();
2748
void __push_match_any();
2749
void __push_match_any_but_newline();
2750
_LIBCPP_INLINE_VISIBILITY
2751
void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2752
unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2753
{__push_loop(__min, numeric_limits<size_t>::max(), __s,
2754
__mexp_begin, __mexp_end);}
2755
_LIBCPP_INLINE_VISIBILITY
2756
void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2757
unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2758
{__push_loop(__min, numeric_limits<size_t>::max(), __s,
2759
__mexp_begin, __mexp_end, false);}
2760
void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
2761
size_t __mexp_begin = 0, size_t __mexp_end = 0,
2762
bool __greedy = true);
2763
__bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
2764
void __push_char(value_type __c);
2765
void __push_back_ref(int __i);
2766
void __push_alternation(__owns_one_state<_CharT>* __sa,
2767
__owns_one_state<_CharT>* __sb);
2768
void __push_begin_marked_subexpression();
2769
void __push_end_marked_subexpression(unsigned);
2770
void __push_empty();
2771
void __push_word_boundary(bool);
2772
void __push_lookahead(const basic_regex&, bool);
2774
template <class _Allocator>
2776
__search(const _CharT* __first, const _CharT* __last,
2777
match_results<const _CharT*, _Allocator>& __m,
2778
regex_constants::match_flag_type __flags) const;
2780
template <class _Allocator>
2782
__match_at_start(const _CharT* __first, const _CharT* __last,
2783
match_results<const _CharT*, _Allocator>& __m,
2784
regex_constants::match_flag_type __flags, bool) const;
2785
template <class _Allocator>
2787
__match_at_start_ecma(const _CharT* __first, const _CharT* __last,
2788
match_results<const _CharT*, _Allocator>& __m,
2789
regex_constants::match_flag_type __flags, bool) const;
2790
template <class _Allocator>
2792
__match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
2793
match_results<const _CharT*, _Allocator>& __m,
2794
regex_constants::match_flag_type __flags, bool) const;
2795
template <class _Allocator>
2797
__match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
2798
match_results<const _CharT*, _Allocator>& __m,
2799
regex_constants::match_flag_type __flags, bool) const;
2801
template <class _Bp, class _Ap, class _Cp, class _Tp>
2804
regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
2805
regex_constants::match_flag_type);
2807
template <class _Ap, class _Cp, class _Tp>
2810
regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
2811
const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2813
template <class _Bp, class _Cp, class _Tp>
2816
regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
2817
regex_constants::match_flag_type);
2819
template <class _Cp, class _Tp>
2822
regex_search(const _Cp*, const _Cp*,
2823
const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2825
template <class _Cp, class _Ap, class _Tp>
2828
regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
2829
regex_constants::match_flag_type);
2831
template <class _ST, class _SA, class _Cp, class _Tp>
2834
regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2835
const basic_regex<_Cp, _Tp>& __e,
2836
regex_constants::match_flag_type __flags);
2838
template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
2841
regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2842
match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
2843
const basic_regex<_Cp, _Tp>& __e,
2844
regex_constants::match_flag_type __flags);
2846
template <class, class> friend class __lookahead;
2849
template <class _CharT, class _Traits>
2850
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
2851
template <class _CharT, class _Traits>
2852
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
2853
template <class _CharT, class _Traits>
2854
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
2855
template <class _CharT, class _Traits>
2856
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
2857
template <class _CharT, class _Traits>
2858
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
2859
template <class _CharT, class _Traits>
2860
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
2861
template <class _CharT, class _Traits>
2862
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
2863
template <class _CharT, class _Traits>
2864
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
2865
template <class _CharT, class _Traits>
2866
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
2867
template <class _CharT, class _Traits>
2868
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
2870
template <class _CharT, class _Traits>
2872
basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
2875
swap(__traits_, __r.__traits_);
2876
swap(__flags_, __r.__flags_);
2877
swap(__marked_count_, __r.__marked_count_);
2878
swap(__loop_count_, __r.__loop_count_);
2879
swap(__open_count_, __r.__open_count_);
2880
swap(__start_, __r.__start_);
2881
swap(__end_, __r.__end_);
2884
template <class _CharT, class _Traits>
2885
inline _LIBCPP_INLINE_VISIBILITY
2887
swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
2889
return __x.swap(__y);
2894
template <class _CharT, class _Traits>
2896
: public __owns_one_state<_CharT>
2898
typedef __owns_one_state<_CharT> base;
2900
basic_regex<_CharT, _Traits> __exp_;
2903
__lookahead(const __lookahead&);
2904
__lookahead& operator=(const __lookahead&);
2906
typedef _VSTD::__state<_CharT> __state;
2908
_LIBCPP_INLINE_VISIBILITY
2909
__lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s)
2910
: base(__s), __exp_(__exp), __invert_(__invert) {}
2912
virtual void __exec(__state&) const;
2915
template <class _CharT, class _Traits>
2917
__lookahead<_CharT, _Traits>::__exec(__state& __s) const
2919
match_results<const _CharT*> __m;
2920
__m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
2921
bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
2923
__s.__flags_ | regex_constants::match_continuous,
2925
if (__matched != __invert_)
2927
__s.__do_ = __state::__accept_but_not_consume;
2928
__s.__node_ = this->first();
2932
__s.__do_ = __state::__reject;
2933
__s.__node_ = nullptr;
2937
template <class _CharT, class _Traits>
2938
template <class _ForwardIterator>
2940
basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
2941
_ForwardIterator __last)
2944
unique_ptr<__node> __h(new __end_state<_CharT>);
2945
__start_.reset(new __empty_state<_CharT>(__h.get()));
2947
__end_ = __start_.get();
2949
switch (__flags_ & 0x1F0)
2952
__first = __parse_ecma_exp(__first, __last);
2955
__first = __parse_basic_reg_exp(__first, __last);
2959
__first = __parse_extended_reg_exp(__first, __last);
2962
__first = __parse_grep(__first, __last);
2965
__first = __parse_egrep(__first, __last);
2967
#ifndef _LIBCPP_NO_EXCEPTIONS
2969
throw regex_error(regex_constants::__re_err_grammar);
2970
#endif // _LIBCPP_NO_EXCEPTIONS
2975
template <class _CharT, class _Traits>
2976
template <class _ForwardIterator>
2978
basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
2979
_ForwardIterator __last)
2981
if (__first != __last)
2983
if (*__first == '^')
2988
if (__first != __last)
2990
__first = __parse_RE_expression(__first, __last);
2991
if (__first != __last)
2993
_ForwardIterator __temp = _VSTD::next(__first);
2994
if (__temp == __last && *__first == '$')
3001
#ifndef _LIBCPP_NO_EXCEPTIONS
3002
if (__first != __last)
3003
throw regex_error(regex_constants::__re_err_empty);
3004
#endif // _LIBCPP_NO_EXCEPTIONS
3009
template <class _CharT, class _Traits>
3010
template <class _ForwardIterator>
3012
basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
3013
_ForwardIterator __last)
3015
__owns_one_state<_CharT>* __sa = __end_;
3016
_ForwardIterator __temp = __parse_ERE_branch(__first, __last);
3017
#ifndef _LIBCPP_NO_EXCEPTIONS
3018
if (__temp == __first)
3019
throw regex_error(regex_constants::__re_err_empty);
3020
#endif // _LIBCPP_NO_EXCEPTIONS
3022
while (__first != __last && *__first == '|')
3024
__owns_one_state<_CharT>* __sb = __end_;
3025
__temp = __parse_ERE_branch(++__first, __last);
3026
#ifndef _LIBCPP_NO_EXCEPTIONS
3027
if (__temp == __first)
3028
throw regex_error(regex_constants::__re_err_empty);
3029
#endif // _LIBCPP_NO_EXCEPTIONS
3030
__push_alternation(__sa, __sb);
3036
template <class _CharT, class _Traits>
3037
template <class _ForwardIterator>
3039
basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
3040
_ForwardIterator __last)
3042
_ForwardIterator __temp = __parse_ERE_expression(__first, __last);
3043
#ifndef _LIBCPP_NO_EXCEPTIONS
3044
if (__temp == __first)
3045
throw regex_error(regex_constants::__re_err_empty);
3046
#endif // _LIBCPP_NO_EXCEPTIONS
3050
__temp = __parse_ERE_expression(__first, __last);
3051
} while (__temp != __first);
3055
template <class _CharT, class _Traits>
3056
template <class _ForwardIterator>
3058
basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
3059
_ForwardIterator __last)
3061
__owns_one_state<_CharT>* __e = __end_;
3062
unsigned __mexp_begin = __marked_count_;
3063
_ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
3064
if (__temp == __first && __temp != __last)
3077
__push_begin_marked_subexpression();
3078
unsigned __temp_count = __marked_count_;
3080
__temp = __parse_extended_reg_exp(++__temp, __last);
3081
#ifndef _LIBCPP_NO_EXCEPTIONS
3082
if (__temp == __last || *__temp != ')')
3083
throw regex_error(regex_constants::error_paren);
3084
#endif // _LIBCPP_NO_EXCEPTIONS
3085
__push_end_marked_subexpression(__temp_count);
3091
if (__temp != __first)
3092
__temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
3098
template <class _CharT, class _Traits>
3099
template <class _ForwardIterator>
3101
basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
3102
_ForwardIterator __last)
3106
_ForwardIterator __temp = __parse_simple_RE(__first, __last);
3107
if (__temp == __first)
3114
template <class _CharT, class _Traits>
3115
template <class _ForwardIterator>
3117
basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
3118
_ForwardIterator __last)
3120
if (__first != __last)
3122
__owns_one_state<_CharT>* __e = __end_;
3123
unsigned __mexp_begin = __marked_count_;
3124
_ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
3125
if (__temp != __first)
3126
__first = __parse_RE_dupl_symbol(__temp, __last, __e,
3127
__mexp_begin+1, __marked_count_+1);
3132
template <class _CharT, class _Traits>
3133
template <class _ForwardIterator>
3135
basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
3136
_ForwardIterator __last)
3138
_ForwardIterator __temp = __first;
3139
__first = __parse_one_char_or_coll_elem_RE(__first, __last);
3140
if (__temp == __first)
3142
__temp = __parse_Back_open_paren(__first, __last);
3143
if (__temp != __first)
3145
__push_begin_marked_subexpression();
3146
unsigned __temp_count = __marked_count_;
3147
__first = __parse_RE_expression(__temp, __last);
3148
__temp = __parse_Back_close_paren(__first, __last);
3149
#ifndef _LIBCPP_NO_EXCEPTIONS
3150
if (__temp == __first)
3151
throw regex_error(regex_constants::error_paren);
3152
#endif // _LIBCPP_NO_EXCEPTIONS
3153
__push_end_marked_subexpression(__temp_count);
3157
__first = __parse_BACKREF(__first, __last);
3162
template <class _CharT, class _Traits>
3163
template <class _ForwardIterator>
3165
basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
3166
_ForwardIterator __first,
3167
_ForwardIterator __last)
3169
_ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
3170
if (__temp == __first)
3172
__temp = __parse_QUOTED_CHAR(__first, __last);
3173
if (__temp == __first)
3175
if (__temp != __last && *__temp == '.')
3181
__temp = __parse_bracket_expression(__first, __last);
3188
template <class _CharT, class _Traits>
3189
template <class _ForwardIterator>
3191
basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
3192
_ForwardIterator __first,
3193
_ForwardIterator __last)
3195
_ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
3196
if (__temp == __first)
3198
__temp = __parse_QUOTED_CHAR_ERE(__first, __last);
3199
if (__temp == __first)
3201
if (__temp != __last && *__temp == '.')
3207
__temp = __parse_bracket_expression(__first, __last);
3214
template <class _CharT, class _Traits>
3215
template <class _ForwardIterator>
3217
basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
3218
_ForwardIterator __last)
3220
if (__first != __last)
3222
_ForwardIterator __temp = _VSTD::next(__first);
3223
if (__temp != __last)
3225
if (*__first == '\\' && *__temp == '(')
3232
template <class _CharT, class _Traits>
3233
template <class _ForwardIterator>
3235
basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
3236
_ForwardIterator __last)
3238
if (__first != __last)
3240
_ForwardIterator __temp = _VSTD::next(__first);
3241
if (__temp != __last)
3243
if (*__first == '\\' && *__temp == ')')
3250
template <class _CharT, class _Traits>
3251
template <class _ForwardIterator>
3253
basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
3254
_ForwardIterator __last)
3256
if (__first != __last)
3258
_ForwardIterator __temp = _VSTD::next(__first);
3259
if (__temp != __last)
3261
if (*__first == '\\' && *__temp == '{')
3268
template <class _CharT, class _Traits>
3269
template <class _ForwardIterator>
3271
basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
3272
_ForwardIterator __last)
3274
if (__first != __last)
3276
_ForwardIterator __temp = _VSTD::next(__first);
3277
if (__temp != __last)
3279
if (*__first == '\\' && *__temp == '}')
3286
template <class _CharT, class _Traits>
3287
template <class _ForwardIterator>
3289
basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
3290
_ForwardIterator __last)
3292
if (__first != __last)
3294
_ForwardIterator __temp = _VSTD::next(__first);
3295
if (__temp != __last)
3297
if (*__first == '\\' && '1' <= *__temp && *__temp <= '9')
3299
__push_back_ref(*__temp - '0');
3307
template <class _CharT, class _Traits>
3308
template <class _ForwardIterator>
3310
basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
3311
_ForwardIterator __last)
3313
if (__first != __last)
3315
_ForwardIterator __temp = _VSTD::next(__first);
3316
if (__temp == __last && *__first == '$')
3318
// Not called inside a bracket
3319
if (*__first == '.' || *__first == '\\' || *__first == '[')
3321
__push_char(*__first);
3327
template <class _CharT, class _Traits>
3328
template <class _ForwardIterator>
3330
basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
3331
_ForwardIterator __last)
3333
if (__first != __last)
3350
if (__open_count_ == 0)
3352
__push_char(*__first);
3357
__push_char(*__first);
3365
template <class _CharT, class _Traits>
3366
template <class _ForwardIterator>
3368
basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
3369
_ForwardIterator __last)
3371
if (__first != __last)
3373
_ForwardIterator __temp = _VSTD::next(__first);
3374
if (__temp != __last)
3376
if (*__first == '\\')
3386
__push_char(*__temp);
3396
template <class _CharT, class _Traits>
3397
template <class _ForwardIterator>
3399
basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
3400
_ForwardIterator __last)
3402
if (__first != __last)
3404
_ForwardIterator __temp = _VSTD::next(__first);
3405
if (__temp != __last)
3407
if (*__first == '\\')
3423
__push_char(*__temp);
3427
if ((__flags_ & 0x1F0) == awk)
3428
__first = __parse_awk_escape(++__first, __last);
3437
template <class _CharT, class _Traits>
3438
template <class _ForwardIterator>
3440
basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
3441
_ForwardIterator __last,
3442
__owns_one_state<_CharT>* __s,
3443
unsigned __mexp_begin,
3444
unsigned __mexp_end)
3446
if (__first != __last)
3448
if (*__first == '*')
3450
__push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3455
_ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
3456
if (__temp != __first)
3460
__temp = __parse_DUP_COUNT(__first, __last, __min);
3461
#ifndef _LIBCPP_NO_EXCEPTIONS
3462
if (__temp == __first)
3463
throw regex_error(regex_constants::error_badbrace);
3464
#endif // _LIBCPP_NO_EXCEPTIONS
3466
#ifndef _LIBCPP_NO_EXCEPTIONS
3467
if (__first == __last)
3468
throw regex_error(regex_constants::error_brace);
3469
#endif // _LIBCPP_NO_EXCEPTIONS
3470
if (*__first != ',')
3472
__temp = __parse_Back_close_brace(__first, __last);
3473
#ifndef _LIBCPP_NO_EXCEPTIONS
3474
if (__temp == __first)
3475
throw regex_error(regex_constants::error_brace);
3476
#endif // _LIBCPP_NO_EXCEPTIONS
3477
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
3483
++__first; // consume ','
3485
__first = __parse_DUP_COUNT(__first, __last, __max);
3486
__temp = __parse_Back_close_brace(__first, __last);
3487
#ifndef _LIBCPP_NO_EXCEPTIONS
3488
if (__temp == __first)
3489
throw regex_error(regex_constants::error_brace);
3490
#endif // _LIBCPP_NO_EXCEPTIONS
3492
__push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3495
#ifndef _LIBCPP_NO_EXCEPTIONS
3497
throw regex_error(regex_constants::error_badbrace);
3498
#endif // _LIBCPP_NO_EXCEPTIONS
3499
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
3510
template <class _CharT, class _Traits>
3511
template <class _ForwardIterator>
3513
basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
3514
_ForwardIterator __last,
3515
__owns_one_state<_CharT>* __s,
3516
unsigned __mexp_begin,
3517
unsigned __mexp_end)
3519
if (__first != __last)
3521
unsigned __grammar = __flags_ & 0x1F0;
3526
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3529
__push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3532
__push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3536
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3539
__push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3542
__push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3546
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3549
__push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
3552
__push_loop(0, 1, __s, __mexp_begin, __mexp_end);
3557
_ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3558
#ifndef _LIBCPP_NO_EXCEPTIONS
3559
if (__temp == __first)
3560
throw regex_error(regex_constants::error_badbrace);
3561
#endif // _LIBCPP_NO_EXCEPTIONS
3563
#ifndef _LIBCPP_NO_EXCEPTIONS
3564
if (__first == __last)
3565
throw regex_error(regex_constants::error_brace);
3566
#endif // _LIBCPP_NO_EXCEPTIONS
3571
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3574
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
3577
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
3581
#ifndef _LIBCPP_NO_EXCEPTIONS
3582
if (__first == __last)
3583
throw regex_error(regex_constants::error_badbrace);
3584
#endif // _LIBCPP_NO_EXCEPTIONS
3585
if (*__first == '}')
3588
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3591
__push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3594
__push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3599
__temp = __parse_DUP_COUNT(__first, __last, __max);
3600
#ifndef _LIBCPP_NO_EXCEPTIONS
3601
if (__temp == __first)
3602
throw regex_error(regex_constants::error_brace);
3603
#endif // _LIBCPP_NO_EXCEPTIONS
3605
#ifndef _LIBCPP_NO_EXCEPTIONS
3606
if (__first == __last || *__first != '}')
3607
throw regex_error(regex_constants::error_brace);
3608
#endif // _LIBCPP_NO_EXCEPTIONS
3610
#ifndef _LIBCPP_NO_EXCEPTIONS
3612
throw regex_error(regex_constants::error_badbrace);
3613
#endif // _LIBCPP_NO_EXCEPTIONS
3614
if (__grammar == ECMAScript && __first != __last && *__first == '?')
3617
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
3620
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
3623
#ifndef _LIBCPP_NO_EXCEPTIONS
3625
throw regex_error(regex_constants::error_badbrace);
3626
#endif // _LIBCPP_NO_EXCEPTIONS
3635
template <class _CharT, class _Traits>
3636
template <class _ForwardIterator>
3638
basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
3639
_ForwardIterator __last)
3641
if (__first != __last && *__first == '[')
3644
#ifndef _LIBCPP_NO_EXCEPTIONS
3645
if (__first == __last)
3646
throw regex_error(regex_constants::error_brack);
3647
#endif // _LIBCPP_NO_EXCEPTIONS
3648
bool __negate = false;
3649
if (*__first == '^')
3654
__bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3655
// __ml owned by *this
3656
#ifndef _LIBCPP_NO_EXCEPTIONS
3657
if (__first == __last)
3658
throw regex_error(regex_constants::error_brack);
3659
#endif // _LIBCPP_NO_EXCEPTIONS
3660
if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
3662
__ml->__add_char(']');
3665
__first = __parse_follow_list(__first, __last, __ml);
3666
#ifndef _LIBCPP_NO_EXCEPTIONS
3667
if (__first == __last)
3668
throw regex_error(regex_constants::error_brack);
3669
#endif // _LIBCPP_NO_EXCEPTIONS
3670
if (*__first == '-')
3672
__ml->__add_char('-');
3675
#ifndef _LIBCPP_NO_EXCEPTIONS
3676
if (__first == __last || *__first != ']')
3677
throw regex_error(regex_constants::error_brack);
3678
#endif // _LIBCPP_NO_EXCEPTIONS
3684
template <class _CharT, class _Traits>
3685
template <class _ForwardIterator>
3687
basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
3688
_ForwardIterator __last,
3689
__bracket_expression<_CharT, _Traits>* __ml)
3691
if (__first != __last)
3695
_ForwardIterator __temp = __parse_expression_term(__first, __last,
3697
if (__temp == __first)
3705
template <class _CharT, class _Traits>
3706
template <class _ForwardIterator>
3708
basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
3709
_ForwardIterator __last,
3710
__bracket_expression<_CharT, _Traits>* __ml)
3712
if (__first != __last && *__first != ']')
3714
_ForwardIterator __temp = _VSTD::next(__first);
3715
basic_string<_CharT> __start_range;
3716
if (__temp != __last && *__first == '[')
3719
return __parse_equivalence_class(++__temp, __last, __ml);
3720
else if (*__temp == ':')
3721
return __parse_character_class(++__temp, __last, __ml);
3722
else if (*__temp == '.')
3723
__first = __parse_collating_symbol(++__temp, __last, __start_range);
3725
unsigned __grammar = __flags_ & 0x1F0;
3726
if (__start_range.empty())
3728
if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3730
if (__grammar == ECMAScript)
3731
__first = __parse_class_escape(++__first, __last, __start_range, __ml);
3733
__first = __parse_awk_escape(++__first, __last, &__start_range);
3737
__start_range = *__first;
3741
if (__first != __last && *__first != ']')
3743
__temp = _VSTD::next(__first);
3744
if (__temp != __last && *__first == '-' && *__temp != ']')
3747
basic_string<_CharT> __end_range;
3750
if (__temp != __last && *__first == '[' && *__temp == '.')
3751
__first = __parse_collating_symbol(++__temp, __last, __end_range);
3754
if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3756
if (__grammar == ECMAScript)
3757
__first = __parse_class_escape(++__first, __last,
3760
__first = __parse_awk_escape(++__first, __last,
3765
__end_range = *__first;
3769
__ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
3773
if (__start_range.size() == 1)
3774
__ml->__add_char(__start_range[0]);
3776
__ml->__add_digraph(__start_range[0], __start_range[1]);
3781
if (__start_range.size() == 1)
3782
__ml->__add_char(__start_range[0]);
3784
__ml->__add_digraph(__start_range[0], __start_range[1]);
3790
template <class _CharT, class _Traits>
3791
template <class _ForwardIterator>
3793
basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
3794
_ForwardIterator __last,
3795
basic_string<_CharT>& __str,
3796
__bracket_expression<_CharT, _Traits>* __ml)
3798
#ifndef _LIBCPP_NO_EXCEPTIONS
3799
if (__first == __last)
3800
throw regex_error(regex_constants::error_escape);
3801
#endif // _LIBCPP_NO_EXCEPTIONS
3811
__ml->__add_class(ctype_base::digit);
3814
__ml->__add_neg_class(ctype_base::digit);
3817
__ml->__add_class(ctype_base::space);
3820
__ml->__add_neg_class(ctype_base::space);
3823
__ml->__add_class(ctype_base::alnum);
3824
__ml->__add_char('_');
3827
__ml->__add_neg_class(ctype_base::alnum);
3828
__ml->__add_neg_char('_');
3831
__first = __parse_character_escape(__first, __last, &__str);
3835
template <class _CharT, class _Traits>
3836
template <class _ForwardIterator>
3838
basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
3839
_ForwardIterator __last,
3840
basic_string<_CharT>* __str)
3842
#ifndef _LIBCPP_NO_EXCEPTIONS
3843
if (__first == __last)
3844
throw regex_error(regex_constants::error_escape);
3845
#endif // _LIBCPP_NO_EXCEPTIONS
3854
__push_char(*__first);
3860
__push_char(_CharT(7));
3866
__push_char(_CharT(8));
3870
*__str = _CharT(0xC);
3872
__push_char(_CharT(0xC));
3876
*__str = _CharT(0xA);
3878
__push_char(_CharT(0xA));
3882
*__str = _CharT(0xD);
3884
__push_char(_CharT(0xD));
3888
*__str = _CharT(0x9);
3890
__push_char(_CharT(0x9));
3894
*__str = _CharT(0xB);
3896
__push_char(_CharT(0xB));
3899
if ('0' <= *__first && *__first <= '7')
3901
unsigned __val = *__first - '0';
3902
if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3904
__val = 8 * __val + *__first - '0';
3905
if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3906
__val = 8 * __val + *__first - '0';
3909
*__str = _CharT(__val);
3911
__push_char(_CharT(__val));
3913
#ifndef _LIBCPP_NO_EXCEPTIONS
3915
throw regex_error(regex_constants::error_escape);
3916
#endif // _LIBCPP_NO_EXCEPTIONS
3920
template <class _CharT, class _Traits>
3921
template <class _ForwardIterator>
3923
basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
3924
_ForwardIterator __last,
3925
__bracket_expression<_CharT, _Traits>* __ml)
3928
// This means =] must exist
3929
value_type _Equal_close[2] = {'=', ']'};
3930
_ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
3932
#ifndef _LIBCPP_NO_EXCEPTIONS
3933
if (__temp == __last)
3934
throw regex_error(regex_constants::error_brack);
3935
#endif // _LIBCPP_NO_EXCEPTIONS
3936
// [__first, __temp) contains all text in [= ... =]
3937
typedef typename _Traits::string_type string_type;
3938
string_type __collate_name =
3939
__traits_.lookup_collatename(__first, __temp);
3940
#ifndef _LIBCPP_NO_EXCEPTIONS
3941
if (__collate_name.empty())
3942
throw regex_error(regex_constants::error_collate);
3943
#endif // _LIBCPP_NO_EXCEPTIONS
3944
string_type __equiv_name =
3945
__traits_.transform_primary(__collate_name.begin(),
3946
__collate_name.end());
3947
if (!__equiv_name.empty())
3948
__ml->__add_equivalence(__equiv_name);
3951
switch (__collate_name.size())
3954
__ml->__add_char(__collate_name[0]);
3957
__ml->__add_digraph(__collate_name[0], __collate_name[1]);
3959
#ifndef _LIBCPP_NO_EXCEPTIONS
3961
throw regex_error(regex_constants::error_collate);
3962
#endif // _LIBCPP_NO_EXCEPTIONS
3965
__first = _VSTD::next(__temp, 2);
3969
template <class _CharT, class _Traits>
3970
template <class _ForwardIterator>
3972
basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
3973
_ForwardIterator __last,
3974
__bracket_expression<_CharT, _Traits>* __ml)
3977
// This means :] must exist
3978
value_type _Colon_close[2] = {':', ']'};
3979
_ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
3981
#ifndef _LIBCPP_NO_EXCEPTIONS
3982
if (__temp == __last)
3983
throw regex_error(regex_constants::error_brack);
3984
#endif // _LIBCPP_NO_EXCEPTIONS
3985
// [__first, __temp) contains all text in [: ... :]
3986
typedef typename _Traits::char_class_type char_class_type;
3987
char_class_type __class_type =
3988
__traits_.lookup_classname(__first, __temp, __flags_ & icase);
3989
#ifndef _LIBCPP_NO_EXCEPTIONS
3990
if (__class_type == 0)
3991
throw regex_error(regex_constants::error_brack);
3992
#endif // _LIBCPP_NO_EXCEPTIONS
3993
__ml->__add_class(__class_type);
3994
__first = _VSTD::next(__temp, 2);
3998
template <class _CharT, class _Traits>
3999
template <class _ForwardIterator>
4001
basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
4002
_ForwardIterator __last,
4003
basic_string<_CharT>& __col_sym)
4006
// This means .] must exist
4007
value_type _Dot_close[2] = {'.', ']'};
4008
_ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
4010
#ifndef _LIBCPP_NO_EXCEPTIONS
4011
if (__temp == __last)
4012
throw regex_error(regex_constants::error_brack);
4013
#endif // _LIBCPP_NO_EXCEPTIONS
4014
// [__first, __temp) contains all text in [. ... .]
4015
typedef typename _Traits::string_type string_type;
4016
__col_sym = __traits_.lookup_collatename(__first, __temp);
4017
switch (__col_sym.size())
4022
#ifndef _LIBCPP_NO_EXCEPTIONS
4024
throw regex_error(regex_constants::error_collate);
4025
#endif // _LIBCPP_NO_EXCEPTIONS
4027
__first = _VSTD::next(__temp, 2);
4031
template <class _CharT, class _Traits>
4032
template <class _ForwardIterator>
4034
basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4035
_ForwardIterator __last,
4038
if (__first != __last && '0' <= *__first && *__first <= '9')
4040
__c = *__first - '0';
4041
for (++__first; __first != __last && '0' <= *__first && *__first <= '9';
4045
__c += *__first - '0';
4051
template <class _CharT, class _Traits>
4052
template <class _ForwardIterator>
4054
basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
4055
_ForwardIterator __last)
4057
__owns_one_state<_CharT>* __sa = __end_;
4058
_ForwardIterator __temp = __parse_alternative(__first, __last);
4059
if (__temp == __first)
4062
while (__first != __last && *__first == '|')
4064
__owns_one_state<_CharT>* __sb = __end_;
4065
__temp = __parse_alternative(++__first, __last);
4066
if (__temp == __first)
4068
__push_alternation(__sa, __sb);
4074
template <class _CharT, class _Traits>
4075
template <class _ForwardIterator>
4077
basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
4078
_ForwardIterator __last)
4082
_ForwardIterator __temp = __parse_term(__first, __last);
4083
if (__temp == __first)
4090
template <class _CharT, class _Traits>
4091
template <class _ForwardIterator>
4093
basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
4094
_ForwardIterator __last)
4096
_ForwardIterator __temp = __parse_assertion(__first, __last);
4097
if (__temp == __first)
4099
__owns_one_state<_CharT>* __e = __end_;
4100
unsigned __mexp_begin = __marked_count_;
4101
__temp = __parse_atom(__first, __last);
4102
if (__temp != __first)
4103
__first = __parse_ERE_dupl_symbol(__temp, __last, __e,
4104
__mexp_begin+1, __marked_count_+1);
4111
template <class _CharT, class _Traits>
4112
template <class _ForwardIterator>
4114
basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
4115
_ForwardIterator __last)
4117
if (__first != __last)
4131
_ForwardIterator __temp = _VSTD::next(__first);
4132
if (__temp != __last)
4136
__push_word_boundary(false);
4139
else if (*__temp == 'B')
4141
__push_word_boundary(true);
4149
_ForwardIterator __temp = _VSTD::next(__first);
4150
if (__temp != __last && *__temp == '?')
4152
if (++__temp != __last)
4159
__exp.__flags_ = __flags_;
4160
__temp = __exp.__parse(++__temp, __last);
4161
__push_lookahead(_VSTD::move(__exp), false);
4162
#ifndef _LIBCPP_NO_EXCEPTIONS
4163
if (__temp == __last || *__temp != ')')
4164
throw regex_error(regex_constants::error_paren);
4165
#endif // _LIBCPP_NO_EXCEPTIONS
4172
__exp.__flags_ = __flags_;
4173
__temp = __exp.__parse(++__temp, __last);
4174
__push_lookahead(_VSTD::move(__exp), true);
4175
#ifndef _LIBCPP_NO_EXCEPTIONS
4176
if (__temp == __last || *__temp != ')')
4177
throw regex_error(regex_constants::error_paren);
4178
#endif // _LIBCPP_NO_EXCEPTIONS
4192
template <class _CharT, class _Traits>
4193
template <class _ForwardIterator>
4195
basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
4196
_ForwardIterator __last)
4198
if (__first != __last)
4203
__push_match_any_but_newline();
4207
__first = __parse_atom_escape(__first, __last);
4210
__first = __parse_bracket_expression(__first, __last);
4215
#ifndef _LIBCPP_NO_EXCEPTIONS
4216
if (__first == __last)
4217
throw regex_error(regex_constants::error_paren);
4218
#endif // _LIBCPP_NO_EXCEPTIONS
4219
_ForwardIterator __temp = _VSTD::next(__first);
4220
if (__temp != __last && *__first == '?' && *__temp == ':')
4223
__first = __parse_ecma_exp(++__temp, __last);
4224
#ifndef _LIBCPP_NO_EXCEPTIONS
4225
if (__first == __last || *__first != ')')
4226
throw regex_error(regex_constants::error_paren);
4227
#endif // _LIBCPP_NO_EXCEPTIONS
4233
__push_begin_marked_subexpression();
4234
unsigned __temp_count = __marked_count_;
4236
__first = __parse_ecma_exp(__first, __last);
4237
#ifndef _LIBCPP_NO_EXCEPTIONS
4238
if (__first == __last || *__first != ')')
4239
throw regex_error(regex_constants::error_paren);
4240
#endif // _LIBCPP_NO_EXCEPTIONS
4241
__push_end_marked_subexpression(__temp_count);
4248
__first = __parse_pattern_character(__first, __last);
4255
template <class _CharT, class _Traits>
4256
template <class _ForwardIterator>
4258
basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
4259
_ForwardIterator __last)
4261
if (__first != __last && *__first == '\\')
4263
_ForwardIterator __t1 = _VSTD::next(__first);
4264
_ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
4269
__t2 = __parse_character_class_escape(__t1, __last);
4274
__t2 = __parse_character_escape(__t1, __last);
4283
template <class _CharT, class _Traits>
4284
template <class _ForwardIterator>
4286
basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4287
_ForwardIterator __last)
4289
if (__first != __last)
4291
if (*__first == '0')
4293
__push_char(_CharT());
4296
else if ('1' <= *__first && *__first <= '9')
4298
unsigned __v = *__first - '0';
4299
for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
4300
__v = 10 * __v + *__first - '0';
4301
#ifndef _LIBCPP_NO_EXCEPTIONS
4302
if (__v > mark_count())
4303
throw regex_error(regex_constants::error_backref);
4304
#endif // _LIBCPP_NO_EXCEPTIONS
4305
__push_back_ref(__v);
4311
template <class _CharT, class _Traits>
4312
template <class _ForwardIterator>
4314
basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
4315
_ForwardIterator __last)
4317
if (__first != __last)
4319
__bracket_expression<_CharT, _Traits>* __ml;
4323
__ml = __start_matching_list(false);
4324
__ml->__add_class(ctype_base::digit);
4328
__ml = __start_matching_list(true);
4329
__ml->__add_class(ctype_base::digit);
4333
__ml = __start_matching_list(false);
4334
__ml->__add_class(ctype_base::space);
4338
__ml = __start_matching_list(true);
4339
__ml->__add_class(ctype_base::space);
4343
__ml = __start_matching_list(false);
4344
__ml->__add_class(ctype_base::alnum);
4345
__ml->__add_char('_');
4349
__ml = __start_matching_list(true);
4350
__ml->__add_class(ctype_base::alnum);
4351
__ml->__add_char('_');
4359
template <class _CharT, class _Traits>
4360
template <class _ForwardIterator>
4362
basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
4363
_ForwardIterator __last,
4364
basic_string<_CharT>* __str)
4366
if (__first != __last)
4368
_ForwardIterator __t;
4375
*__str = _CharT(0xC);
4377
__push_char(_CharT(0xC));
4382
*__str = _CharT(0xA);
4384
__push_char(_CharT(0xA));
4389
*__str = _CharT(0xD);
4391
__push_char(_CharT(0xD));
4396
*__str = _CharT(0x9);
4398
__push_char(_CharT(0x9));
4403
*__str = _CharT(0xB);
4405
__push_char(_CharT(0xB));
4409
if ((__t = _VSTD::next(__first)) != __last)
4411
if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z')
4414
*__str = _CharT(*__t % 32);
4416
__push_char(_CharT(*__t % 32));
4423
#ifndef _LIBCPP_NO_EXCEPTIONS
4424
if (__first == __last)
4425
throw regex_error(regex_constants::error_escape);
4426
#endif // _LIBCPP_NO_EXCEPTIONS
4427
__hd = __traits_.value(*__first, 16);
4428
#ifndef _LIBCPP_NO_EXCEPTIONS
4430
throw regex_error(regex_constants::error_escape);
4431
#endif // _LIBCPP_NO_EXCEPTIONS
4432
__sum = 16 * __sum + static_cast<unsigned>(__hd);
4434
#ifndef _LIBCPP_NO_EXCEPTIONS
4435
if (__first == __last)
4436
throw regex_error(regex_constants::error_escape);
4437
#endif // _LIBCPP_NO_EXCEPTIONS
4438
__hd = __traits_.value(*__first, 16);
4439
#ifndef _LIBCPP_NO_EXCEPTIONS
4441
throw regex_error(regex_constants::error_escape);
4442
#endif // _LIBCPP_NO_EXCEPTIONS
4443
__sum = 16 * __sum + static_cast<unsigned>(__hd);
4447
#ifndef _LIBCPP_NO_EXCEPTIONS
4448
if (__first == __last)
4449
throw regex_error(regex_constants::error_escape);
4450
#endif // _LIBCPP_NO_EXCEPTIONS
4451
__hd = __traits_.value(*__first, 16);
4452
#ifndef _LIBCPP_NO_EXCEPTIONS
4454
throw regex_error(regex_constants::error_escape);
4455
#endif // _LIBCPP_NO_EXCEPTIONS
4456
__sum = 16 * __sum + static_cast<unsigned>(__hd);
4458
#ifndef _LIBCPP_NO_EXCEPTIONS
4459
if (__first == __last)
4460
throw regex_error(regex_constants::error_escape);
4461
#endif // _LIBCPP_NO_EXCEPTIONS
4462
__hd = __traits_.value(*__first, 16);
4463
#ifndef _LIBCPP_NO_EXCEPTIONS
4465
throw regex_error(regex_constants::error_escape);
4466
#endif // _LIBCPP_NO_EXCEPTIONS
4467
__sum = 16 * __sum + static_cast<unsigned>(__hd);
4469
*__str = _CharT(__sum);
4471
__push_char(_CharT(__sum));
4475
if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
4480
__push_char(*__first);
4483
#ifndef _LIBCPP_NO_EXCEPTIONS
4485
throw regex_error(regex_constants::error_escape);
4486
#endif // _LIBCPP_NO_EXCEPTIONS
4493
template <class _CharT, class _Traits>
4494
template <class _ForwardIterator>
4496
basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
4497
_ForwardIterator __last)
4499
if (__first != __last)
4519
__push_char(*__first);
4527
template <class _CharT, class _Traits>
4528
template <class _ForwardIterator>
4530
basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
4531
_ForwardIterator __last)
4533
__owns_one_state<_CharT>* __sa = __end_;
4534
_ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4535
if (__t1 != __first)
4536
__parse_basic_reg_exp(__first, __t1);
4540
if (__first != __last)
4542
while (__first != __last)
4544
__t1 = _VSTD::find(__first, __last, _CharT('\n'));
4545
__owns_one_state<_CharT>* __sb = __end_;
4546
if (__t1 != __first)
4547
__parse_basic_reg_exp(__first, __t1);
4550
__push_alternation(__sa, __sb);
4552
if (__first != __last)
4558
template <class _CharT, class _Traits>
4559
template <class _ForwardIterator>
4561
basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
4562
_ForwardIterator __last)
4564
__owns_one_state<_CharT>* __sa = __end_;
4565
_ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4566
if (__t1 != __first)
4567
__parse_extended_reg_exp(__first, __t1);
4571
if (__first != __last)
4573
while (__first != __last)
4575
__t1 = _VSTD::find(__first, __last, _CharT('\n'));
4576
__owns_one_state<_CharT>* __sb = __end_;
4577
if (__t1 != __first)
4578
__parse_extended_reg_exp(__first, __t1);
4581
__push_alternation(__sa, __sb);
4583
if (__first != __last)
4589
template <class _CharT, class _Traits>
4591
basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
4592
__owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
4595
unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
4596
__end_->first() = nullptr;
4597
unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
4598
__s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
4600
__s->first() = nullptr;
4602
__end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
4603
__end_ = __e2->second();
4604
__s->first() = __e2.release();
4608
template <class _CharT, class _Traits>
4610
basic_regex<_CharT, _Traits>::__push_char(value_type __c)
4612
if (flags() & icase)
4613
__end_->first() = new __match_char_icase<_CharT, _Traits>
4614
(__traits_, __c, __end_->first());
4615
else if (flags() & collate)
4616
__end_->first() = new __match_char_collate<_CharT, _Traits>
4617
(__traits_, __c, __end_->first());
4619
__end_->first() = new __match_char<_CharT>(__c, __end_->first());
4620
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4623
template <class _CharT, class _Traits>
4625
basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
4627
if (!(__flags_ & nosubs))
4630
new __begin_marked_subexpression<_CharT>(++__marked_count_,
4632
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4636
template <class _CharT, class _Traits>
4638
basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
4640
if (!(__flags_ & nosubs))
4643
new __end_marked_subexpression<_CharT>(__sub, __end_->first());
4644
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4648
template <class _CharT, class _Traits>
4650
basic_regex<_CharT, _Traits>::__push_l_anchor()
4652
__end_->first() = new __l_anchor<_CharT>(__end_->first());
4653
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4656
template <class _CharT, class _Traits>
4658
basic_regex<_CharT, _Traits>::__push_r_anchor()
4660
__end_->first() = new __r_anchor<_CharT>(__end_->first());
4661
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4664
template <class _CharT, class _Traits>
4666
basic_regex<_CharT, _Traits>::__push_match_any()
4668
__end_->first() = new __match_any<_CharT>(__end_->first());
4669
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4672
template <class _CharT, class _Traits>
4674
basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
4676
__end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
4677
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4680
template <class _CharT, class _Traits>
4682
basic_regex<_CharT, _Traits>::__push_empty()
4684
__end_->first() = new __empty_state<_CharT>(__end_->first());
4685
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4688
template <class _CharT, class _Traits>
4690
basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
4692
__end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
4694
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4697
template <class _CharT, class _Traits>
4699
basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
4701
if (flags() & icase)
4702
__end_->first() = new __back_ref_icase<_CharT, _Traits>
4703
(__traits_, __i, __end_->first());
4704
else if (flags() & collate)
4705
__end_->first() = new __back_ref_collate<_CharT, _Traits>
4706
(__traits_, __i, __end_->first());
4708
__end_->first() = new __back_ref<_CharT>(__i, __end_->first());
4709
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4712
template <class _CharT, class _Traits>
4714
basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
4715
__owns_one_state<_CharT>* __ea)
4717
__sa->first() = new __alternate<_CharT>(
4718
static_cast<__owns_one_state<_CharT>*>(__sa->first()),
4719
static_cast<__owns_one_state<_CharT>*>(__ea->first()));
4720
__ea->first() = nullptr;
4721
__ea->first() = new __empty_state<_CharT>(__end_->first());
4722
__end_->first() = nullptr;
4723
__end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
4724
__end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
4727
template <class _CharT, class _Traits>
4728
__bracket_expression<_CharT, _Traits>*
4729
basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
4731
__bracket_expression<_CharT, _Traits>* __r =
4732
new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
4733
__negate, __flags_ & icase,
4734
__flags_ & collate);
4735
__end_->first() = __r;
4740
template <class _CharT, class _Traits>
4742
basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4745
__end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4747
__end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4750
typedef basic_regex<char> regex;
4751
typedef basic_regex<wchar_t> wregex;
4755
template <class _BidirectionalIterator>
4756
class _LIBCPP_TYPE_VIS sub_match
4757
: public pair<_BidirectionalIterator, _BidirectionalIterator>
4760
typedef _BidirectionalIterator iterator;
4761
typedef typename iterator_traits<iterator>::value_type value_type;
4762
typedef typename iterator_traits<iterator>::difference_type difference_type;
4763
typedef basic_string<value_type> string_type;
4767
_LIBCPP_INLINE_VISIBILITY
4768
_LIBCPP_CONSTEXPR sub_match() : matched() {}
4770
_LIBCPP_INLINE_VISIBILITY
4771
difference_type length() const
4772
{return matched ? _VSTD::distance(this->first, this->second) : 0;}
4773
_LIBCPP_INLINE_VISIBILITY
4774
string_type str() const
4775
{return matched ? string_type(this->first, this->second) : string_type();}
4776
_LIBCPP_INLINE_VISIBILITY
4777
operator string_type() const
4780
_LIBCPP_INLINE_VISIBILITY
4781
int compare(const sub_match& __s) const
4782
{return str().compare(__s.str());}
4783
_LIBCPP_INLINE_VISIBILITY
4784
int compare(const string_type& __s) const
4785
{return str().compare(__s);}
4786
_LIBCPP_INLINE_VISIBILITY
4787
int compare(const value_type* __s) const
4788
{return str().compare(__s);}
4791
typedef sub_match<const char*> csub_match;
4792
typedef sub_match<const wchar_t*> wcsub_match;
4793
typedef sub_match<string::const_iterator> ssub_match;
4794
typedef sub_match<wstring::const_iterator> wssub_match;
4796
template <class _BiIter>
4797
inline _LIBCPP_INLINE_VISIBILITY
4799
operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4801
return __x.compare(__y) == 0;
4804
template <class _BiIter>
4805
inline _LIBCPP_INLINE_VISIBILITY
4807
operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4809
return !(__x == __y);
4812
template <class _BiIter>
4813
inline _LIBCPP_INLINE_VISIBILITY
4815
operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4817
return __x.compare(__y) < 0;
4820
template <class _BiIter>
4821
inline _LIBCPP_INLINE_VISIBILITY
4823
operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4825
return !(__y < __x);
4828
template <class _BiIter>
4829
inline _LIBCPP_INLINE_VISIBILITY
4831
operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4833
return !(__x < __y);
4836
template <class _BiIter>
4837
inline _LIBCPP_INLINE_VISIBILITY
4839
operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4844
template <class _BiIter, class _ST, class _SA>
4845
inline _LIBCPP_INLINE_VISIBILITY
4847
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4848
const sub_match<_BiIter>& __y)
4850
return __y.compare(__x.c_str()) == 0;
4853
template <class _BiIter, class _ST, class _SA>
4854
inline _LIBCPP_INLINE_VISIBILITY
4856
operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4857
const sub_match<_BiIter>& __y)
4859
return !(__x == __y);
4862
template <class _BiIter, class _ST, class _SA>
4863
inline _LIBCPP_INLINE_VISIBILITY
4865
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4866
const sub_match<_BiIter>& __y)
4868
return __y.compare(__x.c_str()) > 0;
4871
template <class _BiIter, class _ST, class _SA>
4872
inline _LIBCPP_INLINE_VISIBILITY
4874
operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4875
const sub_match<_BiIter>& __y)
4880
template <class _BiIter, class _ST, class _SA>
4881
inline _LIBCPP_INLINE_VISIBILITY
4882
bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4883
const sub_match<_BiIter>& __y)
4885
return !(__x < __y);
4888
template <class _BiIter, class _ST, class _SA>
4889
inline _LIBCPP_INLINE_VISIBILITY
4891
operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4892
const sub_match<_BiIter>& __y)
4894
return !(__y < __x);
4897
template <class _BiIter, class _ST, class _SA>
4898
inline _LIBCPP_INLINE_VISIBILITY
4900
operator==(const sub_match<_BiIter>& __x,
4901
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4903
return __x.compare(__y.c_str()) == 0;
4906
template <class _BiIter, class _ST, class _SA>
4907
inline _LIBCPP_INLINE_VISIBILITY
4909
operator!=(const sub_match<_BiIter>& __x,
4910
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4912
return !(__x == __y);
4915
template <class _BiIter, class _ST, class _SA>
4916
inline _LIBCPP_INLINE_VISIBILITY
4918
operator<(const sub_match<_BiIter>& __x,
4919
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4921
return __x.compare(__y.c_str()) < 0;
4924
template <class _BiIter, class _ST, class _SA>
4925
inline _LIBCPP_INLINE_VISIBILITY
4926
bool operator>(const sub_match<_BiIter>& __x,
4927
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4932
template <class _BiIter, class _ST, class _SA>
4933
inline _LIBCPP_INLINE_VISIBILITY
4935
operator>=(const sub_match<_BiIter>& __x,
4936
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4938
return !(__x < __y);
4941
template <class _BiIter, class _ST, class _SA>
4942
inline _LIBCPP_INLINE_VISIBILITY
4944
operator<=(const sub_match<_BiIter>& __x,
4945
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4947
return !(__y < __x);
4950
template <class _BiIter>
4951
inline _LIBCPP_INLINE_VISIBILITY
4953
operator==(typename iterator_traits<_BiIter>::value_type const* __x,
4954
const sub_match<_BiIter>& __y)
4956
return __y.compare(__x) == 0;
4959
template <class _BiIter>
4960
inline _LIBCPP_INLINE_VISIBILITY
4962
operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
4963
const sub_match<_BiIter>& __y)
4965
return !(__x == __y);
4968
template <class _BiIter>
4969
inline _LIBCPP_INLINE_VISIBILITY
4971
operator<(typename iterator_traits<_BiIter>::value_type const* __x,
4972
const sub_match<_BiIter>& __y)
4974
return __y.compare(__x) > 0;
4977
template <class _BiIter>
4978
inline _LIBCPP_INLINE_VISIBILITY
4980
operator>(typename iterator_traits<_BiIter>::value_type const* __x,
4981
const sub_match<_BiIter>& __y)
4986
template <class _BiIter>
4987
inline _LIBCPP_INLINE_VISIBILITY
4989
operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
4990
const sub_match<_BiIter>& __y)
4992
return !(__x < __y);
4995
template <class _BiIter>
4996
inline _LIBCPP_INLINE_VISIBILITY
4998
operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
4999
const sub_match<_BiIter>& __y)
5001
return !(__y < __x);
5004
template <class _BiIter>
5005
inline _LIBCPP_INLINE_VISIBILITY
5007
operator==(const sub_match<_BiIter>& __x,
5008
typename iterator_traits<_BiIter>::value_type const* __y)
5010
return __x.compare(__y) == 0;
5013
template <class _BiIter>
5014
inline _LIBCPP_INLINE_VISIBILITY
5016
operator!=(const sub_match<_BiIter>& __x,
5017
typename iterator_traits<_BiIter>::value_type const* __y)
5019
return !(__x == __y);
5022
template <class _BiIter>
5023
inline _LIBCPP_INLINE_VISIBILITY
5025
operator<(const sub_match<_BiIter>& __x,
5026
typename iterator_traits<_BiIter>::value_type const* __y)
5028
return __x.compare(__y) < 0;
5031
template <class _BiIter>
5032
inline _LIBCPP_INLINE_VISIBILITY
5034
operator>(const sub_match<_BiIter>& __x,
5035
typename iterator_traits<_BiIter>::value_type const* __y)
5040
template <class _BiIter>
5041
inline _LIBCPP_INLINE_VISIBILITY
5043
operator>=(const sub_match<_BiIter>& __x,
5044
typename iterator_traits<_BiIter>::value_type const* __y)
5046
return !(__x < __y);
5049
template <class _BiIter>
5050
inline _LIBCPP_INLINE_VISIBILITY
5052
operator<=(const sub_match<_BiIter>& __x,
5053
typename iterator_traits<_BiIter>::value_type const* __y)
5055
return !(__y < __x);
5058
template <class _BiIter>
5059
inline _LIBCPP_INLINE_VISIBILITY
5061
operator==(typename iterator_traits<_BiIter>::value_type const& __x,
5062
const sub_match<_BiIter>& __y)
5064
typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5065
return __y.compare(string_type(1, __x)) == 0;
5068
template <class _BiIter>
5069
inline _LIBCPP_INLINE_VISIBILITY
5071
operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
5072
const sub_match<_BiIter>& __y)
5074
return !(__x == __y);
5077
template <class _BiIter>
5078
inline _LIBCPP_INLINE_VISIBILITY
5080
operator<(typename iterator_traits<_BiIter>::value_type const& __x,
5081
const sub_match<_BiIter>& __y)
5083
typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5084
return __y.compare(string_type(1, __x)) > 0;
5087
template <class _BiIter>
5088
inline _LIBCPP_INLINE_VISIBILITY
5090
operator>(typename iterator_traits<_BiIter>::value_type const& __x,
5091
const sub_match<_BiIter>& __y)
5096
template <class _BiIter>
5097
inline _LIBCPP_INLINE_VISIBILITY
5099
operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
5100
const sub_match<_BiIter>& __y)
5102
return !(__x < __y);
5105
template <class _BiIter>
5106
inline _LIBCPP_INLINE_VISIBILITY
5108
operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
5109
const sub_match<_BiIter>& __y)
5111
return !(__y < __x);
5114
template <class _BiIter>
5115
inline _LIBCPP_INLINE_VISIBILITY
5117
operator==(const sub_match<_BiIter>& __x,
5118
typename iterator_traits<_BiIter>::value_type const& __y)
5120
typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5121
return __x.compare(string_type(1, __y)) == 0;
5124
template <class _BiIter>
5125
inline _LIBCPP_INLINE_VISIBILITY
5127
operator!=(const sub_match<_BiIter>& __x,
5128
typename iterator_traits<_BiIter>::value_type const& __y)
5130
return !(__x == __y);
5133
template <class _BiIter>
5134
inline _LIBCPP_INLINE_VISIBILITY
5136
operator<(const sub_match<_BiIter>& __x,
5137
typename iterator_traits<_BiIter>::value_type const& __y)
5139
typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5140
return __x.compare(string_type(1, __y)) < 0;
5143
template <class _BiIter>
5144
inline _LIBCPP_INLINE_VISIBILITY
5146
operator>(const sub_match<_BiIter>& __x,
5147
typename iterator_traits<_BiIter>::value_type const& __y)
5152
template <class _BiIter>
5153
inline _LIBCPP_INLINE_VISIBILITY
5155
operator>=(const sub_match<_BiIter>& __x,
5156
typename iterator_traits<_BiIter>::value_type const& __y)
5158
return !(__x < __y);
5161
template <class _BiIter>
5162
inline _LIBCPP_INLINE_VISIBILITY
5164
operator<=(const sub_match<_BiIter>& __x,
5165
typename iterator_traits<_BiIter>::value_type const& __y)
5167
return !(__y < __x);
5170
template <class _CharT, class _ST, class _BiIter>
5171
inline _LIBCPP_INLINE_VISIBILITY
5172
basic_ostream<_CharT, _ST>&
5173
operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5175
return __os << __m.str();
5178
template <class _BidirectionalIterator, class _Allocator>
5179
class _LIBCPP_TYPE_VIS match_results
5182
typedef _Allocator allocator_type;
5183
typedef sub_match<_BidirectionalIterator> value_type;
5185
typedef vector<value_type, allocator_type> __container_type;
5187
__container_type __matches_;
5188
value_type __unmatched_;
5189
value_type __prefix_;
5190
value_type __suffix_;
5193
_BidirectionalIterator __position_start_;
5194
typedef const value_type& const_reference;
5195
typedef const_reference reference;
5196
typedef typename __container_type::const_iterator const_iterator;
5197
typedef const_iterator iterator;
5198
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
5199
typedef typename allocator_traits<allocator_type>::size_type size_type;
5200
typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
5201
typedef basic_string<char_type> string_type;
5203
// construct/copy/destroy:
5204
explicit match_results(const allocator_type& __a = allocator_type());
5205
// match_results(const match_results&) = default;
5206
// match_results& operator=(const match_results&) = default;
5207
// match_results(match_results&& __m) = default;
5208
// match_results& operator=(match_results&& __m) = default;
5209
// ~match_results() = default;
5211
_LIBCPP_INLINE_VISIBILITY
5212
bool ready() const {return __ready_;}
5215
_LIBCPP_INLINE_VISIBILITY
5216
size_type size() const {return __matches_.size();}
5217
_LIBCPP_INLINE_VISIBILITY
5218
size_type max_size() const {return __matches_.max_size();}
5219
_LIBCPP_INLINE_VISIBILITY
5220
bool empty() const {return size() == 0;}
5223
_LIBCPP_INLINE_VISIBILITY
5224
difference_type length(size_type __sub = 0) const
5225
{return (*this)[__sub].length();}
5226
_LIBCPP_INLINE_VISIBILITY
5227
difference_type position(size_type __sub = 0) const
5228
{return _VSTD::distance(__position_start_, (*this)[__sub].first);}
5229
_LIBCPP_INLINE_VISIBILITY
5230
string_type str(size_type __sub = 0) const
5231
{return (*this)[__sub].str();}
5232
_LIBCPP_INLINE_VISIBILITY
5233
const_reference operator[](size_type __n) const
5234
{return __n < __matches_.size() ? __matches_[__n] : __unmatched_;}
5236
_LIBCPP_INLINE_VISIBILITY
5237
const_reference prefix() const {return __prefix_;}
5238
_LIBCPP_INLINE_VISIBILITY
5239
const_reference suffix() const {return __suffix_;}
5241
_LIBCPP_INLINE_VISIBILITY
5242
const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
5243
_LIBCPP_INLINE_VISIBILITY
5244
const_iterator end() const {return __matches_.end();}
5245
_LIBCPP_INLINE_VISIBILITY
5246
const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
5247
_LIBCPP_INLINE_VISIBILITY
5248
const_iterator cend() const {return __matches_.end();}
5251
template <class _OutputIter>
5253
format(_OutputIter __out, const char_type* __fmt_first,
5254
const char_type* __fmt_last,
5255
regex_constants::match_flag_type __flags = regex_constants::format_default) const;
5256
template <class _OutputIter, class _ST, class _SA>
5257
_LIBCPP_INLINE_VISIBILITY
5259
format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt,
5260
regex_constants::match_flag_type __flags = regex_constants::format_default) const
5261
{return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
5262
template <class _ST, class _SA>
5263
_LIBCPP_INLINE_VISIBILITY
5264
basic_string<char_type, _ST, _SA>
5265
format(const basic_string<char_type, _ST, _SA>& __fmt,
5266
regex_constants::match_flag_type __flags = regex_constants::format_default) const
5268
basic_string<char_type, _ST, _SA> __r;
5269
format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5273
_LIBCPP_INLINE_VISIBILITY
5275
format(const char_type* __fmt,
5276
regex_constants::match_flag_type __flags = regex_constants::format_default) const
5279
format(back_inserter(__r), __fmt,
5280
__fmt + char_traits<char_type>::length(__fmt), __flags);
5285
_LIBCPP_INLINE_VISIBILITY
5286
allocator_type get_allocator() const {return __matches_.get_allocator();}
5289
void swap(match_results& __m);
5291
template <class _Bp, class _Ap>
5292
_LIBCPP_INLINE_VISIBILITY
5293
void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
5294
const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
5296
_Bp __mf = __m.prefix().first;
5297
__matches_.resize(__m.size());
5298
for (size_type __i = 0; __i < __matches_.size(); ++__i)
5300
__matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
5301
__matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
5302
__matches_[__i].matched = __m[__i].matched;
5304
__unmatched_.first = __l;
5305
__unmatched_.second = __l;
5306
__unmatched_.matched = false;
5307
__prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
5308
__prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
5309
__prefix_.matched = __m.prefix().matched;
5310
__suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
5311
__suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
5312
__suffix_.matched = __m.suffix().matched;
5313
if (!__no_update_pos)
5314
__position_start_ = __prefix_.first;
5315
__ready_ = __m.ready();
5319
void __init(unsigned __s,
5320
_BidirectionalIterator __f, _BidirectionalIterator __l,
5321
bool __no_update_pos = false);
5323
template <class, class> friend class basic_regex;
5325
template <class _Bp, class _Ap, class _Cp, class _Tp>
5328
regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
5329
regex_constants::match_flag_type);
5331
template <class _Bp, class _Ap>
5334
operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
5336
template <class, class> friend class __lookahead;
5339
template <class _BidirectionalIterator, class _Allocator>
5340
match_results<_BidirectionalIterator, _Allocator>::match_results(
5341
const allocator_type& __a)
5346
__position_start_(),
5351
template <class _BidirectionalIterator, class _Allocator>
5353
match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
5354
_BidirectionalIterator __f, _BidirectionalIterator __l,
5355
bool __no_update_pos)
5357
__unmatched_.first = __l;
5358
__unmatched_.second = __l;
5359
__unmatched_.matched = false;
5360
__matches_.assign(__s, __unmatched_);
5361
__prefix_.first = __f;
5362
__prefix_.second = __f;
5363
__prefix_.matched = false;
5364
__suffix_ = __unmatched_;
5365
if (!__no_update_pos)
5366
__position_start_ = __prefix_.first;
5370
template <class _BidirectionalIterator, class _Allocator>
5371
template <class _OutputIter>
5373
match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
5374
const char_type* __fmt_first, const char_type* __fmt_last,
5375
regex_constants::match_flag_type __flags) const
5377
if (__flags & regex_constants::format_sed)
5379
for (; __fmt_first != __fmt_last; ++__fmt_first)
5381
if (*__fmt_first == '&')
5382
__out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5384
else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
5387
if ('0' <= *__fmt_first && *__fmt_first <= '9')
5389
size_t __i = *__fmt_first - '0';
5390
__out = _VSTD::copy(__matches_[__i].first,
5391
__matches_[__i].second, __out);
5395
*__out = *__fmt_first;
5401
*__out = *__fmt_first;
5408
for (; __fmt_first != __fmt_last; ++__fmt_first)
5410
if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
5412
switch (__fmt_first[1])
5415
*__out = *++__fmt_first;
5420
__out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5425
__out = _VSTD::copy(__prefix_.first, __prefix_.second, __out);
5429
__out = _VSTD::copy(__suffix_.first, __suffix_.second, __out);
5432
if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5435
size_t __i = *__fmt_first - '0';
5436
if (__fmt_first + 1 != __fmt_last &&
5437
'0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5440
__i = 10 * __i + *__fmt_first - '0';
5442
__out = _VSTD::copy(__matches_[__i].first,
5443
__matches_[__i].second, __out);
5447
*__out = *__fmt_first;
5455
*__out = *__fmt_first;
5463
template <class _BidirectionalIterator, class _Allocator>
5465
match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5468
swap(__matches_, __m.__matches_);
5469
swap(__unmatched_, __m.__unmatched_);
5470
swap(__prefix_, __m.__prefix_);
5471
swap(__suffix_, __m.__suffix_);
5472
swap(__position_start_, __m.__position_start_);
5473
swap(__ready_, __m.__ready_);
5476
typedef match_results<const char*> cmatch;
5477
typedef match_results<const wchar_t*> wcmatch;
5478
typedef match_results<string::const_iterator> smatch;
5479
typedef match_results<wstring::const_iterator> wsmatch;
5481
template <class _BidirectionalIterator, class _Allocator>
5483
operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5484
const match_results<_BidirectionalIterator, _Allocator>& __y)
5486
if (__x.__ready_ != __y.__ready_)
5490
return __x.__matches_ == __y.__matches_ &&
5491
__x.__prefix_ == __y.__prefix_ &&
5492
__x.__suffix_ == __y.__suffix_;
5495
template <class _BidirectionalIterator, class _Allocator>
5496
inline _LIBCPP_INLINE_VISIBILITY
5498
operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
5499
const match_results<_BidirectionalIterator, _Allocator>& __y)
5501
return !(__x == __y);
5504
template <class _BidirectionalIterator, class _Allocator>
5505
inline _LIBCPP_INLINE_VISIBILITY
5507
swap(match_results<_BidirectionalIterator, _Allocator>& __x,
5508
match_results<_BidirectionalIterator, _Allocator>& __y)
5515
template <class _CharT, class _Traits>
5516
template <class _Allocator>
5518
basic_regex<_CharT, _Traits>::__match_at_start_ecma(
5519
const _CharT* __first, const _CharT* __last,
5520
match_results<const _CharT*, _Allocator>& __m,
5521
regex_constants::match_flag_type __flags, bool __at_first) const
5523
vector<__state> __states;
5524
__node* __st = __start_.get();
5527
__states.push_back(__state());
5528
__states.back().__do_ = 0;
5529
__states.back().__first_ = __first;
5530
__states.back().__current_ = __first;
5531
__states.back().__last_ = __last;
5532
__states.back().__sub_matches_.resize(mark_count());
5533
__states.back().__loop_data_.resize(__loop_count());
5534
__states.back().__node_ = __st;
5535
__states.back().__flags_ = __flags;
5536
__states.back().__at_first_ = __at_first;
5539
__state& __s = __states.back();
5541
__s.__node_->__exec(__s);
5544
case __state::__end_state:
5545
__m.__matches_[0].first = __first;
5546
__m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
5547
__m.__matches_[0].matched = true;
5548
for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
5549
__m.__matches_[__i+1] = __s.__sub_matches_[__i];
5551
case __state::__accept_and_consume:
5552
case __state::__repeat:
5553
case __state::__accept_but_not_consume:
5555
case __state::__split:
5557
__state __snext = __s;
5558
__s.__node_->__exec_split(true, __s);
5559
__snext.__node_->__exec_split(false, __snext);
5560
__states.push_back(_VSTD::move(__snext));
5563
case __state::__reject:
5564
__states.pop_back();
5567
#ifndef _LIBCPP_NO_EXCEPTIONS
5568
throw regex_error(regex_constants::__re_err_unknown);
5573
} while (!__states.empty());
5578
template <class _CharT, class _Traits>
5579
template <class _Allocator>
5581
basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
5582
const _CharT* __first, const _CharT* __last,
5583
match_results<const _CharT*, _Allocator>& __m,
5584
regex_constants::match_flag_type __flags, bool __at_first) const
5586
deque<__state> __states;
5587
ptrdiff_t __highest_j = 0;
5588
ptrdiff_t _Np = _VSTD::distance(__first, __last);
5589
__node* __st = __start_.get();
5592
__states.push_back(__state());
5593
__states.back().__do_ = 0;
5594
__states.back().__first_ = __first;
5595
__states.back().__current_ = __first;
5596
__states.back().__last_ = __last;
5597
__states.back().__loop_data_.resize(__loop_count());
5598
__states.back().__node_ = __st;
5599
__states.back().__flags_ = __flags;
5600
__states.back().__at_first_ = __at_first;
5601
bool __matched = false;
5604
__state& __s = __states.back();
5606
__s.__node_->__exec(__s);
5609
case __state::__end_state:
5610
if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5611
__highest_j = __s.__current_ - __s.__first_;
5613
if (__highest_j == _Np)
5616
__states.pop_back();
5618
case __state::__consume_input:
5620
case __state::__accept_and_consume:
5621
__states.push_front(_VSTD::move(__s));
5622
__states.pop_back();
5624
case __state::__repeat:
5625
case __state::__accept_but_not_consume:
5627
case __state::__split:
5629
__state __snext = __s;
5630
__s.__node_->__exec_split(true, __s);
5631
__snext.__node_->__exec_split(false, __snext);
5632
__states.push_back(_VSTD::move(__snext));
5635
case __state::__reject:
5636
__states.pop_back();
5639
#ifndef _LIBCPP_NO_EXCEPTIONS
5640
throw regex_error(regex_constants::__re_err_unknown);
5644
} while (!__states.empty());
5647
__m.__matches_[0].first = __first;
5648
__m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5649
__m.__matches_[0].matched = true;
5656
template <class _CharT, class _Traits>
5657
template <class _Allocator>
5659
basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5660
const _CharT* __first, const _CharT* __last,
5661
match_results<const _CharT*, _Allocator>& __m,
5662
regex_constants::match_flag_type __flags, bool __at_first) const
5664
vector<__state> __states;
5665
__state __best_state;
5667
ptrdiff_t __highest_j = 0;
5668
ptrdiff_t _Np = _VSTD::distance(__first, __last);
5669
__node* __st = __start_.get();
5672
__states.push_back(__state());
5673
__states.back().__do_ = 0;
5674
__states.back().__first_ = __first;
5675
__states.back().__current_ = __first;
5676
__states.back().__last_ = __last;
5677
__states.back().__sub_matches_.resize(mark_count());
5678
__states.back().__loop_data_.resize(__loop_count());
5679
__states.back().__node_ = __st;
5680
__states.back().__flags_ = __flags;
5681
__states.back().__at_first_ = __at_first;
5682
const _CharT* __current = __first;
5683
bool __matched = false;
5686
__state& __s = __states.back();
5688
__s.__node_->__exec(__s);
5691
case __state::__end_state:
5692
if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5694
__highest_j = __s.__current_ - __s.__first_;
5698
if (__highest_j == _Np)
5701
__states.pop_back();
5703
case __state::__accept_and_consume:
5704
__j += __s.__current_ - __current;
5705
__current = __s.__current_;
5707
case __state::__repeat:
5708
case __state::__accept_but_not_consume:
5710
case __state::__split:
5712
__state __snext = __s;
5713
__s.__node_->__exec_split(true, __s);
5714
__snext.__node_->__exec_split(false, __snext);
5715
__states.push_back(_VSTD::move(__snext));
5718
case __state::__reject:
5719
__states.pop_back();
5722
#ifndef _LIBCPP_NO_EXCEPTIONS
5723
throw regex_error(regex_constants::__re_err_unknown);
5727
} while (!__states.empty());
5730
__m.__matches_[0].first = __first;
5731
__m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5732
__m.__matches_[0].matched = true;
5733
for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
5734
__m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
5741
template <class _CharT, class _Traits>
5742
template <class _Allocator>
5744
basic_regex<_CharT, _Traits>::__match_at_start(
5745
const _CharT* __first, const _CharT* __last,
5746
match_results<const _CharT*, _Allocator>& __m,
5747
regex_constants::match_flag_type __flags, bool __at_first) const
5749
if ((__flags_ & 0x1F0) == ECMAScript)
5750
return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
5751
if (mark_count() == 0)
5752
return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
5753
return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
5756
template <class _CharT, class _Traits>
5757
template <class _Allocator>
5759
basic_regex<_CharT, _Traits>::__search(
5760
const _CharT* __first, const _CharT* __last,
5761
match_results<const _CharT*, _Allocator>& __m,
5762
regex_constants::match_flag_type __flags) const
5764
__m.__init(1 + mark_count(), __first, __last,
5765
__flags & regex_constants::__no_update_pos);
5766
if (__match_at_start(__first, __last, __m, __flags, true))
5768
__m.__prefix_.second = __m[0].first;
5769
__m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5770
__m.__suffix_.first = __m[0].second;
5771
__m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5774
if (__first != __last && !(__flags & regex_constants::match_continuous))
5776
__flags |= regex_constants::match_prev_avail;
5777
for (++__first; __first != __last; ++__first)
5779
__m.__matches_.assign(__m.size(), __m.__unmatched_);
5780
if (__match_at_start(__first, __last, __m, __flags, false))
5782
__m.__prefix_.second = __m[0].first;
5783
__m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5784
__m.__suffix_.first = __m[0].second;
5785
__m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5788
__m.__matches_.assign(__m.size(), __m.__unmatched_);
5791
__m.__matches_.clear();
5795
template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5796
inline _LIBCPP_INLINE_VISIBILITY
5798
regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5799
match_results<_BidirectionalIterator, _Allocator>& __m,
5800
const basic_regex<_CharT, _Traits>& __e,
5801
regex_constants::match_flag_type __flags = regex_constants::match_default)
5803
basic_string<_CharT> __s(__first, __last);
5804
match_results<const _CharT*> __mc;
5805
bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5806
__m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5810
template <class _Allocator, class _CharT, class _Traits>
5811
inline _LIBCPP_INLINE_VISIBILITY
5813
regex_search(const _CharT* __first, const _CharT* __last,
5814
match_results<const _CharT*, _Allocator>& __m,
5815
const basic_regex<_CharT, _Traits>& __e,
5816
regex_constants::match_flag_type __flags = regex_constants::match_default)
5818
return __e.__search(__first, __last, __m, __flags);
5821
template <class _BidirectionalIterator, class _CharT, class _Traits>
5822
inline _LIBCPP_INLINE_VISIBILITY
5824
regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5825
const basic_regex<_CharT, _Traits>& __e,
5826
regex_constants::match_flag_type __flags = regex_constants::match_default)
5828
basic_string<_CharT> __s(__first, __last);
5829
match_results<const _CharT*> __mc;
5830
return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5833
template <class _CharT, class _Traits>
5834
inline _LIBCPP_INLINE_VISIBILITY
5836
regex_search(const _CharT* __first, const _CharT* __last,
5837
const basic_regex<_CharT, _Traits>& __e,
5838
regex_constants::match_flag_type __flags = regex_constants::match_default)
5840
match_results<const _CharT*> __mc;
5841
return __e.__search(__first, __last, __mc, __flags);
5844
template <class _CharT, class _Allocator, class _Traits>
5845
inline _LIBCPP_INLINE_VISIBILITY
5847
regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
5848
const basic_regex<_CharT, _Traits>& __e,
5849
regex_constants::match_flag_type __flags = regex_constants::match_default)
5851
return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
5854
template <class _CharT, class _Traits>
5855
inline _LIBCPP_INLINE_VISIBILITY
5857
regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
5858
regex_constants::match_flag_type __flags = regex_constants::match_default)
5860
match_results<const _CharT*> __m;
5861
return _VSTD::regex_search(__str, __m, __e, __flags);
5864
template <class _ST, class _SA, class _CharT, class _Traits>
5865
inline _LIBCPP_INLINE_VISIBILITY
5867
regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5868
const basic_regex<_CharT, _Traits>& __e,
5869
regex_constants::match_flag_type __flags = regex_constants::match_default)
5871
match_results<const _CharT*> __mc;
5872
return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5875
template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5876
inline _LIBCPP_INLINE_VISIBILITY
5878
regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5879
match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5880
const basic_regex<_CharT, _Traits>& __e,
5881
regex_constants::match_flag_type __flags = regex_constants::match_default)
5883
match_results<const _CharT*> __mc;
5884
bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5885
__m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
5891
template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5893
regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
5894
match_results<_BidirectionalIterator, _Allocator>& __m,
5895
const basic_regex<_CharT, _Traits>& __e,
5896
regex_constants::match_flag_type __flags = regex_constants::match_default)
5898
bool __r = _VSTD::regex_search(__first, __last, __m, __e,
5899
__flags | regex_constants::match_continuous);
5902
__r = !__m.suffix().matched;
5904
__m.__matches_.clear();
5909
template <class _BidirectionalIterator, class _CharT, class _Traits>
5910
inline _LIBCPP_INLINE_VISIBILITY
5912
regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
5913
const basic_regex<_CharT, _Traits>& __e,
5914
regex_constants::match_flag_type __flags = regex_constants::match_default)
5916
match_results<_BidirectionalIterator> __m;
5917
return _VSTD::regex_match(__first, __last, __m, __e, __flags);
5920
template <class _CharT, class _Allocator, class _Traits>
5921
inline _LIBCPP_INLINE_VISIBILITY
5923
regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
5924
const basic_regex<_CharT, _Traits>& __e,
5925
regex_constants::match_flag_type __flags = regex_constants::match_default)
5927
return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
5930
template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5931
inline _LIBCPP_INLINE_VISIBILITY
5933
regex_match(const basic_string<_CharT, _ST, _SA>& __s,
5934
match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5935
const basic_regex<_CharT, _Traits>& __e,
5936
regex_constants::match_flag_type __flags = regex_constants::match_default)
5938
return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
5941
template <class _CharT, class _Traits>
5942
inline _LIBCPP_INLINE_VISIBILITY
5944
regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
5945
regex_constants::match_flag_type __flags = regex_constants::match_default)
5947
return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
5950
template <class _ST, class _SA, class _CharT, class _Traits>
5951
inline _LIBCPP_INLINE_VISIBILITY
5953
regex_match(const basic_string<_CharT, _ST, _SA>& __s,
5954
const basic_regex<_CharT, _Traits>& __e,
5955
regex_constants::match_flag_type __flags = regex_constants::match_default)
5957
return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
5962
template <class _BidirectionalIterator,
5963
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
5964
class _Traits = regex_traits<_CharT> >
5965
class _LIBCPP_TYPE_VIS regex_iterator
5968
typedef basic_regex<_CharT, _Traits> regex_type;
5969
typedef match_results<_BidirectionalIterator> value_type;
5970
typedef ptrdiff_t difference_type;
5971
typedef const value_type* pointer;
5972
typedef const value_type& reference;
5973
typedef forward_iterator_tag iterator_category;
5976
_BidirectionalIterator __begin_;
5977
_BidirectionalIterator __end_;
5978
const regex_type* __pregex_;
5979
regex_constants::match_flag_type __flags_;
5980
value_type __match_;
5984
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
5985
const regex_type& __re,
5986
regex_constants::match_flag_type __m = regex_constants::match_default);
5988
bool operator==(const regex_iterator& __x) const;
5989
_LIBCPP_INLINE_VISIBILITY
5990
bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
5992
_LIBCPP_INLINE_VISIBILITY
5993
reference operator*() const {return __match_;}
5994
_LIBCPP_INLINE_VISIBILITY
5995
pointer operator->() const {return &__match_;}
5997
regex_iterator& operator++();
5998
_LIBCPP_INLINE_VISIBILITY
5999
regex_iterator operator++(int)
6001
regex_iterator __t(*this);
6007
template <class _BidirectionalIterator, class _CharT, class _Traits>
6008
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
6009
: __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
6013
template <class _BidirectionalIterator, class _CharT, class _Traits>
6014
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6015
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6016
const regex_type& __re, regex_constants::match_flag_type __m)
6022
_VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
6025
template <class _BidirectionalIterator, class _CharT, class _Traits>
6027
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6028
operator==(const regex_iterator& __x) const
6030
if (__match_.empty() && __x.__match_.empty())
6032
if (__match_.empty() || __x.__match_.empty())
6034
return __begin_ == __x.__begin_ &&
6035
__end_ == __x.__end_ &&
6036
__pregex_ == __x.__pregex_ &&
6037
__flags_ == __x.__flags_ &&
6038
__match_[0] == __x.__match_[0];
6041
template <class _BidirectionalIterator, class _CharT, class _Traits>
6042
regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
6043
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6045
__flags_ |= regex_constants::__no_update_pos;
6046
_BidirectionalIterator __start = __match_[0].second;
6047
if (__match_.length() == 0)
6049
if (__start == __end_)
6051
__match_ = value_type();
6054
else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
6055
__flags_ | regex_constants::match_not_null |
6056
regex_constants::match_continuous))
6061
__flags_ |= regex_constants::match_prev_avail;
6062
if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
6063
__match_ = value_type();
6067
typedef regex_iterator<const char*> cregex_iterator;
6068
typedef regex_iterator<const wchar_t*> wcregex_iterator;
6069
typedef regex_iterator<string::const_iterator> sregex_iterator;
6070
typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6072
// regex_token_iterator
6074
template <class _BidirectionalIterator,
6075
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6076
class _Traits = regex_traits<_CharT> >
6077
class _LIBCPP_TYPE_VIS regex_token_iterator
6080
typedef basic_regex<_CharT, _Traits> regex_type;
6081
typedef sub_match<_BidirectionalIterator> value_type;
6082
typedef ptrdiff_t difference_type;
6083
typedef const value_type* pointer;
6084
typedef const value_type& reference;
6085
typedef forward_iterator_tag iterator_category;
6088
typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
6090
_Position __position_;
6091
const value_type* __result_;
6092
value_type __suffix_;
6094
vector<int> __subs_;
6097
regex_token_iterator();
6098
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6099
const regex_type& __re, int __submatch = 0,
6100
regex_constants::match_flag_type __m =
6101
regex_constants::match_default);
6102
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6103
const regex_type& __re, const vector<int>& __submatches,
6104
regex_constants::match_flag_type __m =
6105
regex_constants::match_default);
6106
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6107
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6108
const regex_type& __re,
6109
initializer_list<int> __submatches,
6110
regex_constants::match_flag_type __m =
6111
regex_constants::match_default);
6112
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6113
template <size_t _Np>
6114
regex_token_iterator(_BidirectionalIterator __a,
6115
_BidirectionalIterator __b,
6116
const regex_type& __re,
6117
const int (&__submatches)[_Np],
6118
regex_constants::match_flag_type __m =
6119
regex_constants::match_default);
6120
regex_token_iterator(const regex_token_iterator&);
6121
regex_token_iterator& operator=(const regex_token_iterator&);
6123
bool operator==(const regex_token_iterator& __x) const;
6124
_LIBCPP_INLINE_VISIBILITY
6125
bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
6127
_LIBCPP_INLINE_VISIBILITY
6128
const value_type& operator*() const {return *__result_;}
6129
_LIBCPP_INLINE_VISIBILITY
6130
const value_type* operator->() const {return __result_;}
6132
regex_token_iterator& operator++();
6133
_LIBCPP_INLINE_VISIBILITY
6134
regex_token_iterator operator++(int)
6136
regex_token_iterator __t(*this);
6142
void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
6145
template <class _BidirectionalIterator, class _CharT, class _Traits>
6146
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6147
regex_token_iterator()
6148
: __result_(nullptr),
6154
template <class _BidirectionalIterator, class _CharT, class _Traits>
6156
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6157
__init(_BidirectionalIterator __a, _BidirectionalIterator __b)
6159
if (__position_ != _Position())
6161
if (__subs_[_N_] == -1)
6162
__result_ = &__position_->prefix();
6164
__result_ = &(*__position_)[__subs_[_N_]];
6166
else if (__subs_[_N_] == -1)
6168
__suffix_.matched = true;
6169
__suffix_.first = __a;
6170
__suffix_.second = __b;
6171
__result_ = &__suffix_;
6174
__result_ = nullptr;
6177
template <class _BidirectionalIterator, class _CharT, class _Traits>
6178
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6179
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6180
const regex_type& __re, int __submatch,
6181
regex_constants::match_flag_type __m)
6182
: __position_(__a, __b, __re, __m),
6184
__subs_(1, __submatch)
6189
template <class _BidirectionalIterator, class _CharT, class _Traits>
6190
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6191
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6192
const regex_type& __re, const vector<int>& __submatches,
6193
regex_constants::match_flag_type __m)
6194
: __position_(__a, __b, __re, __m),
6196
__subs_(__submatches)
6201
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6203
template <class _BidirectionalIterator, class _CharT, class _Traits>
6204
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6205
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6206
const regex_type& __re,
6207
initializer_list<int> __submatches,
6208
regex_constants::match_flag_type __m)
6209
: __position_(__a, __b, __re, __m),
6211
__subs_(__submatches)
6216
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6218
template <class _BidirectionalIterator, class _CharT, class _Traits>
6219
template <size_t _Np>
6220
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6221
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6222
const regex_type& __re,
6223
const int (&__submatches)[_Np],
6224
regex_constants::match_flag_type __m)
6225
: __position_(__a, __b, __re, __m),
6227
__subs_(__submatches, __submatches + _Np)
6232
template <class _BidirectionalIterator, class _CharT, class _Traits>
6233
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6234
regex_token_iterator(const regex_token_iterator& __x)
6235
: __position_(__x.__position_),
6236
__result_(__x.__result_),
6237
__suffix_(__x.__suffix_),
6239
__subs_(__x.__subs_)
6241
if (__x.__result_ == &__x.__suffix_)
6242
__result_ == &__suffix_;
6245
template <class _BidirectionalIterator, class _CharT, class _Traits>
6246
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6247
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6248
operator=(const regex_token_iterator& __x)
6252
__position_ = __x.__position_;
6253
if (__x.__result_ == &__x.__suffix_)
6254
__result_ == &__suffix_;
6256
__result_ = __x.__result_;
6257
__suffix_ = __x.__suffix_;
6259
__subs_ = __x.__subs_;
6264
template <class _BidirectionalIterator, class _CharT, class _Traits>
6266
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6267
operator==(const regex_token_iterator& __x) const
6269
if (__result_ == nullptr && __x.__result_ == nullptr)
6271
if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
6272
__suffix_ == __x.__suffix_)
6274
if (__result_ == nullptr || __x.__result_ == nullptr)
6276
if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
6278
return __position_ == __x.__position_ && _N_ == __x._N_ &&
6279
__subs_ == __x.__subs_;
6282
template <class _BidirectionalIterator, class _CharT, class _Traits>
6283
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6284
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6286
_Position __prev = __position_;
6287
if (__result_ == &__suffix_)
6288
__result_ = nullptr;
6289
else if (_N_ + 1 < __subs_.size())
6292
if (__subs_[_N_] == -1)
6293
__result_ = &__position_->prefix();
6295
__result_ = &(*__position_)[__subs_[_N_]];
6301
if (__position_ != _Position())
6303
if (__subs_[_N_] == -1)
6304
__result_ = &__position_->prefix();
6306
__result_ = &(*__position_)[__subs_[_N_]];
6310
if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
6311
&& __prev->suffix().length() != 0)
6313
__suffix_.matched = true;
6314
__suffix_.first = __prev->suffix().first;
6315
__suffix_.second = __prev->suffix().second;
6316
__result_ = &__suffix_;
6319
__result_ = nullptr;
6325
typedef regex_token_iterator<const char*> cregex_token_iterator;
6326
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6327
typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6328
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6332
template <class _OutputIterator, class _BidirectionalIterator,
6333
class _Traits, class _CharT>
6335
regex_replace(_OutputIterator __out,
6336
_BidirectionalIterator __first, _BidirectionalIterator __last,
6337
const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6338
regex_constants::match_flag_type __flags = regex_constants::match_default)
6340
typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
6341
_Iter __i(__first, __last, __e, __flags);
6345
if (!(__flags & regex_constants::format_no_copy))
6346
__out = _VSTD::copy(__first, __last, __out);
6350
sub_match<_BidirectionalIterator> __lm;
6351
for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
6353
if (!(__flags & regex_constants::format_no_copy))
6354
__out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out);
6355
__out = __i->format(__out, __fmt, __fmt + __len, __flags);
6356
__lm = __i->suffix();
6357
if (__flags & regex_constants::format_first_only)
6360
if (!(__flags & regex_constants::format_no_copy))
6361
__out = _VSTD::copy(__lm.first, __lm.second, __out);
6366
template <class _OutputIterator, class _BidirectionalIterator,
6367
class _Traits, class _CharT, class _ST, class _SA>
6368
inline _LIBCPP_INLINE_VISIBILITY
6370
regex_replace(_OutputIterator __out,
6371
_BidirectionalIterator __first, _BidirectionalIterator __last,
6372
const basic_regex<_CharT, _Traits>& __e,
6373
const basic_string<_CharT, _ST, _SA>& __fmt,
6374
regex_constants::match_flag_type __flags = regex_constants::match_default)
6376
return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags);
6379
template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
6381
inline _LIBCPP_INLINE_VISIBILITY
6382
basic_string<_CharT, _ST, _SA>
6383
regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6384
const basic_regex<_CharT, _Traits>& __e,
6385
const basic_string<_CharT, _FST, _FSA>& __fmt,
6386
regex_constants::match_flag_type __flags = regex_constants::match_default)
6388
basic_string<_CharT, _ST, _SA> __r;
6389
_VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6390
__fmt.c_str(), __flags);
6394
template <class _Traits, class _CharT, class _ST, class _SA>
6395
inline _LIBCPP_INLINE_VISIBILITY
6396
basic_string<_CharT, _ST, _SA>
6397
regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6398
const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6399
regex_constants::match_flag_type __flags = regex_constants::match_default)
6401
basic_string<_CharT, _ST, _SA> __r;
6402
_VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6407
template <class _Traits, class _CharT, class _ST, class _SA>
6408
inline _LIBCPP_INLINE_VISIBILITY
6409
basic_string<_CharT>
6410
regex_replace(const _CharT* __s,
6411
const basic_regex<_CharT, _Traits>& __e,
6412
const basic_string<_CharT, _ST, _SA>& __fmt,
6413
regex_constants::match_flag_type __flags = regex_constants::match_default)
6415
basic_string<_CharT> __r;
6416
_VSTD::regex_replace(back_inserter(__r), __s,
6417
__s + char_traits<_CharT>::length(__s), __e,
6418
__fmt.c_str(), __flags);
6422
template <class _Traits, class _CharT>
6423
inline _LIBCPP_INLINE_VISIBILITY
6424
basic_string<_CharT>
6425
regex_replace(const _CharT* __s,
6426
const basic_regex<_CharT, _Traits>& __e,
6427
const _CharT* __fmt,
6428
regex_constants::match_flag_type __flags = regex_constants::match_default)
6430
basic_string<_CharT> __r;
6431
_VSTD::regex_replace(back_inserter(__r), __s,
6432
__s + char_traits<_CharT>::length(__s), __e,
6437
_LIBCPP_END_NAMESPACE_STD
6439
#endif // _LIBCPP_REGEX