5#include <QRegularExpression>
7#include <albert/export.h>
52 inline bool isMatch()
const {
return score_ >= 0.0; }
57 inline bool isEmptyMatch()
const {
return qFuzzyCompare(score_, 0.0); }
62 inline bool isExactMatch()
const {
return qFuzzyCompare(score_, 1.0); }
72 inline operator bool()
const {
return isMatch(); }
77 inline explicit operator Score()
const {
return score_; }
128 template<
typename... Args>
130 return std::max(match(first), match(args...));
137 requires std::same_as<std::ranges::range_value_t<
decltype(strings)>, QString>
141 return std::ranges::max(
142 strings | std::views::transform([
this](
const QString &s) {
return this->match(s); }));
148 std::unique_ptr<Private> d;
Configuration for string matching.
Definition matchconfig.h:17
Augmented match score.
Definition matcher.h:25
Match()
Constructs an invalid match.
Definition matcher.h:32
bool isEmptyMatch() const
Returns true if this is a zero score match, otherwise returns false.
Definition matcher.h:57
Match(const Match &o)=default
Constructs a Match with the score of other.
bool isMatch() const
Returns true if this is a match, otherwise returns false.
Definition matcher.h:52
Match & operator=(const Match &o)=default
Replaces the score with that of other.
bool isExactMatch() const
Returns true if this is a perfect match, otherwise returns false.
Definition matcher.h:62
Match(const Score score)
Constructs a match with the given score.
Definition matcher.h:37
Score score() const
Returns the score.
Definition matcher.h:67
double Score
Definition matcher.h:27
Configurable string matcher.
Definition matcher.h:91
Matcher(const QString &string, MatchConfig config={})
Constructs a Matcher with the given string and match config.
Match match(std::ranges::range auto &&strings) const
Returns the max match for strings.
Definition matcher.h:136
const QString & string() const
Returns the string matched against.
~Matcher()
Destructs the Matcher.
Match match(const QString &string) const
Returns a Match for string.
Matcher(Matcher &&o)
Constructs a Matcher with the contents of other using move semantics.
Match match(QString first, Args... args) const
Returns a Match for the given strings.
Definition matcher.h:129
Matcher & operator=(Matcher &&o)
Replaces the contents with those of other using move semantics.