diff options
Diffstat (limited to 'launcher/pathmatcher')
-rw-r--r-- | launcher/pathmatcher/FSTreeMatcher.h | 20 | ||||
-rw-r--r-- | launcher/pathmatcher/IPathMatcher.h | 11 | ||||
-rw-r--r-- | launcher/pathmatcher/MultiMatcher.h | 23 | ||||
-rw-r--r-- | launcher/pathmatcher/RegexpMatcher.h | 26 |
4 files changed, 31 insertions, 49 deletions
diff --git a/launcher/pathmatcher/FSTreeMatcher.h b/launcher/pathmatcher/FSTreeMatcher.h index b84af294..52f1404d 100644 --- a/launcher/pathmatcher/FSTreeMatcher.h +++ b/launcher/pathmatcher/FSTreeMatcher.h @@ -1,21 +1,15 @@ #pragma once -#include "IPathMatcher.h" #include <SeparatorPrefixTree.h> #include <QRegularExpression> +#include "IPathMatcher.h" -class FSTreeMatcher : public IPathMatcher -{ -public: - virtual ~FSTreeMatcher() {}; - FSTreeMatcher(SeparatorPrefixTree<'/'> & tree) : m_fsTree(tree) - { - } +class FSTreeMatcher : public IPathMatcher { + public: + virtual ~FSTreeMatcher(){}; + FSTreeMatcher(SeparatorPrefixTree<'/'>& tree) : m_fsTree(tree) {} - bool matches(const QString &string) const override - { - return m_fsTree.covers(string); - } + bool matches(const QString& string) const override { return m_fsTree.covers(string); } - SeparatorPrefixTree<'/'> & m_fsTree; + SeparatorPrefixTree<'/'>& m_fsTree; }; diff --git a/launcher/pathmatcher/IPathMatcher.h b/launcher/pathmatcher/IPathMatcher.h index 1457d3e5..cd612197 100644 --- a/launcher/pathmatcher/IPathMatcher.h +++ b/launcher/pathmatcher/IPathMatcher.h @@ -1,13 +1,12 @@ #pragma once -#include <memory> #include <QString> +#include <memory> -class IPathMatcher -{ -public: +class IPathMatcher { + public: typedef std::shared_ptr<IPathMatcher> Ptr; -public: + public: virtual ~IPathMatcher() {} - virtual bool matches(const QString &string) const = 0; + virtual bool matches(const QString& string) const = 0; }; diff --git a/launcher/pathmatcher/MultiMatcher.h b/launcher/pathmatcher/MultiMatcher.h index 8bc1b6ee..10159580 100644 --- a/launcher/pathmatcher/MultiMatcher.h +++ b/launcher/pathmatcher/MultiMatcher.h @@ -1,26 +1,21 @@ -#include "IPathMatcher.h" #include <SeparatorPrefixTree.h> #include <QRegularExpression> +#include "IPathMatcher.h" -class MultiMatcher : public IPathMatcher -{ -public: - virtual ~MultiMatcher() {}; - MultiMatcher() - { - } - MultiMatcher &add(Ptr add) +class MultiMatcher : public IPathMatcher { + public: + virtual ~MultiMatcher(){}; + MultiMatcher() {} + MultiMatcher& add(Ptr add) { m_matchers.append(add); return *this; } - virtual bool matches(const QString &string) const override + virtual bool matches(const QString& string) const override { - for(auto iter: m_matchers) - { - if(iter->matches(string)) - { + for (auto iter : m_matchers) { + if (iter->matches(string)) { return true; } } diff --git a/launcher/pathmatcher/RegexpMatcher.h b/launcher/pathmatcher/RegexpMatcher.h index 6da651ef..a6a3e616 100644 --- a/launcher/pathmatcher/RegexpMatcher.h +++ b/launcher/pathmatcher/RegexpMatcher.h @@ -1,36 +1,30 @@ -#include "IPathMatcher.h" #include <QRegularExpression> +#include "IPathMatcher.h" -class RegexpMatcher : public IPathMatcher -{ -public: +class RegexpMatcher : public IPathMatcher { + public: virtual ~RegexpMatcher() {} - RegexpMatcher(const QString ®exp) + RegexpMatcher(const QString& regexp) { m_regexp.setPattern(regexp); m_onlyFilenamePart = !regexp.contains('/'); } - RegexpMatcher &caseSensitive(bool cs = true) + RegexpMatcher& caseSensitive(bool cs = true) { - if(cs) - { + if (cs) { m_regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - } - else - { + } else { m_regexp.setPatternOptions(QRegularExpression::NoPatternOption); } return *this; } - virtual bool matches(const QString &string) const override + virtual bool matches(const QString& string) const override { - if(m_onlyFilenamePart) - { + if (m_onlyFilenamePart) { auto slash = string.lastIndexOf('/'); - if(slash != -1) - { + if (slash != -1) { auto part = string.mid(slash + 1); return m_regexp.match(part).hasMatch(); } |