30 shared_ptr<RegexBackrefManager> backrefManager)
45 return compileSingleComponent();
47 size_t lastIndex =
m_expr.size() - 1;
48 if (
']' !=
m_expr[lastIndex])
52 m_isInclusion =
false;
53 compileMultipleComponents(2, lastIndex);
56 compileMultipleComponents(1, lastIndex);
65 RegexComponentSetMatcher::compileSingleComponent()
67 size_t end = extractComponent(1);
75 RegexComponentSetMatcher::compileMultipleComponents(
size_t start,
size_t lastIndex)
78 size_t tempIndex = start;
80 while (index < lastIndex) {
84 tempIndex = index + 1;
85 index = extractComponent(tempIndex);
86 m_components.push_back(make_shared<RegexComponentMatcher>(
m_expr.substr(tempIndex, index - tempIndex - 1),
90 if (index != lastIndex)
101 bool isMatched =
false;
102 for (
const auto& comp : m_components) {
103 if (comp->match(name, offset, len)) {
111 if (m_isInclusion ? isMatched : !isMatched) {
120 RegexComponentSetMatcher::extractComponent(
size_t index)
const 125 while (lcount > rcount) {
const Component & get(ssize_t i) const
Returns an immutable reference to the component at the specified index.
bool match(const Name &name, size_t offset, size_t len=1) override
shared_ptr< RegexBackrefManager > m_backrefManager
void compile() override
Compile the regular expression to generate the more matchers when necessary.
std::vector< name::Component > m_matchResult
Represents an absolute name.
RegexComponentSetMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
Create a RegexComponentSetMatcher matcher from expr.