looqs/shared/wildcardmatcher.cpp

30 γραμμές
614 B
C++

2022-05-31 10:13:34 +02:00
#include "wildcardmatcher.h"
void WildcardMatcher::setPatterns(QStringList patterns)
{
this->regexes.clear();
for(QString &str : patterns)
{
2024-05-20 19:14:40 +02:00
QRegularExpression regexp;
regexp.setPattern(QRegularExpression::wildcardToRegularExpression(str, QRegularExpression::UnanchoredWildcardConversion));
2022-05-31 10:13:34 +02:00
this->regexes.append(regexp);
}
}
WildcardMatcher::WildcardMatcher()
{
}
bool WildcardMatcher::match(QString haystack) const
{
2024-05-20 19:14:40 +02:00
for(const QRegularExpression &regexp : this->regexes)
2022-05-31 10:13:34 +02:00
{
2024-05-20 19:14:40 +02:00
QRegularExpressionMatch match = regexp.match(haystack);
if(match.hasMatch())
2022-05-31 10:13:34 +02:00
{
return true;
}
}
return false;
}