30 řádky
614 B
C++
30 řádky
614 B
C++
#include "wildcardmatcher.h"
|
|
|
|
void WildcardMatcher::setPatterns(QStringList patterns)
|
|
{
|
|
this->regexes.clear();
|
|
for(QString &str : patterns)
|
|
{
|
|
QRegularExpression regexp;
|
|
regexp.setPattern(QRegularExpression::wildcardToRegularExpression(str, QRegularExpression::UnanchoredWildcardConversion));
|
|
this->regexes.append(regexp);
|
|
}
|
|
}
|
|
|
|
WildcardMatcher::WildcardMatcher()
|
|
{
|
|
}
|
|
|
|
bool WildcardMatcher::match(QString haystack) const
|
|
{
|
|
for(const QRegularExpression ®exp : this->regexes)
|
|
{
|
|
QRegularExpressionMatch match = regexp.match(haystack);
|
|
if(match.hasMatch())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|