30 shared_ptr<RegexBackrefManager> backrefManager,
32 :
RegexMatcher(expr, EXPR_COMPONENT, std::move(backrefManager))
33 , m_isExactMatch(isExactMatch)
39 RegexComponentMatcher::compile()
41 m_componentRegex.assign(
m_expr);
43 m_pseudoMatchers.clear();
44 m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
46 for (
size_t i = 1; i <= m_componentRegex.mark_count(); i++) {
47 m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
63 NDN_THROW(
Error(
"Non-exact component search is not supported yet"));
65 std::smatch subResult;
66 std::string targetStr = name.
get(offset).
toUri();
67 if (std::regex_match(targetStr, subResult, m_componentRegex)) {
68 for (
size_t i = 1; i <= m_componentRegex.mark_count(); i++) {
69 m_pseudoMatchers[i]->resetMatchResult();
70 m_pseudoMatchers[i]->setMatchResult(subResult[i]);
Represents an absolute name.
const Component & get(ssize_t i) const noexcept
Returns an immutable reference to the component at the specified index.
bool match(const Name &name, size_t offset, size_t len=1) override
RegexComponentMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager, bool isExactMatch=true)
Create a RegexComponent matcher from expr.
std::vector< name::Component > m_matchResult
shared_ptr< RegexBackrefManager > m_backrefManager
void toUri(std::ostream &os, UriFormat format=UriFormat::DEFAULT) const
Write *this to the output stream, escaping characters according to the NDN URI format.