From bd7065eece443de59adbe47dd7d9bd16e1d35ff5 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 23 Oct 2022 00:44:57 +0200 Subject: [PATCH] feat: add SimplePrefixMatcher Signed-off-by: Sefa Eyeoglu --- launcher/CMakeLists.txt | 1 + launcher/pathmatcher/SimplePrefixMatcher.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 launcher/pathmatcher/SimplePrefixMatcher.h diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 8db93429..45d197ef 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -97,6 +97,7 @@ set(PATHMATCHER_SOURCES pathmatcher/IPathMatcher.h pathmatcher/MultiMatcher.h pathmatcher/RegexpMatcher.h + pathmatcher/SimplePrefixMatcher.h ) set(NET_SOURCES diff --git a/launcher/pathmatcher/SimplePrefixMatcher.h b/launcher/pathmatcher/SimplePrefixMatcher.h new file mode 100644 index 00000000..191d010c --- /dev/null +++ b/launcher/pathmatcher/SimplePrefixMatcher.h @@ -0,0 +1,21 @@ +#include +#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; +};