@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user