24 #ifndef NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP 25 #define NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP 27 #include "../../common.hpp" 62 extractComponent(
size_t index);
65 compileSingleComponent();
68 compileMultipleComponents(
size_t start,
size_t lastIndex);
71 typedef std::set<shared_ptr<RegexComponentMatcher> > ComponentsSet;
72 ComponentsSet m_components;
79 shared_ptr<RegexBackrefManager> backrefManager)
100 return compileSingleComponent();
103 size_t lastIndex =
m_expr.size() - 1;
104 if (
']' !=
m_expr[lastIndex])
109 m_isInclusion =
false;
110 compileMultipleComponents(2, lastIndex);
113 compileMultipleComponents(1, lastIndex);
123 RegexComponentSetMatcher::compileSingleComponent()
125 size_t end = extractComponent(1);
133 shared_ptr<RegexComponentMatcher> component =
136 m_components.insert(component);
141 RegexComponentSetMatcher::compileMultipleComponents(
size_t start,
size_t lastIndex)
143 size_t index = start;
144 size_t tempIndex = start;
146 while (index < lastIndex) {
150 tempIndex = index + 1;
151 index = extractComponent(tempIndex);
153 shared_ptr<RegexComponentMatcher> component =
154 make_shared<RegexComponentMatcher>(
m_expr.substr(tempIndex, index - tempIndex - 1),
157 m_components.insert(component);
160 if (index != lastIndex)
167 bool isMatched =
false;
176 it != m_components.end();
179 if ((*it)->match(name, offset, len))
188 if (m_isInclusion ? isMatched : !isMatched)
198 RegexComponentSetMatcher::extractComponent(
size_t index)
203 while (lcount > rcount) {
226 #endif // NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP Copyright (c) 2011-2015 Regents of the University of California.
virtual ~RegexComponentSetMatcher()
Table::const_iterator iterator
shared_ptr< RegexBackrefManager > m_backrefManager
std::vector< name::Component > m_matchResult
Name abstraction to represent an absolute name.
RegexComponentSetMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
Create a RegexComponentSetMatcher matcher from expr.
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.
virtual bool match(const Name &name, size_t offset, size_t len=1)
const Component & get(ssize_t i) const
Get the component at the given index.