1// qregularexpression.sip generated by MetaSIP 2// 3// This file is part of the QtCore Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 8// 9// This file may be used under the terms of the GNU General Public License 10// version 3.0 as published by the Free Software Foundation and appearing in 11// the file LICENSE included in the packaging of this file. Please review the 12// following information to ensure the GNU General Public License version 3.0 13// requirements will be met: http://www.gnu.org/copyleft/gpl.html. 14// 15// If you do not wish to use this file under the terms of the GPL version 3.0 16// then you may purchase a commercial license. For more information contact 17// info@riverbankcomputing.com. 18// 19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 22 23class QRegularExpression 24{ 25%TypeHeaderCode 26#include <qregularexpression.h> 27%End 28 29public: 30 enum PatternOption 31 { 32 NoPatternOption, 33 CaseInsensitiveOption, 34 DotMatchesEverythingOption, 35 MultilineOption, 36 ExtendedPatternSyntaxOption, 37 InvertedGreedinessOption, 38 DontCaptureOption, 39 UseUnicodePropertiesOption, 40%If (Qt_5_4_0 -) 41 OptimizeOnFirstUsageOption, 42%End 43%If (Qt_5_4_0 -) 44 DontAutomaticallyOptimizeOption, 45%End 46 }; 47 48 typedef QFlags<QRegularExpression::PatternOption> PatternOptions; 49 QRegularExpression::PatternOptions patternOptions() const; 50 void setPatternOptions(QRegularExpression::PatternOptions options); 51 QRegularExpression(); 52 QRegularExpression(const QString &pattern, QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption); 53 QRegularExpression(const QRegularExpression &re); 54 ~QRegularExpression(); 55 SIP_PYOBJECT __repr__() const /TypeHint="str"/; 56%MethodCode 57 PyObject *uni = qpycore_PyObject_FromQString(sipCpp->pattern()); 58 59 if (uni) 60 { 61 #if PY_MAJOR_VERSION >= 3 62 sipRes = PyUnicode_FromFormat("PyQt5.QtCore.QRegularExpression(%R", uni); 63 64 if (sipCpp->patternOptions() != QRegularExpression::NoPatternOption) 65 { 66 qpycore_Unicode_ConcatAndDel(&sipRes, 67 PyUnicode_FromFormat( 68 ", PyQt5.QtCore.QRegularExpression.PatternOptions(%i)", 69 (int)sipCpp->patternOptions())); 70 } 71 72 qpycore_Unicode_ConcatAndDel(&sipRes, PyUnicode_FromString(")")); 73 #else 74 sipRes = PyString_FromString("PyQt5.QtCore.QRegularExpression("); 75 PyString_ConcatAndDel(&sipRes, PyObject_Repr(uni)); 76 77 if (sipCpp->patternOptions() != QRegularExpression::NoPatternOption) 78 { 79 PyString_ConcatAndDel(&sipRes, 80 PyString_FromFormat( 81 ", PyQt5.QtCore.QRegularExpression.PatternOptions(%i)", 82 (int)sipCpp->patternOptions())); 83 } 84 85 PyString_ConcatAndDel(&sipRes, PyString_FromString(")")); 86 #endif 87 88 Py_DECREF(uni); 89 } 90 else 91 { 92 sipRes = 0; 93 } 94%End 95 96 void swap(QRegularExpression &re /Constrained/); 97 QString pattern() const; 98 void setPattern(const QString &pattern); 99 bool isValid() const; 100 int patternErrorOffset() const; 101 QString errorString() const; 102 int captureCount() const; 103 104 enum MatchType 105 { 106 NormalMatch, 107 PartialPreferCompleteMatch, 108 PartialPreferFirstMatch, 109%If (Qt_5_1_0 -) 110 NoMatch, 111%End 112 }; 113 114 enum MatchOption 115 { 116 NoMatchOption, 117 AnchoredMatchOption, 118%If (Qt_5_4_0 -) 119 DontCheckSubjectStringMatchOption, 120%End 121 }; 122 123 typedef QFlags<QRegularExpression::MatchOption> MatchOptions; 124 QRegularExpressionMatch match(const QString &subject, int offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const; 125 QRegularExpressionMatchIterator globalMatch(const QString &subject, int offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const; 126 static QString escape(const QString &str); 127%If (Qt_5_1_0 -) 128 QStringList namedCaptureGroups() const; 129%End 130 bool operator==(const QRegularExpression &re) const; 131 bool operator!=(const QRegularExpression &re) const; 132%If (Qt_5_4_0 -) 133 void optimize() const; 134%End 135%If (Qt_5_6_0 -) 136 long __hash__() const; 137%MethodCode 138 sipRes = qHash(*sipCpp); 139%End 140 141%End 142%If (Qt_5_12_0 -) 143 static QString wildcardToRegularExpression(const QString &str); 144%End 145%If (Qt_5_12_0 -) 146 static QString anchoredPattern(const QString &expression); 147%End 148}; 149 150QFlags<QRegularExpression::PatternOption> operator|(QRegularExpression::PatternOption f1, QFlags<QRegularExpression::PatternOption> f2); 151QFlags<QRegularExpression::MatchOption> operator|(QRegularExpression::MatchOption f1, QFlags<QRegularExpression::MatchOption> f2); 152QDataStream &operator<<(QDataStream &out, const QRegularExpression &re /Constrained/) /ReleaseGIL/; 153QDataStream &operator>>(QDataStream &in, QRegularExpression &re /Constrained/) /ReleaseGIL/; 154 155class QRegularExpressionMatch 156{ 157%TypeHeaderCode 158#include <qregularexpression.h> 159%End 160 161public: 162%If (Qt_5_1_0 -) 163 QRegularExpressionMatch(); 164%End 165 ~QRegularExpressionMatch(); 166 QRegularExpressionMatch(const QRegularExpressionMatch &match); 167 void swap(QRegularExpressionMatch &match /Constrained/); 168 QRegularExpression regularExpression() const; 169 QRegularExpression::MatchType matchType() const; 170 QRegularExpression::MatchOptions matchOptions() const; 171 bool hasMatch() const; 172 bool hasPartialMatch() const; 173 bool isValid() const; 174 int lastCapturedIndex() const; 175 QString captured(int nth = 0) const; 176 QString captured(const QString &name) const; 177 QStringList capturedTexts() const; 178 int capturedStart(int nth = 0) const; 179 int capturedLength(int nth = 0) const; 180 int capturedEnd(int nth = 0) const; 181 int capturedStart(const QString &name) const; 182 int capturedLength(const QString &name) const; 183 int capturedEnd(const QString &name) const; 184}; 185 186class QRegularExpressionMatchIterator 187{ 188%TypeHeaderCode 189#include <qregularexpression.h> 190%End 191 192public: 193%If (Qt_5_1_0 -) 194 QRegularExpressionMatchIterator(); 195%End 196 ~QRegularExpressionMatchIterator(); 197 QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator); 198 void swap(QRegularExpressionMatchIterator &iterator /Constrained/); 199 bool isValid() const; 200 bool hasNext() const; 201 QRegularExpressionMatch next(); 202 QRegularExpressionMatch peekNext() const; 203 QRegularExpression regularExpression() const; 204 QRegularExpression::MatchType matchType() const; 205 QRegularExpression::MatchOptions matchOptions() const; 206}; 207