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>());
65 match(
const Name& name,
size_t offset,
size_t len);
71 const std::vector<name::Component>&
92 recursiveMatch(
size_t matcherNo,
const Name& name,
size_t offset,
size_t len);
119 shared_ptr<RegexBackrefManager> backrefManager)
140 if (recursiveMatch(0, name, offset, len))
142 for (
size_t i = offset; i < offset + len ; i++)
155 RegexMatcher::recursiveMatch(
size_t matcherNo,
const Name& name,
size_t offset,
size_t len)
162 shared_ptr<RegexMatcher> matcher =
m_matchers[matcherNo];
166 if (matcher->match(name, offset, tried) &&
167 recursiveMatch(matcherNo + 1, name, offset + tried, len - tried))
179 #endif // NDN_UTIL_REGEX_REGEX_MATCHER_H virtual void compile()=0
Compile the regular expression to generate the more matchers when necessary.
Copyright (c) 2013-2017 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
Represents 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.