15#include <QRegularExpression>
23 QRegularExpression Rx_;
28 RegExp (
const QString&, Qt::CaseSensitivity);
30 bool Matches (
const QString&)
const;
31 bool Matches (
const QByteArray&)
const;
44 :
Shift_ { std::max<qsizetype> (shift, 1) }
53 const QRegularExpression& rx,
55 requires requires { { replacer (body, QRegularExpressionMatch {}) } -> std::convertible_to<ReplacerResult>; }
58 bool keepGoing =
true;
61 const auto& match = rx.match (body, pos);
62 if (!match.hasMatch ())
66 [&] (StopReplace) { keepGoing =
false; },
67 [&] (
ReplaceAdvance adv) { pos = match.capturedStart (0) + adv.Shift_; });
QString GetPattern() const
Qt::CaseSensitivity GetCaseSensitivity() const
bool Matches(const QString &) const
std::variant< StopReplace, ReplaceAdvance > ReplacerResult
void ReplaceByRegexp(QString &body, const QRegularExpression &rx, R &&replacer)
auto Visit(const Either< Left, Right > &either, Args &&... args)
UTIL_SLL_API QDataStream & operator>>(QDataStream &, LC::Util::RegExp &)
UTIL_SLL_API QDataStream & operator<<(QDataStream &, const LC::Util::RegExp &)
ReplaceAdvance(qsizetype shift)
Q_DECLARE_METATYPE(QVariantList *)