8 #include <pajlada/serialize.hpp> 22 , isCaseSensitive_(isCaseSensitive)
23 , caseSensitivity_(this->isCaseSensitive_ ? Qt::CaseSensitive
24 : Qt::CaseInsensitive)
28 this->regex_ = QRegularExpression(
29 name, QRegularExpression::UseUnicodePropertiesOption |
31 ? QRegularExpression::NoPatternOption
32 : QRegularExpression::CaseInsensitiveOption));
36 [[nodiscard]]
const QString &
name()
const 41 [[nodiscard]]
const QString &
replace()
const 43 return this->replace_;
48 return this->isRegex_;
53 return this->caseSensitivity_;
58 return this->isCaseSensitive_;
61 [[nodiscard]]
bool match(QString &usernameText)
const 65 if (!this->regex_.isValid())
69 if (this->
name().isEmpty())
74 auto workingCopy = usernameText;
75 workingCopy.replace(this->regex_, this->
replace());
76 if (workingCopy != usernameText)
78 usernameText = workingCopy;
100 bool isCaseSensitive_;
101 Qt::CaseSensitivity caseSensitivity_;
102 QRegularExpression regex_{};
112 rapidjson::Document::AllocatorType &a)
114 rapidjson::Value ret(rapidjson::kObjectType);
128 bool *error =
nullptr)
130 if (!value.IsObject())
132 PAJLADA_REPORT_ERROR(error)
139 bool _isCaseSensitive;
const QString & replace() const
Definition: Nickname.hpp:41
Definition: Application.cpp:48
const bool & isCaseSensitive() const
Definition: Nickname.hpp:56
bool match(QString &usernameText) const
Definition: Nickname.hpp:61
void set(rapidjson::Value &obj, const char *key, const Type &value, rapidjson::Document::AllocatorType &a)
Definition: RapidjsonHelpers.hpp:22
Qt::CaseSensitivity caseSensitivity() const
Definition: Nickname.hpp:51
Definition: Command.hpp:25
bool isRegex() const
Definition: Nickname.hpp:46
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
Definition: RapidjsonHelpers.hpp:73
Nickname(const QString &name, const QString &replace, const bool isRegex, const bool isCaseSensitive)
Definition: Nickname.hpp:17
Definition: Nickname.hpp:14
const QString & name() const
Definition: Nickname.hpp:36