8 #ifndef NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
9 #define NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
11 #include <boost/regex.hpp>
29 ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
35 match(
const Name & name,
const int & offset,
const int &len = 1);
47 boost::regex m_componentRegex;
48 std::vector<ptr_lib::shared_ptr<RegexPseudoMatcher> > m_pseudoMatcher;
55 ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
70 m_componentRegex = boost::regex (
m_expr);
72 m_pseudoMatcher.clear();
73 m_pseudoMatcher.push_back(ptr_lib::make_shared<RegexPseudoMatcher>());
75 for (
size_t i = 1; i < m_componentRegex.mark_count(); i++)
77 ptr_lib::shared_ptr<RegexPseudoMatcher> pMatcher = ptr_lib::make_shared<RegexPseudoMatcher>();
78 m_pseudoMatcher.push_back(pMatcher);
79 m_backrefManager->pushRef(ptr_lib::static_pointer_cast<RegexMatcher>(pMatcher));
101 boost::smatch subResult;
103 if (boost::regex_match(targetStr, subResult, m_componentRegex))
105 for (
size_t i = 1; i < m_componentRegex.mark_count(); i++)
107 m_pseudoMatcher[i]->resetMatchResult();
108 m_pseudoMatcher[i]->setMatchResult(subResult[i]);
125 #endif // NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
void toEscapedString(std::ostream &result) const
Write the value to result, escaping characters according to the NDN URI Scheme.
RegexComponentMatcher(const std::string &expr, ptr_lib::shared_ptr< RegexBackrefManager > backRefManager, bool exact=true)
Create a RegexComponent matcher from expr.
shared_ptr< RegexBackrefManager > m_backrefManager
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.
virtual bool match(const Name &name, const int &offset, const int &len=1)
virtual ~RegexComponentMatcher()
std::vector< name::Component > m_matchResult
A Name holds an array of Name::Component and represents an NDN name.
const Component & get(ssize_t i) const
Get the component at the given index.