31 namespace std _GLIBCXX_VISIBILITY(default)
33 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 template<
typename _BiIter,
typename _Alloc,
44 typename _CharT,
typename _TraitsT,
45 _RegexExecutorPolicy __policy,
48 __regex_algo_impl(_BiIter __s,
50 match_results<_BiIter, _Alloc>& __m,
51 const basic_regex<_CharT, _TraitsT>& __re,
54 if (__re._M_automaton ==
nullptr)
57 typename match_results<_BiIter, _Alloc>::_Base_type& __res = __m;
59 __m._M_resize(__re._M_automaton->_M_sub_count());
60 for (
auto& __it : __res)
65 || (__policy == _RegexExecutorPolicy::_S_alternate
66 && !__re._M_automaton->_M_has_backref))
68 _Executor<_BiIter, _Alloc, _TraitsT, false>
69 __executor(__s, __e, __m, __re, __flags);
71 __ret = __executor._M_match();
73 __ret = __executor._M_search();
77 _Executor<_BiIter, _Alloc, _TraitsT, true>
78 __executor(__s, __e, __m, __re, __flags);
80 __ret = __executor._M_match();
82 __ret = __executor._M_search();
86 for (
auto& __it : __res)
88 __it.first = __it.second = __e;
89 auto& __pre = __m._M_prefix();
90 auto& __suf = __m._M_suffix();
93 __pre.matched =
false;
96 __suf.matched =
false;
103 __pre.second = __res[0].first;
104 __pre.matched = (__pre.first != __pre.second);
105 __suf.first = __res[0].second;
107 __suf.matched = (__suf.first != __suf.second);
113 for (
auto& __it : __res)
115 __it.matched =
false;
116 __it.first = __it.second = __e;
123 template<
typename _Ch_type>
124 template<
typename _Fwd_iter>
125 typename regex_traits<_Ch_type>::string_type
130 const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
132 static const char* __collatenames[] =
225 "left-square-bracket",
227 "right-square-bracket",
257 "left-curly-bracket",
259 "right-curly-bracket",
265 for (; __first != __last; ++__first)
266 __s += __fctyp.narrow(*__first, 0);
268 for (
const auto& __it : __collatenames)
271 static_cast<char>(&__it - __collatenames)));
279 template<
typename _Ch_type>
280 template<
typename _Fwd_iter>
281 typename regex_traits<_Ch_type>::char_class_type
286 const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
291 {
"d", ctype_base::digit},
292 {
"w", {ctype_base::alnum, _RegexMask::_S_under}},
293 {
"s", ctype_base::space},
294 {
"alnum", ctype_base::alnum},
295 {
"alpha", ctype_base::alpha},
296 {
"blank", ctype_base::blank},
297 {
"cntrl", ctype_base::cntrl},
298 {
"digit", ctype_base::digit},
299 {
"graph", ctype_base::graph},
300 {
"lower", ctype_base::lower},
301 {
"print", ctype_base::print},
302 {
"punct", ctype_base::punct},
303 {
"space", ctype_base::space},
304 {
"upper", ctype_base::upper},
305 {
"xdigit", ctype_base::xdigit},
309 for (; __first != __last; ++__first)
310 __s += __fctyp.narrow(__fctyp.tolower(*__first), 0);
312 for (
const auto& __it : __classnames)
313 if (__s == __it.first)
317 & (ctype_base::lower | ctype_base::upper)) != 0))
318 return ctype_base::alpha;
324 template<
typename _Ch_type>
327 isctype(_Ch_type __c, char_class_type __f)
const 330 const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
332 return __fctyp.is(__f._M_base, __c)
334 || ((__f._M_extended & _RegexMask::_S_under)
335 && __c == __fctyp.widen(
'_'));
338 template<
typename _Ch_type>
341 value(_Ch_type __ch,
int __radix)
const 347 else if (__radix == 16)
350 return __is.
fail() ? -1 : __v;
353 template<
typename _Bi_iter,
typename _Alloc>
354 template<
typename _Out_iter>
357 const match_results<_Bi_iter, _Alloc>::char_type* __fmt_first,
358 const match_results<_Bi_iter, _Alloc>::char_type* __fmt_last,
361 __glibcxx_assert( ready() );
365 __fctyp(use_facet<__ctype_type>(__traits.
getloc()));
367 auto __output = [&](
size_t __idx)
369 auto& __sub = (*this)[__idx];
371 __out = std::copy(__sub.first, __sub.second, __out);
376 bool __escaping =
false;
377 for (; __fmt_first != __fmt_last; __fmt_first++)
382 if (__fctyp.is(__ctype_type::digit, *__fmt_first))
383 __output(__traits.
value(*__fmt_first, 10));
385 *__out++ = *__fmt_first;
388 if (*__fmt_first ==
'\\')
393 if (*__fmt_first ==
'&')
398 *__out++ = *__fmt_first;
407 auto __next = std::find(__fmt_first, __fmt_last,
'$');
408 if (__next == __fmt_last)
411 __out = std::copy(__fmt_first, __next, __out);
413 auto __eat = [&](
char __ch) ->
bool 423 if (++__next == __fmt_last)
431 auto& __sub = _M_prefix();
433 __out = std::copy(__sub.first, __sub.second, __out);
435 else if (__eat(
'\''))
437 auto& __sub = _M_suffix();
439 __out = std::copy(__sub.first, __sub.second, __out);
441 else if (__fctyp.is(__ctype_type::digit, *__next))
443 long __num = __traits.
value(*__next, 10);
444 if (++__next != __fmt_last
445 && __fctyp.is(__ctype_type::digit, *__next))
448 __num += __traits.
value(*__next++, 10);
450 if (0 <= __num && __num < this->size())
455 __fmt_first = __next;
457 __out = std::copy(__fmt_first, __fmt_last, __out);
462 template<
typename _Out_iter,
typename _Bi_iter,
463 typename _Rx_traits,
typename _Ch_type>
467 const _Ch_type* __fmt,
471 _IterT __i(__first, __last, __e, __flags);
476 __out = std::copy(__first, __last, __out);
482 for (; __i != __end; ++__i)
485 __out = std::copy(__i->prefix().first, __i->prefix().second,
487 __out = __i->format(__out, __fmt, __fmt + __len, __flags);
488 __last = __i->suffix();
493 __out = std::copy(__last.
first, __last.
second, __out);
498 template<
typename _Bi_iter,
505 if (_M_pregex ==
nullptr && __rhs._M_pregex ==
nullptr)
507 return _M_pregex == __rhs._M_pregex
508 && _M_begin == __rhs._M_begin
509 && _M_end == __rhs._M_end
510 && _M_flags == __rhs._M_flags
511 && _M_match[0] == __rhs._M_match[0];
514 template<
typename _Bi_iter,
527 if (_M_match[0].matched)
529 auto __start = _M_match[0].second;
530 auto __prefix_first = _M_match[0].second;
531 if (_M_match[0].first == _M_match[0].second)
533 if (__start == _M_end)
545 __glibcxx_assert(_M_match[0].matched);
546 auto& __prefix = _M_match._M_prefix();
547 __prefix.first = __prefix_first;
548 __prefix.matched = __prefix.first != __prefix.second;
550 _M_match._M_begin = _M_begin;
558 if (
regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
560 __glibcxx_assert(_M_match[0].matched);
561 auto& __prefix = _M_match._M_prefix();
562 __prefix.first = __prefix_first;
563 __prefix.matched = __prefix.first != __prefix.second;
565 _M_match._M_begin = _M_begin;
573 template<
typename _Bi_iter,
580 _M_position = __rhs._M_position;
581 _M_subs = __rhs._M_subs;
583 _M_suffix = __rhs._M_suffix;
584 _M_has_m1 = __rhs._M_has_m1;
585 _M_normalize_result();
589 template<
typename _Bi_iter,
596 if (_M_end_of_seq() && __rhs._M_end_of_seq())
598 if (_M_suffix.matched && __rhs._M_suffix.matched
599 && _M_suffix == __rhs._M_suffix)
601 if (_M_end_of_seq() || _M_suffix.matched
602 || __rhs._M_end_of_seq() || __rhs._M_suffix.matched)
604 return _M_position == __rhs._M_position
605 && _M_n == __rhs._M_n
606 && _M_subs == __rhs._M_subs;
609 template<
typename _Bi_iter,
616 _Position __prev = _M_position;
617 if (_M_suffix.matched)
619 else if (_M_n + 1 < _M_subs.size())
622 _M_result = &_M_current_match();
628 if (_M_position != _Position())
629 _M_result = &_M_current_match();
630 else if (_M_has_m1 && __prev->suffix().length() != 0)
632 _M_suffix.matched =
true;
633 _M_suffix.first = __prev->suffix().first;
634 _M_suffix.second = __prev->suffix().second;
635 _M_result = &_M_suffix;
643 template<
typename _Bi_iter,
648 _M_init(_Bi_iter __a, _Bi_iter __b)
651 for (
auto __it : _M_subs)
657 if (_M_position != _Position())
658 _M_result = &_M_current_match();
661 _M_suffix.matched =
true;
662 _M_suffix.first = __a;
663 _M_suffix.second = __b;
664 _M_result = &_M_suffix;
670 _GLIBCXX_END_NAMESPACE_VERSION
Describes aspects of a regular expression.
_T2 second
first is a copy of the first object
_GLIBCXX17_INLINE constexpr match_flag_type format_no_copy
regex_token_iterator & operator=(const regex_token_iterator &__rhs)
Assigns a regex_token_iterator to another.
ISO C++ entities toplevel namespace is std.
regex_token_iterator & operator++()
Increments a regex_token_iterator.
Controlling input for std::string.
_Out_iter regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, const basic_regex< _Ch_type, _Rx_traits > &__e, const basic_string< _Ch_type, _St, _Sa > &__fmt, regex_constants::match_flag_type __flags=regex_constants::match_default)
Search for a regular expression within a range for multiple times, and replace the matched parts thro...
_GLIBCXX17_INLINE constexpr match_flag_type match_not_null
ios_base & hex(ios_base &__base)
Calls base.setf(ios_base::hex, ios_base::basefield).
_Out_iter format(_Out_iter __out, const char_type *__fmt_first, const char_type *__fmt_last, match_flag_type __flags=regex_constants::format_default) const
bool regex_search(_Bi_iter __s, _Bi_iter __e, match_results< _Bi_iter, _Alloc > &__m, const basic_regex< _Ch_type, _Rx_traits > &__re, regex_constants::match_flag_type __flags=regex_constants::match_default)
_T1 first
second_type is the second bound type
_GLIBCXX17_INLINE constexpr match_flag_type match_continuous
match_flag_type
This is a bitmask type indicating regex matching rules.
locale_type getloc() const
Gets a copy of the current locale in use by the regex_traits object.
bool operator==(const regex_iterator &) const noexcept
Tests the equivalence of two regex iterators.
bool operator==(const regex_token_iterator &__rhs) const
Compares a regex_token_iterator to another for equality.
int value(_Ch_type __ch, int __radix) const
Converts a digit to an int.
char_class_type lookup_classname(_Fwd_iter __first, _Fwd_iter __last, bool __icase=false) const
Maps one or more characters to a named character classification.
_GLIBCXX17_INLINE constexpr match_flag_type match_prev_avail
string_type lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
Gets a collation element by name.
_GLIBCXX17_INLINE constexpr match_flag_type format_first_only
Primary class template ctype facet.This template class defines classification and conversion function...
Basis for explicit traits specializations.
Managing sequences of characters and character-like objects.
Struct holding two objects of arbitrary type.
bool fail() const
Fast error checking.
_GLIBCXX17_INLINE constexpr syntax_option_type __polynomial
regex_iterator & operator++()
Increments a regex_iterator.
ios_base & oct(ios_base &__base)
Calls base.setf(ios_base::oct, ios_base::basefield).
_GLIBCXX17_INLINE constexpr match_flag_type format_sed
bool isctype(_Ch_type __c, char_class_type __f) const
Determines if c is a member of an identified class.