| 38 | }; |
| 39 | |
| 40 | class SimilarToRegex : public PermanentStorage |
| 41 | { |
| 42 | public: |
| 43 | struct MatchPos |
| 44 | { |
| 45 | unsigned start; |
| 46 | unsigned length; |
| 47 | }; |
| 48 | |
| 49 | public: |
| 50 | SimilarToRegex(MemoryPool& pool, unsigned flags, |
| 51 | const char* patternStr, unsigned patternLen, const char* escapeStr, unsigned escapeLen); |
| 52 | ~SimilarToRegex(); |
| 53 | |
| 54 | public: |
| 55 | static bool isSpecialChar(ULONG c) |
| 56 | { |
| 57 | switch (c) |
| 58 | { |
| 59 | case '^': |
| 60 | case '-': |
| 61 | case '_': |
| 62 | case '%': |
| 63 | case '[': |
| 64 | case ']': |
| 65 | case '(': |
| 66 | case ')': |
| 67 | case '{': |
| 68 | case '}': |
| 69 | case '|': |
| 70 | case '?': |
| 71 | case '+': |
| 72 | case '*': |
| 73 | return true; |
| 74 | } |
| 75 | |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | private: |
| 80 | static void finalize(SimilarToRegex* self); |
| 81 | |
| 82 | public: |
| 83 | bool matches(const char* buffer, unsigned bufferLen, Array<MatchPos>* matchPosArray = nullptr); |
| 84 | |
| 85 | private: |
| 86 | MemoryPool::Finalizer* finalizer = nullptr; |
| 87 | AutoPtr<re2::RE2> regexp; |
| 88 | }; |
| 89 | |
| 90 | // Given a regular expression R1<escape>#R2#<escape>R3 and the string S: |
| 91 | // - Find the shortest substring of S that matches R1 while the remainder (S23) matches R2R3; |
no outgoing calls
no test coverage detected