24 #ifndef NDN_UTIL_REGEX_REGEX_MATCHER_H 25 #define NDN_UTIL_REGEX_REGEX_MATCHER_H 27 #include "../../common.hpp" 28 #include "../../name.hpp" 32 class RegexBackrefManager;
37 class Error :
public std::runtime_error
42 :
std::runtime_error(what)
59 shared_ptr<RegexBackrefManager> backrefManager = shared_ptr<RegexBackrefManager>());
71 const std::vector<name::Component>&
93 recursiveMatch(
size_t matcherNo,
const Name&
name,
size_t offset,
size_t len);
120 shared_ptr<RegexBackrefManager> backrefManager)
141 if (recursiveMatch(0, name, offset, len))
143 for (
size_t i = offset; i < offset + len ; i++)
156 RegexMatcher::recursiveMatch(
size_t matcherNo,
const Name&
name,
size_t offset,
size_t len)
163 shared_ptr<RegexMatcher> matcher =
m_matchers[matcherNo];
167 if (matcher->match(name, offset, tried) &&
168 recursiveMatch(matcherNo + 1, name, offset + tried, len - tried))
180 #endif // NDN_UTIL_REGEX_REGEX_MATCHER_H virtual void compile()=0
Compile the regular expression to generate the more matchers when necessary.
Copyright (c) 2011-2015 Regents of the University of California.
Error(const std::string &what)
std::ostream & operator<<(std::ostream &os, const Data &data)
const RegexExprType m_type
const std::string & getExpr() const
const std::vector< name::Component > & getMatchResult() const
get the matched name components
RegexMatcher(const std::string &expr, const RegexExprType &type, shared_ptr< RegexBackrefManager > backrefManager=shared_ptr< RegexBackrefManager >())
shared_ptr< RegexBackrefManager > m_backrefManager
std::vector< shared_ptr< RegexMatcher > > m_matchers
std::vector< name::Component > m_matchResult
Name abstraction to represent an absolute name.
virtual bool match(const Name &name, size_t offset, size_t len)
const Component & get(ssize_t i) const
Get the component at the given index.