STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
_Matcher< _BidIt, _Elem, _RxTraits, _It > Class Template Reference

Public Member Functions

 _Matcher (_It _Pfirst, _It _Plast, const _RxTraits &_Tr, _Root_node *_Re, unsigned int _Nx, regex_constants::syntax_option_type _Sf, regex_constants::match_flag_type _Mf)
 
void _Setf (regex_constants::match_flag_type _Mf)
 
void _Clearf (regex_constants::match_flag_type _Mf)
 
template<class _Alloc >
bool _Match (_It _Pfirst, match_results< _BidIt, _Alloc > *_Matches, bool _Full_match)
 
template<class _Alloc >
bool _Match (match_results< _BidIt, _Alloc > *_Matches, bool _Full_match)
 
_BidIt _Skip (_BidIt, _BidIt, _Node_base *=0)
 

Private Member Functions

bool _Do_if (_Node_if *)
 
bool _Do_rep0 (_Node_rep *, bool)
 
bool _Do_rep (_Node_rep *, bool, int)
 
bool _Do_class (_Node_base *)
 
bool _Match_pat (_Node_base *)
 
bool _Better_match ()
 
bool _Is_wbound () const
 
unsigned int _Get_ncap () const
 
_Matcheroperator= (const _Matcher &)
 

Private Attributes

_Tgt_state_t< _It > _Tgt_state
 
_Tgt_state_t< _It > _Res
 
vector< _Loop_vals_t_Loop_vals
 
_It _Begin
 
_It _End
 
_It _First
 
_Node_base_Rep
 
regex_constants::syntax_option_type _Sflags
 
regex_constants::match_flag_type _Mflags
 
bool _Matched
 
bool _Cap
 
int _Ncap
 
bool _Longest
 
const _RxTraits & _Traits
 
bool _Full
 
long _Max_complexity_count
 
long _Max_stack_count
 

Constructor & Destructor Documentation

template<class _BidIt , class _Elem , class _RxTraits , class _It >
_Matcher< _BidIt, _Elem, _RxTraits, _It >::_Matcher ( _It  _Pfirst,
_It  _Plast,
const _RxTraits &  _Tr,
_Root_node _Re,
unsigned int  _Nx,
regex_constants::syntax_option_type  _Sf,
regex_constants::match_flag_type  _Mf 
)
inline
2028  : _First(_Pfirst), _End(_Plast), _Traits(_Tr), _Rep(_Re),
2029  _Sflags(_Sf), _Mflags(_Mf), _Matched(false),
2030  _Ncap(static_cast<int>(_Nx)),
2031  _Longest((_Re->_Flags & _Fl_longest)
2032  && !(_Mf & regex_constants::match_any))
2033  { // construct
2034  _Loop_vals.resize(_Re->_Loops);
2036  }
_Node_base * _Rep
Definition: regex:2136
_RanIt _Plast
Definition: algorithm:2577
#define _DEBUG_RANGE(first, last)
Definition: xutility:902
const _RxTraits & _Traits
Definition: regex:2143
regex_constants::match_flag_type _Mflags
Definition: regex:2138
_It _End
Definition: regex:2134
Definition: regex:1513
bool _Longest
Definition: regex:2142
regex_constants::syntax_option_type _Sflags
Definition: regex:2137
Definition: regex:122
_RanIt _Pfirst
Definition: algorithm:2576
bool _Matched
Definition: regex:2139
vector< _Loop_vals_t > _Loop_vals
Definition: regex:2121
int _Ncap
Definition: regex:2141
void resize(_CRT_GUARDOVERFLOW const size_type _Newsize)
Definition: vector:1489
_Node_flags _Flags
Definition: regex:1681
_It _First
Definition: regex:2135
unsigned int _Loops
Definition: regex:1716

Member Function Documentation

