![]() |
Qt 6.x
The Qt SDK
|
Public Types | |
enum | CheckSubjectStringOption { CheckSubjectString , DontCheckSubjectString } |
Public Member Functions | |
QRegularExpressionPrivate () | |
~QRegularExpressionPrivate () | |
QRegularExpressionPrivate (const QRegularExpressionPrivate &other) | |
void | cleanCompiledPattern () |
void | compilePattern () |
void | getPatternInfo () |
void | optimizePattern () |
void | doMatch (QRegularExpressionMatchPrivate *priv, qsizetype offset, CheckSubjectStringOption checkSubjectStringOption=CheckSubjectString, const QRegularExpressionMatchPrivate *previous=nullptr) const |
int | captureIndexForName (QStringView name) const |
![]() | |
QSharedData () noexcept | |
Constructs a QSharedData object with a reference count of 0. | |
QSharedData (const QSharedData &) noexcept | |
Constructs a QSharedData object with reference count 0. | |
QSharedData & | operator= (const QSharedData &)=delete |
~QSharedData ()=default | |
Public Attributes | |
QRegularExpression::PatternOptions | patternOptions |
QString | pattern |
QMutex | mutex |
pcre2_code_16 * | compiledPattern |
int | errorCode |
qsizetype | errorOffset |
int | capturingCount |
bool | usingCrLfNewlines |
bool | isDirty |
![]() | |
QAtomicInt | ref |
Definition at line 703 of file qregularexpression.cpp.
Enumerator | |
---|---|
CheckSubjectString | |
DontCheckSubjectString |
Definition at line 714 of file qregularexpression.cpp.
QRegularExpressionPrivate::QRegularExpressionPrivate | ( | ) |
Definition at line 821 of file qregularexpression.cpp.
QRegularExpressionPrivate::~QRegularExpressionPrivate | ( | ) |
Definition at line 838 of file qregularexpression.cpp.
References cleanCompiledPattern().
QRegularExpressionPrivate::QRegularExpressionPrivate | ( | const QRegularExpressionPrivate & | other | ) |
Copies the private, which means copying only the pattern and the pattern options. The compiledPattern pointer is NOT copied (we do not own it any more), and in general all the members set when compiling a pattern are set to default values. isDirty is set back to true so that the pattern has to be recompiled again.
Definition at line 852 of file qregularexpression.cpp.
int QRegularExpressionPrivate::captureIndexForName | ( | QStringView | name | ) | const |
Returns the capturing group number for the given name. Duplicated names for capturing groups are not supported.
Definition at line 1016 of file qregularexpression.cpp.
References compiledPattern, i, and Q_ASSERT.
Referenced by QRegularExpressionMatch::capturedEnd(), QRegularExpressionMatch::capturedLength(), QRegularExpressionMatch::capturedStart(), QRegularExpressionMatch::capturedView(), and QRegularExpressionMatch::hasCaptured().
void QRegularExpressionPrivate::cleanCompiledPattern | ( | ) |
Definition at line 869 of file qregularexpression.cpp.
References capturingCount, compiledPattern, errorCode, errorOffset, and usingCrLfNewlines.
Referenced by ~QRegularExpressionPrivate(), and compilePattern().
void QRegularExpressionPrivate::compilePattern | ( | ) |
Definition at line 882 of file qregularexpression.cpp.
References cleanCompiledPattern(), compiledPattern, convertToPcreOptions(), errorCode, errorOffset, getPatternInfo(), isDirty, lock, mutex, optimizePattern(), and patternOptions.
Referenced by QRegularExpression::errorString(), QRegularExpression::isValid(), QRegularExpression::match(), QRegularExpression::matchView(), QRegularExpression::optimize(), and QRegularExpression::patternErrorOffset().
void QRegularExpressionPrivate::doMatch | ( | QRegularExpressionMatchPrivate * | priv, |
qsizetype | offset, | ||
CheckSubjectStringOption | checkSubjectStringOption = CheckSubjectString , |
||
const QRegularExpressionMatchPrivate * | previous = nullptr |
||
) | const |
Performs a match on the subject string view held by priv. The match will be of type priv->matchType and using the options priv->matchOptions; the matching offset is relative the substring, and if negative, it's taken as an offset from the end of the substring.
It also advances a match if a previous result is given as previous. The subject string goes a Unicode validity check if checkSubjectString is CheckSubjectString and the match options don't include DontCheckSubjectStringMatchOption (PCRE doesn't like illegal UTF-16 sequences).
priv is modified to hold the results of the match.
Advancing a match is a tricky algorithm. If the previous match matched a non-empty string, we just do an ordinary match at the offset position.
If the previous match matched an empty string, then an anchored, non-empty match is attempted at the offset position. If that succeeds, then we got the next match and we can return it. Otherwise, we advance by 1 position (which can be one or two code units in UTF-16!) and reattempt a "normal" match. We also have the problem of detecting the current newline format: if the new advanced offset is pointing to the beginning of a CRLF sequence, we must advance over it.
Definition at line 1101 of file qregularexpression.cpp.
References QList< T >::at(), QRegularExpressionMatchPrivate::capturedOffsets, compiledPattern, convertToPcreOptions(), DontCheckSubjectString, QRegularExpressionMatchPrivate::hasMatch, i, QChar::isLowSurrogate(), QRegularExpression::NoMatch, QRegularExpression::PartialPreferCompleteMatch, QRegularExpression::PartialPreferFirstMatch, priv(), Q_ASSERT, Q_UNLIKELY, qDebug, qtPcreCallback(), qtWarnAboutInvalidRegularExpression(), safe_pcre2_match_16(), and usingCrLfNewlines.
Referenced by QRegularExpression::match(), QRegularExpression::matchView(), and QRegularExpressionMatchPrivate::nextMatch().
void QRegularExpressionPrivate::getPatternInfo | ( | ) |
Definition at line 918 of file qregularexpression.cpp.
References capturingCount, compiledPattern, Q_ASSERT, Q_UNLIKELY, qUtf16Printable, qWarning, and usingCrLfNewlines.
Referenced by compilePattern().
void QRegularExpressionPrivate::optimizePattern | ( | ) |
The purpose of the function is to call pcre2_jit_compile_16, which JIT-compiles the pattern.
It gets called when a pattern is recompiled by us (in compilePattern()), under mutex protection.
Definition at line 998 of file qregularexpression.cpp.
References compiledPattern, isJitEnabled(), and Q_ASSERT.
Referenced by compilePattern().
int QRegularExpressionPrivate::capturingCount |
Definition at line 741 of file qregularexpression.cpp.
Referenced by QRegularExpression::captureCount(), cleanCompiledPattern(), getPatternInfo(), and QRegularExpression::namedCaptureGroups().
pcre2_code_16* QRegularExpressionPrivate::compiledPattern |
Definition at line 738 of file qregularexpression.cpp.
Referenced by captureIndexForName(), cleanCompiledPattern(), compilePattern(), doMatch(), getPatternInfo(), QRegularExpression::isValid(), QRegularExpression::namedCaptureGroups(), and optimizePattern().
int QRegularExpressionPrivate::errorCode |
Definition at line 739 of file qregularexpression.cpp.
Referenced by cleanCompiledPattern(), compilePattern(), and QRegularExpression::errorString().
qsizetype QRegularExpressionPrivate::errorOffset |
Definition at line 740 of file qregularexpression.cpp.
Referenced by cleanCompiledPattern(), compilePattern(), and QRegularExpression::patternErrorOffset().
bool QRegularExpressionPrivate::isDirty |
Definition at line 743 of file qregularexpression.cpp.
Referenced by compilePattern(), QRegularExpression::setPattern(), and QRegularExpression::setPatternOptions().
|
mutable |
Definition at line 733 of file qregularexpression.cpp.
Referenced by compilePattern().
QString QRegularExpressionPrivate::pattern |
Definition at line 728 of file qregularexpression.cpp.
Referenced by QRegularExpression::QRegularExpression(), QRegularExpression::operator==(), QRegularExpression::pattern(), and QRegularExpression::setPattern().
QRegularExpression::PatternOptions QRegularExpressionPrivate::patternOptions |
Definition at line 727 of file qregularexpression.cpp.
Referenced by QRegularExpression::QRegularExpression(), compilePattern(), QRegularExpression::operator==(), QRegularExpression::patternOptions(), and QRegularExpression::setPatternOptions().
bool QRegularExpressionPrivate::usingCrLfNewlines |
Definition at line 742 of file qregularexpression.cpp.
Referenced by cleanCompiledPattern(), doMatch(), and getPatternInfo().