|
@@ -20,12 +20,14 @@ bool CachedRegexMatcher::addMatcher(const QString& pattern, const QVariant& resu
|
|
}
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
-QVariant CachedRegexMatcher::match(const QString& input)
|
|
|
|
|
|
+QVariantList CachedRegexMatcher::match(const QString& input)
|
|
{
|
|
{
|
|
// first we check if this match has already happened before
|
|
// first we check if this match has already happened before
|
|
if (m_matcherCache.contains(input))
|
|
if (m_matcherCache.contains(input))
|
|
return m_matcherCache.value(input);
|
|
return m_matcherCache.value(input);
|
|
|
|
|
|
|
|
+ QVariantList matches;
|
|
|
|
+
|
|
// otherwise try to iterate our list and find a match
|
|
// otherwise try to iterate our list and find a match
|
|
for(const MatcherValuePair& matcher : m_matcherList)
|
|
for(const MatcherValuePair& matcher : m_matcherList)
|
|
{
|
|
{
|
|
@@ -49,17 +51,19 @@ QVariant CachedRegexMatcher::match(const QString& input)
|
|
returnValue = QVariant(value);
|
|
returnValue = QVariant(value);
|
|
}
|
|
}
|
|
|
|
|
|
- // now cache the match and the final value
|
|
|
|
- m_matcherCache.insert(input, returnValue);
|
|
|
|
-
|
|
|
|
- return returnValue;
|
|
|
|
|
|
+ matches << returnValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
QLOG_DEBUG() << "No match for:" << input;
|
|
QLOG_DEBUG() << "No match for:" << input;
|
|
|
|
|
|
- // no match at all
|
|
|
|
- return QVariant();
|
|
|
|
|
|
+ if (!matches.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ m_matcherCache.insert(input, matches);
|
|
|
|
+ return matches;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return QVariantList();
|
|
}
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|