8 #ifndef NDN_UTIL_REGEX_REGEX_MATCHER_H
9 #define NDN_UTIL_REGEX_REGEX_MATCHER_H
11 #include "../../common.hpp"
12 #include "../../name.hpp"
16 class RegexBackrefManager;
21 class Error :
public std::runtime_error
26 : std::runtime_error(what)
47 shared_ptr<RegexBackrefManager> backrefManager = shared_ptr<RegexBackrefManager>());
53 match(
const Name& name,
const int& offset,
const int& len);
59 const std::vector<name::Component>&
77 recursiveMatch(
size_t mId,
const Name& name,
size_t offset,
size_t len);
97 shared_ptr<RegexBackrefManager> backrefManager)
100 m_backrefManager(backrefManager)
119 if (recursiveMatch(0, name, offset, len))
121 for(
int i = offset; i < offset + len ; i++)
135 RegexMatcher::recursiveMatch(
size_t mId,
const Name& name,
size_t offset,
size_t len)
142 return (len != 0 ?
false :
true);
148 if (matcher->match(name, offset, tried) && recursiveMatch(mId + 1, name, offset + tried, len - tried))
160 #endif // NDN_UTIL_REGEX_REGEX_MATCHER_H
virtual void compile()=0
Compile the regular expression to generate the more matchers when necessary.
Error(const std::string &what)
const RegexExprType m_type
const std::string & getExpr() const
const std::vector< name::Component > & getMatchResult() const
get the matched name components
virtual bool match(const Name &name, const int &offset, const int &len)
RegexMatcher(const std::string &expr, const RegexExprType &type, shared_ptr< RegexBackrefManager > backrefManager=shared_ptr< RegexBackrefManager >())
shared_ptr< RegexBackrefManager > m_backrefManager
std::vector< name::Component > m_matchResult
A Name holds an array of Name::Component and represents an NDN name.
std::vector< shared_ptr< RegexMatcher > > m_matcherList
const Component & get(ssize_t i) const
Get the component at the given index.