24 #ifndef NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP 25 #define NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP 27 #include "../../common.hpp" 33 class RegexBackrefManager;
51 extractPattern(
size_t index,
size_t* next);
54 extractSubPattern(
const char left,
const char right,
size_t index);
57 extractRepetition(
size_t index);
72 shared_ptr<RegexBackrefManager> backrefManager)
81 size_t len =
m_expr.size();
83 size_t subHead = index;
88 if (!extractPattern(subHead, &index))
94 RegexPatternListMatcher::extractPattern(
size_t index,
size_t* next)
98 size_t indicator = index;
103 index = extractSubPattern(
'(',
')', index);
105 end = extractRepetition(index);
106 if (indicator == end) {
107 shared_ptr<RegexMatcher> matcher =
115 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
121 index = extractSubPattern(
'<',
'>', index);
123 end = extractRepetition(index);
124 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
130 index = extractSubPattern(
'[',
']', index);
132 end = extractRepetition(index);
133 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
147 RegexPatternListMatcher::extractSubPattern(
const char left,
const char right,
size_t index)
152 while (lcount > rcount) {
154 if (index >=
m_expr.size())
157 if (left ==
m_expr[index])
160 if (right ==
m_expr[index])
169 RegexPatternListMatcher::extractRepetition(
size_t index)
171 size_t exprSize =
m_expr.size();
173 if (index == exprSize)
180 if (
'{' ==
m_expr[index]) {
181 while (
'}' !=
m_expr[index]) {
183 if (index == exprSize)
186 if (index == exprSize)
199 #endif // NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP Copyright (c) 2011-2015 Regents of the University of California.
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.
shared_ptr< RegexBackrefManager > m_backrefManager
RegexPatternListMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
std::vector< shared_ptr< RegexMatcher > > m_matchers
virtual ~RegexPatternListMatcher()