30 shared_ptr<RegexBackrefManager> backrefManager)
31 :
RegexMatcher(expr, EXPR_COMPONENT_SET, std::move(backrefManager))
37 RegexComponentSetMatcher::compile()
45 return compileSingleComponent();
47 size_t lastIndex =
m_expr.size() - 1;
48 if (
']' !=
m_expr[lastIndex]) {
53 m_isInclusion =
false;
54 compileMultipleComponents(2, lastIndex);
57 compileMultipleComponents(1, lastIndex);
67 RegexComponentSetMatcher::compileSingleComponent()
69 size_t end = extractComponent(1);
77 RegexComponentSetMatcher::compileMultipleComponents(
size_t start,
size_t lastIndex)
80 size_t tempIndex = start;
82 while (index < lastIndex) {
86 tempIndex = index + 1;
87 index = extractComponent(tempIndex);
88 m_components.push_back(make_shared<RegexComponentMatcher>(
m_expr.substr(tempIndex, index - tempIndex - 1),
92 if (index != lastIndex)
103 bool isMatched =
false;
104 for (
const auto& comp : m_components) {
105 if (comp->match(name, offset, len)) {
113 if (m_isInclusion ? isMatched : !isMatched) {
122 RegexComponentSetMatcher::extractComponent(
size_t index)
const
127 while (lcount > rcount) {
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
RegexComponentSetMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
Create a RegexComponentSetMatcher matcher from expr.
std::vector< name::Component > m_matchResult
shared_ptr< RegexBackrefManager > m_backrefManager