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;
46 extractPattern(
size_t index,
size_t* next);
49 extractSubPattern(
const char left,
const char right,
size_t index);
52 extractRepetition(
size_t index);
64 shared_ptr<RegexBackrefManager> backrefManager)
73 size_t len =
m_expr.size();
75 size_t subHead = index;
80 if (!extractPattern(subHead, &index))
86 RegexPatternListMatcher::extractPattern(
size_t index,
size_t* next)
90 size_t indicator = index;
95 index = extractSubPattern(
'(',
')', index);
97 end = extractRepetition(index);
98 if (indicator == end) {
99 shared_ptr<RegexMatcher> matcher =
107 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
113 index = extractSubPattern(
'<',
'>', index);
115 end = extractRepetition(index);
116 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
122 index = extractSubPattern(
'[',
']', index);
124 end = extractRepetition(index);
125 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
139 RegexPatternListMatcher::extractSubPattern(
const char left,
const char right,
size_t index)
144 while (lcount > rcount) {
146 if (index >=
m_expr.size())
149 if (left ==
m_expr[index])
152 if (right ==
m_expr[index])
161 RegexPatternListMatcher::extractRepetition(
size_t index)
163 size_t exprSize =
m_expr.size();
165 if (index == exprSize)
172 if (
'{' ==
m_expr[index]) {
173 while (
'}' !=
m_expr[index]) {
175 if (index == exprSize)
178 if (index == exprSize)
190 #endif // NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP Copyright (c) 2013-2017 Regents of the University of California.
shared_ptr< RegexBackrefManager > m_backrefManager
RegexPatternListMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
std::vector< shared_ptr< RegexMatcher > > m_matchers
void compile() override
Compile the regular expression to generate the more matchers when necessary.