31 shared_ptr<RegexBackrefManager> backrefManager)
32 :
RegexMatcher(expr, EXPR_PATTERN_LIST, std::move(backrefManager))
38 RegexPatternListMatcher::compile()
40 size_t len =
m_expr.size();
42 size_t subHead = index;
47 if (!extractPattern(subHead, &index))
53 RegexPatternListMatcher::extractPattern(
size_t index,
size_t* next)
57 size_t indicator = index;
62 index = extractSubPattern(
'(',
')', index);
64 end = extractRepetition(index);
65 if (indicator == end) {
66 auto matcher = make_shared<RegexBackrefMatcher>(
m_expr.substr(start, end - start),
73 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
80 index = extractSubPattern(
'<',
'>', index);
82 end = extractRepetition(index);
83 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
89 index = extractSubPattern(
'[',
']', index);
91 end = extractRepetition(index);
92 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
105 RegexPatternListMatcher::extractSubPattern(
const char left,
const char right,
size_t index)
110 while (lcount > rcount) {
111 if (index >=
m_expr.size())
112 NDN_THROW(Error(
"Parenthesis mismatch"));
114 if (left ==
m_expr[index])
117 if (right ==
m_expr[index])
127 RegexPatternListMatcher::extractRepetition(
size_t index)
129 size_t exprSize =
m_expr.size();
131 if (index == exprSize)
138 if (
'{' ==
m_expr[index]) {
139 while (
'}' !=
m_expr[index]) {
141 if (index == exprSize)
144 if (index == exprSize)
145 NDN_THROW(Error(
"Missing closing brace"));
shared_ptr< RegexBackrefManager > m_backrefManager
std::vector< shared_ptr< RegexMatcher > > m_matchers
RegexPatternListMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)