8 #ifndef NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP
9 #define NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP
11 #include "../../common.hpp"
17 class RegexBackrefManager;
32 extractPattern(
int index,
int* next);
35 extractSubPattern(
const char left,
const char right,
size_t index);
38 extractRepetition(
size_t index);
60 const int len =
m_expr.size();
67 if (!extractPattern(subHead, &index))
73 RegexPatternListMatcher::extractPattern(
int index,
int* next)
77 const int start = index;
79 int indicator = index;
84 index = extractSubPattern(
'(',
')', index);
86 end = extractRepetition(index);
87 if (indicator == end){
88 shared_ptr<RegexMatcher> matcher = make_shared<RegexBackrefMatcher>(
m_expr.substr(start, end - start),
m_backrefManager);
100 index = extractSubPattern (
'<',
'>', index);
102 end = extractRepetition(index);
108 index = extractSubPattern (
'[',
']', index);
110 end = extractRepetition(index);
115 throw RegexMatcher::Error(
"Error: unexpected syntax");
124 RegexPatternListMatcher::extractSubPattern(
const char left,
const char right,
size_t index)
129 while(lcount > rcount){
131 if (index >=
m_expr.size())
132 throw RegexMatcher::Error(
"Error: parenthesis mismatch");
134 if (left ==
m_expr[index])
137 if (right ==
m_expr[index])
146 RegexPatternListMatcher::extractRepetition(
size_t index)
148 size_t exprSize =
m_expr.size();
150 if (index == exprSize)
157 if (
'{' ==
m_expr[index]){
158 while(
'}' !=
m_expr[index]){
160 if (index == exprSize)
163 if (index == exprSize)
164 throw RegexMatcher::Error(std::string(
"Error: RegexPatternListMatcher.ExtractRepetition(): ")
165 +
"Missing right brace bracket");
177 #endif // NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.
shared_ptr< RegexBackrefManager > m_backrefManager
virtual ~RegexPatternListMatcher()
std::vector< shared_ptr< RegexMatcher > > m_matcherList
RegexPatternListMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backRefManager)