Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRegularExpressionPrivate Struct Reference
+ Inheritance diagram for QRegularExpressionPrivate:
+ Collaboration diagram for QRegularExpressionPrivate:

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 (QAnyStringView name) const
 
- Public Member Functions inherited from QSharedData
 QSharedData () noexcept
 Constructs a QSharedData object with a reference count of 0.
 
 QSharedData (const QSharedData &) noexcept
 Constructs a QSharedData object with reference count 0.
 
QSharedDataoperator= (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
 
- Public Attributes inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 704 of file qregularexpression.cpp.

Member Enumeration Documentation

◆ CheckSubjectStringOption

Enumerator
CheckSubjectString 
DontCheckSubjectString 

Definition at line 715 of file qregularexpression.cpp.

Constructor & Destructor Documentation

◆ QRegularExpressionPrivate() [1/2]

QRegularExpressionPrivate::QRegularExpressionPrivate ( )

Definition at line 822 of file qregularexpression.cpp.

◆ ~QRegularExpressionPrivate()

QRegularExpressionPrivate::~QRegularExpressionPrivate ( )

Definition at line 839 of file qregularexpression.cpp.

References cleanCompiledPattern().

+ Here is the call graph for this function:

◆ QRegularExpressionPrivate() [2/2]

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 853 of file qregularexpression.cpp.

Member Function Documentation

◆ captureIndexForName()

int QRegularExpressionPrivate::captureIndexForName ( QAnyStringView name) const

Returns the capturing group number for the given name. Duplicated names for capturing groups are not supported.

Definition at line 1017 of file qregularexpression.cpp.

References compiledPattern, i, and Q_ASSERT.

Referenced by QRegularExpressionMatch::capturedEnd(), QRegularExpressionMatch::capturedLength(), QRegularExpressionMatch::capturedStart(), QRegularExpressionMatch::capturedView(), and QRegularExpressionMatch::hasCaptured().

+ Here is the caller graph for this function:

◆ cleanCompiledPattern()

void QRegularExpressionPrivate::cleanCompiledPattern ( )

Definition at line 870 of file qregularexpression.cpp.

References capturingCount, compiledPattern, errorCode, errorOffset, and usingCrLfNewlines.

Referenced by ~QRegularExpressionPrivate(), and compilePattern().

+ Here is the caller graph for this function:

◆ compilePattern()

void QRegularExpressionPrivate::compilePattern ( )

Definition at line 883 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doMatch()

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 1102 of file qregularexpression.cpp.

References QList< T >::at(), QRegularExpressionMatchPrivate::capturedOffsets, compiledPattern, convertToPcreOptions(), DontCheckSubjectString, QRegularExpressionMatchPrivate::hasMatch, i, 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPatternInfo()

void QRegularExpressionPrivate::getPatternInfo ( )

Definition at line 919 of file qregularexpression.cpp.

References capturingCount, compiledPattern, Q_ASSERT, Q_UNLIKELY, qUtf16Printable, qWarning, and usingCrLfNewlines.

Referenced by compilePattern().

+ Here is the caller graph for this function:

◆ optimizePattern()

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 999 of file qregularexpression.cpp.

References compiledPattern, isJitEnabled(), and Q_ASSERT.

Referenced by compilePattern().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ capturingCount

int QRegularExpressionPrivate::capturingCount

◆ compiledPattern

◆ errorCode

int QRegularExpressionPrivate::errorCode

◆ errorOffset

qsizetype QRegularExpressionPrivate::errorOffset

◆ isDirty

bool QRegularExpressionPrivate::isDirty

◆ mutex

QMutex QRegularExpressionPrivate::mutex
mutable

Definition at line 734 of file qregularexpression.cpp.

Referenced by compilePattern().

◆ pattern

QString QRegularExpressionPrivate::pattern

◆ patternOptions

QRegularExpression::PatternOptions QRegularExpressionPrivate::patternOptions

◆ usingCrLfNewlines

bool QRegularExpressionPrivate::usingCrLfNewlines

Definition at line 743 of file qregularexpression.cpp.

Referenced by cleanCompiledPattern(), doMatch(), and getPatternInfo().


The documentation for this struct was generated from the following file: