1// qregexp.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 QRegExp 24{ 25%TypeHeaderCode 26#include <qregexp.h> 27%End 28 29public: 30 enum PatternSyntax 31 { 32 RegExp, 33 RegExp2, 34 Wildcard, 35 FixedString, 36 WildcardUnix, 37 W3CXmlSchema11, 38 }; 39 40 enum CaretMode 41 { 42 CaretAtZero, 43 CaretAtOffset, 44 CaretWontMatch, 45 }; 46 47 QRegExp(); 48 QRegExp(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive, QRegExp::PatternSyntax syntax = QRegExp::RegExp); 49 QRegExp(const QRegExp &rx); 50 ~QRegExp(); 51 SIP_PYOBJECT __repr__() const /TypeHint="str"/; 52%MethodCode 53 PyObject *uni = qpycore_PyObject_FromQString(sipCpp->pattern()); 54 55 if (uni) 56 { 57 #if PY_MAJOR_VERSION >= 3 58 sipRes = PyUnicode_FromFormat("PyQt5.QtCore.QRegExp(%R", uni); 59 60 if (sipCpp->caseSensitivity() != Qt::CaseSensitive || 61 sipCpp->patternSyntax() != QRegExp::RegExp) 62 { 63 qpycore_Unicode_ConcatAndDel(&sipRes, 64 PyUnicode_FromFormat(", PyQt5.QtCore.Qt.CaseSensitivity(%i)", 65 (int)sipCpp->caseSensitivity())); 66 67 if (sipCpp->patternSyntax() != QRegExp::RegExp) 68 qpycore_Unicode_ConcatAndDel(&sipRes, 69 PyUnicode_FromFormat( 70 ", PyQt5.QtCore.QRegExp.PatternSyntax(%i)", 71 (int)sipCpp->patternSyntax())); 72 } 73 74 qpycore_Unicode_ConcatAndDel(&sipRes, PyUnicode_FromString(")")); 75 #else 76 sipRes = PyString_FromString("PyQt5.QtCore.QRegExp("); 77 PyString_ConcatAndDel(&sipRes, PyObject_Repr(uni)); 78 79 if (sipCpp->caseSensitivity() != Qt::CaseSensitive || 80 sipCpp->patternSyntax() != QRegExp::RegExp) 81 { 82 PyString_ConcatAndDel(&sipRes, 83 PyString_FromFormat(", PyQt5.QtCore.Qt.CaseSensitivity(%i)", 84 (int)sipCpp->caseSensitivity())); 85 86 if (sipCpp->patternSyntax() != QRegExp::RegExp) 87 PyString_ConcatAndDel(&sipRes, 88 PyString_FromFormat( 89 ", PyQt5.QtCore.QRegExp.PatternSyntax(%i)", 90 (int)sipCpp->patternSyntax())); 91 } 92 93 PyString_ConcatAndDel(&sipRes, PyString_FromString(")")); 94 #endif 95 96 Py_DECREF(uni); 97 } 98 else 99 { 100 sipRes = 0; 101 } 102%End 103 104 bool operator==(const QRegExp &rx) const; 105 bool operator!=(const QRegExp &rx) const; 106 bool isEmpty() const; 107 bool isValid() const; 108 QString pattern() const; 109 void setPattern(const QString &pattern); 110 Qt::CaseSensitivity caseSensitivity() const; 111 void setCaseSensitivity(Qt::CaseSensitivity cs); 112 QRegExp::PatternSyntax patternSyntax() const; 113 void setPatternSyntax(QRegExp::PatternSyntax syntax); 114 bool isMinimal() const; 115 void setMinimal(bool minimal); 116 bool exactMatch(const QString &str) const; 117 int indexIn(const QString &str, int offset = 0, QRegExp::CaretMode caretMode = QRegExp::CaretAtZero) const; 118 int lastIndexIn(const QString &str, int offset = -1, QRegExp::CaretMode caretMode = QRegExp::CaretAtZero) const; 119 int matchedLength() const; 120 QStringList capturedTexts(); 121 QString cap(int nth = 0); 122 int pos(int nth = 0); 123 QString errorString(); 124 static QString escape(const QString &str); 125 int captureCount() const; 126 void swap(QRegExp &other /Constrained/); 127%If (Qt_5_6_0 -) 128 long __hash__() const; 129%MethodCode 130 sipRes = qHash(*sipCpp); 131%End 132 133%End 134}; 135 136QDataStream &operator<<(QDataStream &out, const QRegExp ®Exp /Constrained/) /ReleaseGIL/; 137QDataStream &operator>>(QDataStream &in, QRegExp ®Exp /Constrained/) /ReleaseGIL/; 138