aboutsummaryrefslogtreecommitdiff
path: root/launcher/pathmatcher/SimplePrefixMatcher.h
blob: 191d010cb605400d5a812fb1a400fede11851c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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;
};