10 #include <QRegularExpression> 12 #include <pajlada/serialize.hpp> 23 return std::tie(this->pattern_, this->isRegex_, this->isBlock_,
24 this->replace_, this->isCaseSensitive_) ==
25 std::tie(other.pattern_, other.isRegex_, other.isBlock_,
26 other.replace_, other.isCaseSensitive_);
36 , isCaseSensitive_(isCaseSensitive)
38 if (this->isCaseSensitive_)
40 regex_.setPatternOptions(
41 QRegularExpression::UseUnicodePropertiesOption);
45 regex_.setPatternOptions(
46 QRegularExpression::CaseInsensitiveOption |
47 QRegularExpression::UseUnicodePropertiesOption);
53 return this->pattern_;
58 return this->isRegex_;
63 return this->regex_.isValid();
66 bool isMatch(
const QString &subject)
const 68 return !this->pattern_.isEmpty() &&
69 (this->
isRegex() ? (this->regex_.isValid() &&
70 this->regex_.match(subject).hasMatch())
71 : subject.contains(this->pattern_,
72 this->caseSensitivity()));
82 return this->isBlock_;
87 return this->replace_;
92 return this->isCaseSensitive_;
97 return this->isCaseSensitive_ ? Qt::CaseSensitive : Qt::CaseInsensitive;
100 const std::unordered_map<EmoteName, EmotePtr> &
getEmotes()
const 102 return this->emotes_;
107 if (!this->emotesChecked_)
110 for (
const auto &acc : accvec)
112 const auto &accemotes = *acc->accessEmotes();
113 for (
const auto &
emote : accemotes.emotes)
115 if (this->replace_.contains(
emote.first.string,
118 this->emotes_.emplace(
emote.first,
emote.second);
122 this->emotesChecked_ =
true;
124 return !this->emotes_.empty();
130 QRegularExpression regex_;
133 bool isCaseSensitive_;
134 mutable std::unordered_map<EmoteName, EmotePtr> emotes_;
135 mutable bool emotesChecked_{
false};
144 rapidjson::Document::AllocatorType &a)
146 rapidjson::Value ret(rapidjson::kObjectType);
161 bool *error =
nullptr)
163 if (!value.IsObject())
165 PAJLADA_REPORT_ERROR(error)
167 QString(),
false,
false,
173 bool _isRegex =
false;
174 bool _isBlock =
false;
176 bool _caseSens =
true;
Application * getApp()
Definition: Application.cpp:623
bool isBlock() const
Definition: IgnorePhrase.hpp:80
bool isCaseSensitive() const
Definition: IgnorePhrase.hpp:90
const QRegularExpression & getRegex() const
Definition: IgnorePhrase.hpp:75
bool containsEmote() const
Definition: IgnorePhrase.hpp:105
Definition: Application.cpp:48
const QString & getReplace() const
Definition: IgnorePhrase.hpp:85
bool isRegexValid() const
Definition: IgnorePhrase.hpp:61
Qt::CaseSensitivity caseSensitivity() const
Definition: IgnorePhrase.hpp:95
Definition: IgnorePhrase.hpp:18
TwitchAccountManager twitch
Definition: AccountController.hpp:27
void set(rapidjson::Value &obj, const char *key, const Type &value, rapidjson::Document::AllocatorType &a)
Definition: RapidjsonHelpers.hpp:22
const std::unordered_map< EmoteName, EmotePtr > & getEmotes() const
Definition: IgnorePhrase.hpp:100
Definition: Command.hpp:25
bool isMatch(const QString &subject) const
Definition: IgnorePhrase.hpp:66
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
Definition: RapidjsonHelpers.hpp:73
Settings * getSettings()
Definition: BaseSettings.cpp:110
IgnorePhrase(const QString &pattern, bool isRegex, bool isBlock, const QString &replace, bool isCaseSensitive)
Definition: IgnorePhrase.hpp:29
bool isRegex() const
Definition: IgnorePhrase.hpp:56
bool operator==(const IgnorePhrase &other) const
Definition: IgnorePhrase.hpp:21
AccountController *const accounts
Definition: Application.hpp:83
SignalVector< std::shared_ptr< TwitchAccount > > accounts
Definition: TwitchAccountManager.hpp:57
const QString & getPattern() const
Definition: IgnorePhrase.hpp:51