24 #ifndef NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP 25 #define NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP 27 #include "../../common.hpp" 61 extractComponent(
size_t index);
64 compileSingleComponent();
67 compileMultipleComponents(
size_t start,
size_t lastIndex);
70 typedef std::set<shared_ptr<RegexComponentMatcher> > ComponentsSet;
71 ComponentsSet m_components;
78 shared_ptr<RegexBackrefManager> backrefManager)
99 return compileSingleComponent();
102 size_t lastIndex =
m_expr.size() - 1;
103 if (
']' !=
m_expr[lastIndex])
108 m_isInclusion =
false;
109 compileMultipleComponents(2, lastIndex);
112 compileMultipleComponents(1, lastIndex);
122 RegexComponentSetMatcher::compileSingleComponent()
124 size_t end = extractComponent(1);
132 shared_ptr<RegexComponentMatcher> component =
135 m_components.insert(component);
140 RegexComponentSetMatcher::compileMultipleComponents(
size_t start,
size_t lastIndex)
142 size_t index = start;
143 size_t tempIndex = start;
145 while (index < lastIndex) {
149 tempIndex = index + 1;
150 index = extractComponent(tempIndex);
152 shared_ptr<RegexComponentMatcher> component =
153 make_shared<RegexComponentMatcher>(
m_expr.substr(tempIndex, index - tempIndex - 1),
156 m_components.insert(component);
159 if (index != lastIndex)
166 bool isMatched =
false;
175 it != m_components.end();
178 if ((*it)->match(name, offset, len))
187 if (m_isInclusion ? isMatched : !isMatched)
197 RegexComponentSetMatcher::extractComponent(
size_t index)
202 while (lcount > rcount) {
225 #endif // NDN_UTIL_REGEX_COMPONENT_SET_MATCHER_HPP Copyright (c) 2011-2015 Regents of the University of California.
const Component & get(ssize_t i) const
Get the component at the given index.
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)