aboutsummaryrefslogtreecommitdiff
path: root/launcher/pathmatcher/SimplePrefixMatcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/pathmatcher/SimplePrefixMatcher.h')
-rw-r--r--launcher/pathmatcher/SimplePrefixMatcher.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/launcher/pathmatcher/SimplePrefixMatcher.h b/launcher/pathmatcher/SimplePrefixMatcher.h
new file mode 100644
index 00000000..fc1f5ced
--- /dev/null
+++ b/launcher/pathmatcher/SimplePrefixMatcher.h
@@ -0,0 +1,25 @@
+// SPDX-FileCopyrightText: 2022 Sefa Eyeoglu <contact@scrumplex.net>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+#include <QRegularExpression>
+#include "IPathMatcher.h"
+
+class SimplePrefixMatcher : public IPathMatcher {
+ public:
+ virtual ~SimplePrefixMatcher(){};
+ SimplePrefixMatcher(const QString& prefix)
+ {
+ m_prefix = prefix;
+ m_isPrefix = prefix.endsWith('/');
+ }
+
+ virtual bool matches(const QString& string) const override
+ {
+ if (m_isPrefix)
+ return string.startsWith(m_prefix);
+ return string == m_prefix;
+ }
+ QString m_prefix;
+ bool m_isPrefix = false;
+};