summaryrefslogtreecommitdiff
path: root/src/desktop/rule/matchEngine/RegexMatchEngine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop/rule/matchEngine/RegexMatchEngine.cpp')
-rw-r--r--src/desktop/rule/matchEngine/RegexMatchEngine.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/desktop/rule/matchEngine/RegexMatchEngine.cpp b/src/desktop/rule/matchEngine/RegexMatchEngine.cpp
new file mode 100644
index 00000000..14e30af1
--- /dev/null
+++ b/src/desktop/rule/matchEngine/RegexMatchEngine.cpp
@@ -0,0 +1,17 @@
+#include "RegexMatchEngine.hpp"
+#include <re2/re2.h>
+
+using namespace Desktop::Rule;
+
+CRegexMatchEngine::CRegexMatchEngine(const std::string& regex) {
+ if (regex.starts_with("negative:")) {
+ m_negative = true;
+ m_regex = makeUnique<re2::RE2>(regex.substr(9));
+ return;
+ }
+ m_regex = makeUnique<re2::RE2>(regex);
+}
+
+bool CRegexMatchEngine::match(const std::string& other) {
+ return re2::RE2::FullMatch(other, *m_regex) != m_negative;
+} \ No newline at end of file