looqs/shared/wildcardmatcher.cpp
2024-05-20 19:15:31 +02:00

30 lines
564 B
C++

#include "wildcardmatcher.h"
void WildcardMatcher::setPatterns(QStringList patterns)
{
this->regexes.clear();
for(QString &str : patterns)
{
QRegularExpression regexp;
regexp.setPattern(QRegularExpression::wildcardToRegularExpression(str));
this->regexes.append(regexp);
}
}
WildcardMatcher::WildcardMatcher()
{
}
bool WildcardMatcher::match(QString haystack) const
{
for(const QRegularExpression &regexp : this->regexes)
{
QRegularExpressionMatch match = regexp.match(haystack);
if(match.hasMatch())
{
return true;
}
}
return false;
}