template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Better_match ( )
inlineprivate
4480  { // check for better match under UNIX rules
4481  for (unsigned int _Ix = 0; _Ix < _Get_ncap(); ++_Ix)
4482  { // check each capture group
4483  if (!_Res._Grp_valid[_Ix] || !_Tgt_state._Grp_valid[_Ix])
4484  ;
4485  else if (_Res._Grps[_Ix]._Begin
4486  != _Tgt_state._Grps[_Ix]._Begin)
4487  return (_STD distance(_Begin, _Res._Grps[_Ix]._Begin)
4488  < _STD distance(_Begin, _Tgt_state._Grps[_Ix]._Begin));
4489  else if (_Res._Grps[_Ix]._End
4490  != _Tgt_state._Grps[_Ix]._End)
4491  return (_STD distance(_Begin, _Res._Grps[_Ix]._End)
4492  < _STD distance(_Begin, _Tgt_state._Grps[_Ix]._End));
4493  }
4494  return (false);
4495  }
_It _Begin
Definition: regex:2133
vector< bool > _Grp_valid
Definition: regex:1993
vector< _Grp_t > _Grps
Definition: regex:2008
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
_Iter_diff_t< _InIt > distance(_InIt _First, _InIt _Last)
Definition: xutility:1111
unsigned int _Get_ncap() const
Definition: regex:4524
_Tgt_state_t< _It > _Res
Definition: regex:2120
template<class _BidIt , class _Elem , class _RxTraits , class _It >
void _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Clearf ( regex_constants::match_flag_type  _Mf)
inline
2044  { // clear specified flags
2045  _Mflags &= ~_Mf;
2046  }
regex_constants::match_flag_type _Mflags
Definition: regex:2138
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Do_class ( _Node_base _Nx)
inlineprivate
4430  { // apply bracket expression
4431  bool _Found;
4432  typename _RxTraits::_Uelem _Ch = *_Tgt_state._Cur;
4434  _Ch = _Traits.translate_nocase(_Ch);
4435  _It _Res0 = _Tgt_state._Cur;
4436  ++_Res0;
4437  _It _Resx;
4440  if (_Node->_Coll
4441  && (_Resx = _Lookup_coll(_Tgt_state._Cur, _End, _Node->_Coll))
4442  != _Tgt_state._Cur)
4443  { // check for collation element
4444  _Res0 = _Resx;
4445  _Found = true;
4446  }
4447  else if (_Node->_Ranges
4448  && (_Lookup_range((typename _RxTraits::_Uelem)
4450  ? _Traits.translate(_Ch)
4451  : _Ch), _Node->_Ranges)))
4452  _Found = true;
4453  else if (_Ch < _Bmp_max)
4454  _Found = _Node->_Small && _Node->_Small->_Find(_Ch);
4455  else if (_Node->_Large
4456  && _STD find(_Node->_Large->_Str(),
4457  _Node->_Large->_Str() + _Node->_Large->_Size(), _Ch)
4458  != _Node->_Large->_Str() + _Node->_Large->_Size())
4459  _Found = true;
4460  else if (_Node->_Classes != 0 && _Traits.isctype(_Ch, _Node->_Classes))
4461  _Found = true;
4462  else if (_Node->_Equiv && _Lookup_equiv(_Ch, _Node->_Equiv, _Traits))
4463  _Found = true;
4464  else
4465  _Found = false;
4466  if (_Found == (_Node->_Flags & _Fl_negate))
4467  return (false);
4468  else
4469  { // record result
4470  _Tgt_state._Cur = _Res0;
4471  return (true);
4472  }
4473  }
_BidIt _Cur
Definition: regex:1992
Definition: regex:1795
bool _Lookup_equiv(typename _RxTraits::_Uelem _Ch, const _Sequence< _Elem > *_Eq, const _RxTraits &_Traits)
Definition: regex:4380
const _RxTraits & _Traits
Definition: regex:2143
_It _End
Definition: regex:2134
Definition: regex:1510
_Sequence< _Elem > * _Equiv
Definition: regex:1829
regex_constants::syntax_option_type _Sflags
Definition: regex:2137
_Sequence< _Elem > * _Coll
Definition: regex:1824
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_Buf< _Elem > * _Ranges
Definition: regex:1827
bool _Find(_Elem _Ch) const
Definition: regex:1646
_BidIt _Lookup_coll(_BidIt _First, _BidIt _Last, const _Sequence< _Elem > *_Eq)
Definition: regex:4403
_Bitmap * _Small
Definition: regex:1825
Definition: regex:107
_RxTraits::char_class_type _Classes
Definition: regex:1828
_Node_flags _Flags
Definition: regex:1681
Definition: regex:110
_Buf< _Elem > * _Large
Definition: regex:1826
const unsigned int _Bmp_max
Definition: regex:1498
bool _Lookup_range(unsigned int _Ch, const _Buf< _Elem > *_Bufptr)
Definition: regex:4366
_InIt find(_InIt _First, _InIt _Last, const _Ty &_Val)
Definition: xutility:3185
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Do_if ( _Node_if _Node)
inlineprivate
4155  { // apply if node
4157 
4158  // look for the first match
4159  for (; _Node; _Node = _Node->_Child)
4160  { // process one branch of if
4161  _Tgt_state = _St; // rewind to where the alternation starts in input
4162  if (_Match_pat(_Node->_Next)) // try to match this branch
4163  break;
4164  }
4165 
4166  // if none of the if branches matched, fail to match
4167  if (!_Node)
4168  return (false);
4169 
4170  // if we aren't looking for the longest match, that's it
4171  if (!_Longest)
4172  return (true);
4173 
4174  // see if there is a longer match
4175  _Tgt_state_t<_It> _Final = _Tgt_state;
4176  size_t _Final_len = _STD distance(_St._Cur, _Tgt_state._Cur);
4177  for (;;)
4178  { // process one branch of if
4179  _Node = _Node->_Child;
4180  if (!_Node)
4181  break;
4182 
4183  _Tgt_state = _St;
4184  if (_Match_pat(_Node->_Next))
4185  { // record match if it is longer
4186  size_t _Len = _STD distance(_St._Cur, _Tgt_state._Cur);
4187  if (_Final_len < _Len)
4188  { // memorize longest so far
4189  _Final = _Tgt_state;
4190  _Final_len = _Len;
4191  }
4192  }
4193  }
4194 
4195  // set the input end to the longest match
4196  _Tgt_state = _Final;
4197  return (true);
4198  }
_BidIt _Cur
Definition: regex:1992
_Node_base * _Next
Definition: regex:1682
bool _Longest
Definition: regex:2142
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
_Iter_diff_t< _InIt > distance(_InIt _First, _InIt _Last)
Definition: xutility:1111
bool _Match_pat(_Node_base *)
Definition: regex:4533
_Node_if * _Child
Definition: regex:1866
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Do_rep ( _Node_rep _Node,
bool  _Greedy,
int  _Init_idx 
)
inlineprivate
4269  { // apply repetition
4270  if (_Node->_Simple_loop == 1)
4271  return (_Do_rep0(_Node, _Greedy));
4272 
4273  bool _Matched0 = false;
4275  _Loop_vals_t *_Psav = &_Loop_vals[_Node->_Loop_number];
4276  int _Loop_idx_sav = _Psav->_Loop_idx;
4277  _It *_Loop_iter_sav = (_It *)_Psav->_Loop_iter;
4278  _It _Cur_iter = _Tgt_state._Cur;
4279 
4280  bool _Progress = _Init_idx == 0 || *_Loop_iter_sav != _Cur_iter;
4281 
4282  if (0 <= _Node->_Max && _Node->_Max <= _Init_idx)
4283  _Matched0 = _Match_pat(_Node->_End_rep->_Next); // reps done, try tail
4284  else if (_Init_idx < _Node->_Min)
4285  { // try a required rep
4286  if (!_Progress)
4287  _Matched0 = _Match_pat(_Node->_End_rep->_Next); // empty, try tail
4288  else
4289  { // try another required match
4290  _Psav->_Loop_idx = _Init_idx + 1;
4291  _Psav->_Loop_iter = &_Cur_iter;
4292  _Matched0 = _Match_pat(_Node->_Next);
4293  }
4294  }
4295  else if (!_Greedy)
4296  { // not greedy, favor minimum number of reps
4297  _Matched0 = _Match_pat(_Node->_End_rep->_Next);
4298  if (!_Matched0 && _Progress)
4299  { // tail failed, try another rep
4300  _Tgt_state = _St;
4301  _Psav->_Loop_idx = _Init_idx + 1;
4302  _Psav->_Loop_iter = &_Cur_iter;
4303  _Matched0 = _Match_pat(_Node->_Next);
4304  }
4305  }
4306  else
4307  { // greedy, favor maximum number of reps
4308  if (_Progress)
4309  { // try another rep
4310  _Psav->_Loop_idx = _Init_idx + 1;
4311  _Psav->_Loop_iter = &_Cur_iter;
4312  _Matched0 = _Match_pat(_Node->_Next);
4313  }
4314  if (!_Progress && 1 < _Init_idx)
4315  ;
4316  else if (!_Matched0)
4317  { // rep failed, try tail
4318  _Psav->_Loop_idx = _Loop_idx_sav;
4319  _Psav->_Loop_iter = _Loop_iter_sav;
4320  _Tgt_state = _St;
4321  _Matched0 = _Match_pat(_Node->_End_rep->_Next);
4322  }
4323  }
4324 
4325  if (!_Matched0)
4326  _Tgt_state = _St;
4327  _Psav->_Loop_idx = _Loop_idx_sav;
4328  _Psav->_Loop_iter = _Loop_iter_sav;
4329  return (_Matched0);
4330  }
_BidIt _Cur
Definition: regex:1992
_Node_base * _Next
Definition: regex:1682
const int _Max
Definition: regex:1912
unsigned int _Loop_number
Definition: regex:1914
if(_Source==NULL||_DestinationSize< _SourceSize)
Definition: corecrt_memcpy_s.h:48
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
int _Loop_idx
Definition: regex:1891
vector< _Loop_vals_t > _Loop_vals
Definition: regex:2121
bool _Match_pat(_Node_base *)
Definition: regex:4533
int _Simple_loop
Definition: regex:1915
Definition: regex:1889
void * _Loop_iter
Definition: regex:1892
bool _Do_rep0(_Node_rep *, bool)
Definition: regex:4204
_Node_end_rep * _End_rep
Definition: regex:1913
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Do_rep0 ( _Node_rep _Node,
bool  _Greedy 
)
inlineprivate
4206  { // apply repetition to loop with no nested if/do
4207  int _Ix = 0;
4209 
4210  for (; _Ix < _Node->_Min; ++_Ix)
4211  { // do minimum number of reps
4212  _It _Cur = _Tgt_state._Cur;
4213  if (!_Match_pat(_Node->_Next))
4214  { // didn't match minimum number of reps, fail
4215  _Tgt_state = _St;
4216  return (false);
4217  }
4218  else if (_Cur == _Tgt_state._Cur)
4219  _Ix = _Node->_Min - 1; // skip matches that don't change state
4220  }
4221 
4222  _Tgt_state_t<_It> _Final = _Tgt_state;
4223  bool _Matched0 = false;
4224  _It _Saved_pos = _Tgt_state._Cur;
4225 
4226  if (!_Match_pat(_Node->_End_rep->_Next))
4227  ; // no full match yet
4228  else if (!_Greedy)
4229  return (true); // go with current match
4230  else
4231  { // record an acceptable match and continue
4232  _Final = _Tgt_state;
4233  _Matched0 = true;
4234  }
4235 
4236  while (_Node->_Max == -1 || _Ix++ < _Node->_Max)
4237  { // try another rep/tail match
4238  _Tgt_state._Cur = _Saved_pos;
4240  if (!_Match_pat(_Node->_Next))
4241  break; // rep match failed, quit loop
4242 
4243  _It _Mid = _Tgt_state._Cur;
4244  if (!_Match_pat(_Node->_End_rep->_Next))
4245  ; // tail match failed, continue
4246  else if (!_Greedy)
4247  return (true); // go with current match
4248  else
4249  { // record match and continue
4250  _Final = _Tgt_state;
4251  _Matched0 = true;
4252  }
4253 
4254  if (_Saved_pos == _Mid)
4255  break; // rep match ate no additional elements, quit loop
4256  _Saved_pos = _Mid;
4257  }
4258 
4259  _Tgt_state = _Matched0 ? _Final : _St;
4260  return (_Matched0);
4261  }
_BidIt _Cur
Definition: regex:1992
_Node_base * _Next
Definition: regex:1682
const int _Max
Definition: regex:1912
vector< bool > _Grp_valid
Definition: regex:1993
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
const int _Min
Definition: regex:1911
bool _Match_pat(_Node_base *)
Definition: regex:4533
_Node_end_rep * _End_rep
Definition: regex:1913
template<class _BidIt , class _Elem , class _RxTraits , class _It >
unsigned int _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Get_ncap ( ) const
inlineprivate
4525  {
4526  return (static_cast<unsigned int>(_Ncap));
4527  }
int _Ncap
Definition: regex:2141
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Is_wbound ( ) const
inlineprivate
4502  { // test if _Tgt_state._Cur is a word boundary
4504  || _Tgt_state._Cur != _Begin)
4505  { // if --_Cur is valid, check for preceding word character
4506  if (_Tgt_state._Cur == _End)
4508  else
4510  }
4511  else
4512  { // --_Cur is not valid
4513  if (_Tgt_state._Cur == _End)
4514  return ((_Mflags & (regex_constants::match_not_bow | regex_constants::match_not_eow)) == 0);
4515  else
4517  }
4518  }
_BidIt _Cur
Definition: regex:1992
regex_constants::match_flag_type _Mflags
Definition: regex:2138
_It _End
Definition: regex:2134
_It _Begin
Definition: regex:2133
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
_BidIt prev(_BidIt _First, _Iter_diff_t< _BidIt > _Off=1)
Definition: xutility:1129
bool _Is_word(unsigned char _UCh)
Definition: regex:610
Definition: regex:120
Definition: regex:121
template<class _BidIt , class _Elem , class _RxTraits , class _It >
template<class _Alloc >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Match ( _It  _Pfirst,
match_results< _BidIt, _Alloc > *  _Matches,
bool  _Full_match 
)
inline
2052  { // try to match
2053  _First = _Pfirst;
2054  return (_Match(_Matches, _Full_match));
2055  }
_RanIt _Pfirst
Definition: algorithm:2576
_It _First
Definition: regex:2135
bool _Match(_It _Pfirst, match_results< _BidIt, _Alloc > *_Matches, bool _Full_match)
Definition: regex:2049
template<class _BidIt , class _Elem , class _RxTraits , class _It >
template<class _Alloc >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Match ( match_results< _BidIt, _Alloc > *  _Matches,
bool  _Full_match 
)
inline
2060  { // try to match
2061  if (_Matches)
2062  { // clear _Matches before doing work
2063  _Matches->_Ready = true;
2064  _Matches->_Resize(0);
2065  }
2066 
2067  _Begin = _First;
2070  _Tgt_state._Grps.resize(_Get_ncap());
2071  _Cap = _Matches != 0;
2072  _Full = _Full_match;
2075 
2076  _Matched = false;
2077 
2078  if (!_Match_pat(_Rep))
2079  return (false);
2080 
2081  if (_Matches)
2082  { // copy results to _Matches
2083  _Matches->_Resize(_Get_ncap());
2084  for (unsigned int _Idx = 0; _Idx < _Get_ncap(); ++_Idx)
2085  { // copy submatch _Idx
2086  if (_Res._Grp_valid[_Idx])
2087  { // copy successful match
2088  _Matches->_At(_Idx).matched = true;
2089  _Matches->_At(_Idx).first = _Res._Grps[_Idx]._Begin;
2090  _Matches->_At(_Idx).second = _Res._Grps[_Idx]._End;
2091  }
2092  else
2093  { // copy failed match
2094  _Matches->_At(_Idx).matched = false;
2095  _Matches->_At(_Idx).first = _End;
2096  _Matches->_At(_Idx).second = _End;
2097  }
2098  }
2099  _Matches->_Org = _Begin;
2100  _Matches->_Pfx().first = _Begin;
2101  _Matches->_Pfx().second = _Matches->_At(0).first;
2102  _Matches->_Pfx().matched =
2103  _Matches->_Pfx().first != _Matches->_Pfx().second;
2104 
2105  _Matches->_Sfx().first = _Matches->_At(0).second;
2106  _Matches->_Sfx().second = _End;
2107  _Matches->_Sfx().matched =
2108  _Matches->_Sfx().first != _Matches->_Sfx().second;
2109 
2110  _Matches->_Null().first = _End;
2111  _Matches->_Null().second = _End;
2112  }
2113  return (true);
2114  }
_Ty2 second
Definition: utility:271
_Node_base * _Rep
Definition: regex:2136
bool _Cap
Definition: regex:2140
_BidIt _Org
Definition: regex:1456
_BidIt _Cur
Definition: regex:1992
_It _End
Definition: regex:2134
bool matched
Definition: regex:664
_It _Begin
Definition: regex:2133
vector< bool > _Grp_valid
Definition: regex:1993
vector< _Grp_t > _Grps
Definition: regex:2008
_Elem & _Null()
Definition: regex:1441
bool _Full
Definition: regex:2144
bool _Matched
Definition: regex:2139
#define _REGEX_MAX_STACK_COUNT
Definition: regex:35
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
_Ty1 first
Definition: utility:270
_Elem & _At(unsigned int _Sub)
Definition: regex:1446
unsigned int _Get_ncap() const
Definition: regex:4524
#define _REGEX_MAX_COMPLEXITY_COUNT
Definition: regex:28
_Tgt_state_t< _It > _Res
Definition: regex:2120
bool _Match_pat(_Node_base *)
Definition: regex:4533
_Elem & _Pfx()
Definition: regex:1431
void resize(_CRT_GUARDOVERFLOW const size_type _Newsize)
Definition: vector:1489
void _Resize(unsigned int _Nx)
Definition: regex:1426
_It _First
Definition: regex:2135
long _Max_stack_count
Definition: regex:2146
bool _Ready
Definition: regex:1457
_Elem & _Sfx()
Definition: regex:1436
long _Max_complexity_count
Definition: regex:2145
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Match_pat ( _Node_base _Nx)
inlineprivate
4535  { // check for match
4536  if (0 < _Max_stack_count && --_Max_stack_count <= 0)
4538  if (0 < _Max_complexity_count && --_Max_complexity_count <= 0)
4540 
4541  bool _Failed = false;
4542  while (_Nx != 0)
4543  { // match current node
4544  switch (_Nx->_Kind)
4545  { // handle current node's type
4546  case _N_nop:
4547  break;
4548 
4549  case _N_bol:
4551  || _Tgt_state._Cur != _Begin)
4552  { // if --_Cur is valid, check for preceding newline
4553  _Failed = *_STD prev(_Tgt_state._Cur) != _Meta_nl;
4554  }
4555  else
4556  _Failed = (_Mflags & regex_constants::match_not_bol) != 0;
4557  break;
4558 
4559  case _N_eol:
4560  if (_Tgt_state._Cur == _End)
4561  _Failed = (_Mflags & regex_constants::match_not_eol) != 0;
4562  else
4563  _Failed = *_Tgt_state._Cur != _Meta_nl;
4564  break;
4565 
4566  case _N_wbound:
4567  _Failed = _Is_wbound() == ((_Nx->_Flags & _Fl_negate) != 0);
4568  break;
4569 
4570  case _N_dot:
4571  if (_Tgt_state._Cur == _End
4572  || *_Tgt_state._Cur == _Meta_nl
4573  || *_Tgt_state._Cur == _Meta_cr)
4574  _Failed = true;
4575  else
4576  ++_Tgt_state._Cur;
4577  break;
4578 
4579  case _N_str:
4580  { // check for string match
4581  _Node_str<_Elem> *_Node = (_Node_str<_Elem> *)_Nx;
4582  _It _Res0;
4583  if ((_Res0 = _Compare(_Tgt_state._Cur, _End,
4584  _Node->_Data._Str(),
4585  _Node->_Data._Str() + _Node->_Data._Size(),
4586  _Traits, _Sflags))
4587  != _Tgt_state._Cur)
4588  _Tgt_state._Cur = _Res0;
4589  else
4590  _Failed = true;
4591  break;
4592  }
4593 
4594  case _N_class:
4595  { // check for bracket expression match
4596  _Failed = _Tgt_state._Cur == _End
4597  || !_Do_class(_Nx);
4598  break;
4599  }
4600 
4601  case _N_group:
4602  break;
4603 
4604  case _N_end_group:
4605  break;
4606 
4607  case _N_neg_assert:
4608  case _N_assert:
4609  { // check assert
4610  _It _Ch = _Tgt_state._Cur;
4611  bool _Neg = _Nx->_Kind == _N_neg_assert;
4613  if (_Match_pat(((_Node_assert *)_Nx)->_Child) == _Neg)
4614  { // restore initial state and indicate failure
4615  _Tgt_state = _St;
4616  _Failed = true;
4617  }
4618  else
4619  _Tgt_state._Cur = _Ch;
4620  break;
4621  }
4622 
4623  case _N_end_assert:
4624  _Nx = 0;
4625  break;
4626 
4627  case _N_capture:
4628  { // record current position
4629  _Node_capture *_Node = (_Node_capture *)_Nx;
4630  _Tgt_state._Grps[_Node->_Idx]._Begin = _Tgt_state._Cur;
4631  for (size_t _Idx = _Tgt_state._Grp_valid.size();
4632  _Node->_Idx < _Idx; )
4633  _Tgt_state._Grp_valid[--_Idx] = false;
4634  break;
4635  }
4636 
4637  case _N_end_capture:
4638  { // record successful capture
4639  _Node_end_group *_Node = (_Node_end_group *)_Nx;
4640  _Node_capture *_Node0 = (_Node_capture *)_Node->_Back;
4641  if (_Cap || _Node0->_Idx != 0)
4642  { // update capture data
4643  _Tgt_state._Grp_valid[_Node0->_Idx] = true;
4644  _Tgt_state._Grps[_Node0->_Idx]._End = _Tgt_state._Cur;
4645  }
4646  break;
4647  }
4648 
4649  case _N_back:
4650  { // check back reference
4651  _Node_back *_Node = (_Node_back *)_Nx;
4652  if (_Tgt_state._Grp_valid[_Node->_Idx])
4653  { // check for match
4654  _It _Res0 = _Tgt_state._Cur;
4655  _It _Bx = _Tgt_state._Grps[_Node->_Idx]._Begin;
4656  _It _Ex = _Tgt_state._Grps[_Node->_Idx]._End;
4657  if (_Bx != _Ex // _Bx == _Ex for zero-length match
4658  && (_Res0 = _Compare(_Tgt_state._Cur, _End,
4659  _Bx, _Ex, _Traits, _Sflags))
4660  == _Tgt_state._Cur)
4661  _Failed = true;
4662  else
4663  _Tgt_state._Cur = _Res0;
4664  }
4665  break;
4666  }
4667 
4668  case _N_if:
4669  if (!_Do_if((_Node_if *)_Nx))
4670  _Failed = true;
4671  _Nx = 0;
4672  break;
4673 
4674  case _N_endif:
4675  break;
4676 
4677  case _N_rep:
4678  if (!_Do_rep((_Node_rep *)_Nx,
4679  (_Nx->_Flags & _Fl_greedy) != 0, 0))
4680  _Failed = true;
4681  _Nx = 0;
4682  break;
4683 
4684  case _N_end_rep:
4685  { // return at end of loop
4686  _Node_rep *_Nr = ((_Node_end_rep *)_Nx)->_Begin_rep;
4687  _Loop_vals_t *_Psav = &_Loop_vals[_Nr->_Loop_number];
4688 
4689  if (_Nr->_Simple_loop == 0 && !_Do_rep(_Nr,
4690  (_Nr->_Flags & _Fl_greedy) != 0, _Psav->_Loop_idx))
4691  _Failed = true; // recurse only if loop contains if/do
4692  _Nx = 0;
4693  break;
4694  }
4695 
4696  case _N_begin:
4697  break;
4698 
4699  case _N_end:
4702  && _Begin == _Tgt_state._Cur)
4703  || (_Full && _Tgt_state._Cur != _End))
4704  _Failed = true;
4705  else if (!_Matched || _Better_match())
4706  { // record successful match
4707  _Res = _Tgt_state;
4708  _Matched = true;
4709  }
4710  _Nx = 0;
4711  break;
4712 
4713  default:
4715  }
4716 
4717  if (_Failed)
4718  _Nx = 0;
4719  else if (_Nx)
4720  _Nx = _Nx->_Next;
4721  }
4722 
4723  if (0 < _Max_stack_count)
4724  ++_Max_stack_count;
4725  return (!_Failed);
4726  }
Definition: regex:118
Definition: regex:149
bool _Cap
Definition: regex:2140
Definition: regex:1511
Definition: regex:150
_BidIt _Cur
Definition: regex:1992
Definition: regex:1539
Definition: regex:1537
Definition: regex:1538
Definition: regex:1545
_Node_base * _Next
Definition: regex:1682
Definition: regex:1552
_Buf< _Elem > _Data
Definition: regex:1789
Definition: regex:1780
const _RxTraits & _Traits
Definition: regex:2143
regex_constants::match_flag_type _Mflags
Definition: regex:2138
Definition: regex:1541
_It _End
Definition: regex:2134
Definition: regex:1753
_It _Begin
Definition: regex:2133
Definition: regex:123
Definition: regex:1844
Definition: regex:1510
Definition: regex:1549
Definition: regex:1544
vector< bool > _Grp_valid
Definition: regex:1993
regex_constants::syntax_option_type _Sflags
Definition: regex:2137
unsigned int _Loop_number
Definition: regex:1914
vector< _Grp_t > _Grps
Definition: regex:2008
_Node_base * _Back
Definition: regex:1731
Definition: regex:1554
bool _Full
Definition: regex:2144
if(_Source==NULL||_DestinationSize< _SourceSize)
Definition: corecrt_memcpy_s.h:48
bool _Matched
Definition: regex:2139
Definition: regex:1543
_Tgt_state_t< _It > _Tgt_state
Definition: regex:2119
bool _Is_wbound() const
Definition: regex:4501
Definition: regex:1542
int _Loop_idx
Definition: regex:1891
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_BidIt1 _Compare(_BidIt1 _Begin1, _BidIt1 _End1, _BidIt2 _Begin2, _BidIt2 _End2, const _RxTraits &_Traits, regex_constants::syntax_option_type _Sflags)
Definition: regex:4348
Definition: regex:1536
vector< _Loop_vals_t > _Loop_vals
Definition: regex:2121
size_type size() const _NOEXCEPT
Definition: vector:1708
_Tgt_state_t< _It > _Res
Definition: regex:2120
bool _Match_pat(_Node_base *)
Definition: regex:4533
int _Simple_loop
Definition: regex:1915
bool _Better_match()
Definition: regex:4479
_BidIt prev(_BidIt _First, _Iter_diff_t< _BidIt > _Off=1)
Definition: xutility:1129
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xregex_error(regex_constants::error_type _Code)
Definition: regex:1551
unsigned int _Idx
Definition: regex:1762
Definition: regex:74
Definition: regex:1722
_Node_flags _Flags
Definition: regex:1681
Definition: regex:1766
long _Max_stack_count
Definition: regex:2146
bool _Do_rep(_Node_rep *, bool, int)
Definition: regex:4267
Definition: regex:1553
_Node_type _Kind
Definition: regex:1680
unsigned int _Idx
Definition: regex:1775
Definition: regex:1547
Definition: regex:1889
Definition: regex:1548
Definition: regex:1540
Definition: regex:1550
Definition: regex:1872
Definition: regex:75
Definition: regex:1896
bool _Do_class(_Node_base *)
Definition: regex:4428
bool _Do_if(_Node_if *)
Definition: regex:4153
Definition: regex:1534
Definition: regex:1535
Definition: regex:1735
long _Max_complexity_count
Definition: regex:2145
Definition: regex:1546
Definition: regex:119
template<class _BidIt , class _Elem , class _RxTraits , class _It >
void _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Setf ( regex_constants::match_flag_type  _Mf)
inline
2039  { // set specified flags
2040  _Mflags |= _Mf;
2041  }
regex_constants::match_flag_type _Mflags
Definition: regex:2138
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_BidIt _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Skip ( _BidIt  _First_arg,
_BidIt  _Last,
_Node_base _Node_arg = 0 
)
inline
4734  { // skip until possible match
4735  // assumes --_First_arg is valid
4736  _Node_base *_Nx = _Node_arg != 0 ? _Node_arg : _Rep;
4737 
4738  while (_First_arg != _Last && _Nx != 0)
4739  { // check current node
4740  switch (_Nx->_Kind)
4741  { // handle current node's type
4742  case _N_nop:
4743  break;
4744 
4745  case _N_bol:
4746  { // check for embedded newline
4747  // return iterator to character just after the newline; for input like "\nabc"
4748  // matching "^abc", _First_arg could be pointing at 'a', so we need to check
4749  // --_First_arg for '\n'
4750  if (*_STD prev(_First_arg) != _Meta_nl)
4751  {
4752  _First_arg = _STD find(_First_arg, _Last, _Meta_nl);
4753  if (_First_arg != _Last)
4754  ++_First_arg;
4755  }
4756 
4757  return (_First_arg);
4758  }
4759 
4760  case _N_eol:
4761  return (_STD find(_First_arg, _Last, _Meta_nl));
4762 
4763 // case _N_wbound:
4764 // case _N_dot:
4765 
4766  case _N_str:
4767  { // check for string match
4768  _Node_str<_Elem> *_Node = (_Node_str<_Elem> *)_Nx;
4769  for (; _First_arg != _Last; ++_First_arg)
4770  { // look for starting match
4771  _BidIt _Next = _First_arg;
4772  if (_Compare(_First_arg, ++_Next,
4773  _Node->_Data._Str(),
4774  _Node->_Data._Str() + 1,
4775  _Traits, _Sflags)
4776  != _First_arg)
4777  break;
4778  }
4779  return (_First_arg);
4780  }
4781 
4782  case _N_class:
4783  { // check for string match
4784  for (; _First_arg != _Last; ++_First_arg)
4785  { // look for starting match
4786  bool _Found;
4787  typename _RxTraits::_Uelem _Ch = *_First_arg;
4790  _It _Next = _First_arg;
4791  ++_Next;
4792 
4793  if (_Node->_Coll
4794  && _Lookup_coll(_First_arg, _Next, _Node->_Coll)
4795  != _First_arg)
4796  _Found = true;
4797  else if (_Node->_Ranges
4798  && (_Lookup_range((typename _RxTraits::_Uelem)
4800  ? _Traits.translate(_Ch)
4801  : _Ch), _Node->_Ranges)))
4802  _Found = true;
4803  else if (_Ch < _Bmp_max)
4804  _Found = _Node->_Small && _Node->_Small->_Find(_Ch);
4805  else if (_Node->_Large
4806  && _STD find(_Node->_Large->_Str(),
4807  _Node->_Large->_Str() + _Node->_Large->_Size(),
4808  _Ch)
4809  != _Node->_Large->_Str() + _Node->_Large->_Size())
4810  _Found = true;
4811  else if (_Node->_Classes
4812  && _Traits.isctype(_Ch, _Node->_Classes))
4813  _Found = true;
4814  else if (_Node->_Equiv
4815  && _Lookup_equiv(_Ch, _Node->_Equiv, _Traits))
4816  _Found = true;
4817  else
4818  _Found = false;
4819 
4820  if (_Found != (_Node->_Flags & _Fl_negate))
4821  return (_First_arg);
4822  }
4823  }
4824  return (_First_arg);
4825 
4826  case _N_group:
4827  break;
4828 
4829  case _N_end_group:
4830  break;
4831 
4832 // case _N_neg_assert:
4833 // case _N_assert:
4834 
4835  case _N_end_assert:
4836  _Nx = 0;
4837  break;
4838 
4839  case _N_capture:
4840  break;
4841 
4842  case _N_end_capture:
4843  break;
4844 
4845 // case _N_back:
4846 
4847  case _N_if:
4848  { // check for soonest string match
4849  _Node_if *_Node = (_Node_if *)_Nx;
4850 
4851  for (; _First_arg != _Last && _Node != 0;
4852  _Node = _Node->_Child)
4853  _Last = _Skip(_First_arg, _Last, _Node->_Next);
4854  return (_Last);
4855  }
4856 
4857 // case _N_endif:
4858 // case _N_rep:
4859 // case _N_end_rep:
4860 
4861  case _N_begin:
4862  break;
4863 
4864  case _N_end:
4865  _Nx = 0;
4866  break;
4867 
4868  default:
4869  return (_First_arg);
4870  }
4871  if (_Nx)
4872  _Nx = _Nx->_Next;
4873  }
4874  return (_First_arg);
4875  }
_Node_base * _Rep
Definition: regex:2136
_BidIt _Skip(_BidIt, _BidIt, _Node_base *=0)
Definition: regex:4732
Definition: regex:1539
Definition: regex:1795
Definition: regex:1545
_Node_base * _Next
Definition: regex:1682
_Buf< _Elem > _Data
Definition: regex:1789
bool _Lookup_equiv(typename _RxTraits::_Uelem _Ch, const _Sequence< _Elem > *_Eq, const _RxTraits &_Traits)
Definition: regex:4380
Definition: regex:1780
const _RxTraits & _Traits
Definition: regex:2143
Definition: regex:1541
Definition: regex:1844
Definition: regex:1510
Definition: regex:1549
_Sequence< _Elem > * _Equiv
Definition: regex:1829
regex_constants::syntax_option_type _Sflags
Definition: regex:2137
_Sequence< _Elem > * _Coll
Definition: regex:1824
Definition: regex:1554
Definition: regex:1542
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_BidIt1 _Compare(_BidIt1 _Begin1, _BidIt1 _End1, _BidIt2 _Begin2, _BidIt2 _End2, const _RxTraits &_Traits, regex_constants::syntax_option_type _Sflags)
Definition: regex:4348
Definition: regex:1536
_Buf< _Elem > * _Ranges
Definition: regex:1827
bool _Find(_Elem _Ch) const
Definition: regex:1646
_BidIt _Lookup_coll(_BidIt _First, _BidIt _Last, const _Sequence< _Elem > *_Eq)
Definition: regex:4403
_Bitmap * _Small
Definition: regex:1825
_BidIt prev(_BidIt _First, _Iter_diff_t< _BidIt > _Off=1)
Definition: xutility:1129
Definition: regex:74
_RxTraits::char_class_type _Classes
Definition: regex:1828
_Node_flags _Flags
Definition: regex:1681
Definition: regex:1553
_Node_type _Kind
Definition: regex:1680
Definition: regex:1547
Definition: regex:1540
_Node_if * _Child
Definition: regex:1866
Definition: regex:110
_Buf< _Elem > * _Large
Definition: regex:1826
const unsigned int _Bmp_max
Definition: regex:1498
Definition: regex:1534
Definition: regex:1535
_FwdIt _Last
Definition: algorithm:1936
Definition: regex:1546
bool _Lookup_range(unsigned int _Ch, const _Buf< _Elem > *_Bufptr)
Definition: regex:4366
_InIt find(_InIt _First, _InIt _Last, const _Ty &_Val)
Definition: xutility:3185
Definition: regex:1672
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_Matcher& _Matcher< _BidIt, _Elem, _RxTraits, _It >::operator= ( const _Matcher< _BidIt, _Elem, _RxTraits, _It > &  )
private

Member Data Documentation

template<class _BidIt , class _Elem , class _RxTraits , class _It >
_It _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Begin
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Cap
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_It _Matcher< _BidIt, _Elem, _RxTraits, _It >::_End
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_It _Matcher< _BidIt, _Elem, _RxTraits, _It >::_First
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Full
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Longest
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
vector<_Loop_vals_t> _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Loop_vals
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
bool _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Matched
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
long _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Max_complexity_count
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
long _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Max_stack_count
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
regex_constants::match_flag_type _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Mflags
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
int _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Ncap
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_Node_base* _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Rep
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_Tgt_state_t<_It> _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Res
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
regex_constants::syntax_option_type _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Sflags
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
_Tgt_state_t<_It> _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Tgt_state
private
template<class _BidIt , class _Elem , class _RxTraits , class _It >
const _RxTraits& _Matcher< _BidIt, _Elem, _RxTraits, _It >::_Traits
private

The documentation for this class was generated from the following file: