bool ixion::regex<T>::matchAt(T const &candidate,TIndex at) { LastCandidate = candidate; BackrefStack.clear(); if (ParsedRegex.get() == NULL) EX_THROW(regex,ECRE_NOPATTERN) if (ParsedRegex->match(BackrefStack,candidate,at)) { MatchIndex = at; MatchLength = ParsedRegex->subsequentMatchLength(); return true; } return false; }
bool ixion::regex<T>::match(T const &candidate,TIndex from) { LastCandidate = candidate; BackrefStack.clear(); if (ParsedRegex.get() == NULL) EX_THROW(regex,ECRE_NOPATTERN) for (TIndex index = from;index < candidate.size();index++) if (ParsedRegex->match(BackrefStack,candidate,index)) { MatchIndex = index; MatchLength = ParsedRegex->subsequentMatchLength(); return true; } return false; }
T ixion::regex<T>::backref_stack::get(TIndex number,T const &candidate) const { TIndex level = 0,next_index = 0; TIndex start; TIndex startlevel; typename internal_stack::const_iterator first = Stack.begin(),last = Stack.end(); while (first != last) { if (first->Type == backref_entry::OPEN) { if (number == next_index) { start = first->Index; startlevel = level; level++; break; } next_index++; level++; } if (first->Type == backref_entry::CLOSE) level--; first++; } if (first == last) EX_THROW(regex,ECRE_INVBACKREF) first++; while (first != last) { if (first->Type == backref_entry::OPEN) level++; if (first->Type == backref_entry::CLOSE) { level--; if (startlevel == level) return candidate.substr(start,first->Index - start); } first++; } EX_THROW(regex,ECRE_UNBALBACKREF) }
// Ideally DacNoImpl and DacError would be marked no-return, but that will require changing a bunch of existing // code to avoid "unreachable code" warnings. void DECLSPEC_NORETURN DacError_NoRet(HRESULT err) { EX_THROW(HRException, (err)); }
void DacError(HRESULT err) { EX_THROW(HRException, (err)); }
void DacNotImpl(void) { EX_THROW(HRException, (E_NOTIMPL)); }