qregularexpression.sip 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // qregularexpression.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  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. class QRegularExpression
  22. {
  23. %TypeHeaderCode
  24. #include <qregularexpression.h>
  25. %End
  26. public:
  27. enum PatternOption /BaseType=Flag/
  28. {
  29. NoPatternOption,
  30. CaseInsensitiveOption,
  31. DotMatchesEverythingOption,
  32. MultilineOption,
  33. ExtendedPatternSyntaxOption,
  34. InvertedGreedinessOption,
  35. DontCaptureOption,
  36. UseUnicodePropertiesOption,
  37. };
  38. typedef QFlags<QRegularExpression::PatternOption> PatternOptions;
  39. QRegularExpression::PatternOptions patternOptions() const;
  40. void setPatternOptions(QRegularExpression::PatternOptions options);
  41. QRegularExpression();
  42. QRegularExpression(const QString &pattern, QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption);
  43. QRegularExpression(const QRegularExpression &re);
  44. ~QRegularExpression();
  45. SIP_PYOBJECT __repr__() const /TypeHint="str"/;
  46. %MethodCode
  47. PyObject *uni = qpycore_PyObject_FromQString(sipCpp->pattern());
  48. if (uni)
  49. {
  50. sipRes = PyUnicode_FromFormat("PyQt6.QtCore.QRegularExpression(%R", uni);
  51. if (sipCpp->patternOptions() != QRegularExpression::NoPatternOption)
  52. {
  53. qpycore_Unicode_ConcatAndDel(&sipRes,
  54. PyUnicode_FromFormat(
  55. ", PyQt6.QtCore.QRegularExpression.PatternOptions(%i)",
  56. (int)sipCpp->patternOptions()));
  57. }
  58. qpycore_Unicode_ConcatAndDel(&sipRes, PyUnicode_FromString(")"));
  59. Py_DECREF(uni);
  60. }
  61. else
  62. {
  63. sipRes = 0;
  64. }
  65. %End
  66. void swap(QRegularExpression &re /Constrained/);
  67. QString pattern() const;
  68. void setPattern(const QString &pattern);
  69. bool isValid() const;
  70. qsizetype patternErrorOffset() const;
  71. QString errorString() const;
  72. int captureCount() const;
  73. enum MatchType
  74. {
  75. NormalMatch,
  76. PartialPreferCompleteMatch,
  77. PartialPreferFirstMatch,
  78. NoMatch,
  79. };
  80. enum MatchOption /BaseType=Flag/
  81. {
  82. NoMatchOption,
  83. AnchorAtOffsetMatchOption,
  84. DontCheckSubjectStringMatchOption,
  85. };
  86. typedef QFlags<QRegularExpression::MatchOption> MatchOptions;
  87. QRegularExpressionMatch match(const QString &subject, qsizetype offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const;
  88. %If (Qt_6_5_0 -)
  89. QRegularExpressionMatch matchView(QStringView subjectView, qsizetype offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const;
  90. %End
  91. QRegularExpressionMatchIterator globalMatch(const QString &subject, qsizetype offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const;
  92. %If (Qt_6_5_0 -)
  93. QRegularExpressionMatchIterator globalMatchView(QStringView subjectView, qsizetype offset = 0, QRegularExpression::MatchType matchType = QRegularExpression::NormalMatch, QRegularExpression::MatchOptions matchOptions = QRegularExpression::NoMatchOption) const;
  94. %End
  95. static QString escape(const QString &str);
  96. QStringList namedCaptureGroups() const;
  97. %If (- Qt_6_8_0)
  98. bool operator==(const QRegularExpression &re) const;
  99. %End
  100. %If (- Qt_6_8_0)
  101. bool operator!=(const QRegularExpression &re) const;
  102. %End
  103. void optimize() const;
  104. Py_hash_t __hash__() const;
  105. %MethodCode
  106. sipRes = qHash(*sipCpp);
  107. %End
  108. static QString wildcardToRegularExpression(QStringView str, QRegularExpression::WildcardConversionOptions options = QRegularExpression::DefaultWildcardConversion);
  109. static QString anchoredPattern(const QString &expression);
  110. enum WildcardConversionOption /BaseType=Flag/
  111. {
  112. DefaultWildcardConversion,
  113. UnanchoredWildcardConversion,
  114. %If (Qt_6_6_0 -)
  115. NonPathWildcardConversion,
  116. %End
  117. };
  118. typedef QFlags<QRegularExpression::WildcardConversionOption> WildcardConversionOptions;
  119. static QRegularExpression fromWildcard(QStringView pattern, Qt::CaseSensitivity cs = Qt::CaseInsensitive, QRegularExpression::WildcardConversionOptions options = QRegularExpression::DefaultWildcardConversion);
  120. };
  121. QDataStream &operator<<(QDataStream &out, const QRegularExpression &re /Constrained/) /ReleaseGIL/;
  122. QDataStream &operator>>(QDataStream &in, QRegularExpression &re /Constrained/) /ReleaseGIL/;
  123. class QRegularExpressionMatch
  124. {
  125. %TypeHeaderCode
  126. #include <qregularexpression.h>
  127. %End
  128. public:
  129. QRegularExpressionMatch();
  130. ~QRegularExpressionMatch();
  131. QRegularExpressionMatch(const QRegularExpressionMatch &match);
  132. void swap(QRegularExpressionMatch &match /Constrained/);
  133. QRegularExpression regularExpression() const;
  134. QRegularExpression::MatchType matchType() const;
  135. QRegularExpression::MatchOptions matchOptions() const;
  136. bool hasMatch() const;
  137. bool hasPartialMatch() const;
  138. bool isValid() const;
  139. int lastCapturedIndex() const;
  140. QString captured(int nth = 0) const;
  141. %If (- Qt_6_8_0)
  142. QString captured(const QString &name) const;
  143. %End
  144. %If (Qt_6_8_0 -)
  145. QString captured(QAnyStringView name) const;
  146. %End
  147. QStringList capturedTexts() const;
  148. %If (- Qt_6_8_0)
  149. qsizetype capturedStart(QStringView name) const;
  150. %End
  151. %If (Qt_6_8_0 -)
  152. qsizetype capturedStart(QAnyStringView name) const;
  153. %End
  154. qsizetype capturedStart(int nth = 0) const;
  155. %If (- Qt_6_8_0)
  156. qsizetype capturedLength(QStringView name) const;
  157. %End
  158. %If (Qt_6_8_0 -)
  159. qsizetype capturedLength(QAnyStringView name) const;
  160. %End
  161. qsizetype capturedLength(int nth = 0) const;
  162. %If (- Qt_6_8_0)
  163. qsizetype capturedEnd(QStringView name) const;
  164. %End
  165. %If (Qt_6_8_0 -)
  166. qsizetype capturedEnd(QAnyStringView name) const;
  167. %End
  168. qsizetype capturedEnd(int nth = 0) const;
  169. %If (Qt_6_3_0 -)
  170. bool hasCaptured(int nth) const;
  171. %End
  172. %If (Qt_6_3_0 - Qt_6_8_0)
  173. bool hasCaptured(const QString &name) const;
  174. %End
  175. %If (Qt_6_8_0 -)
  176. bool hasCaptured(QAnyStringView name) const;
  177. %End
  178. };
  179. class QRegularExpressionMatchIterator
  180. {
  181. %TypeHeaderCode
  182. #include <qregularexpression.h>
  183. %End
  184. public:
  185. QRegularExpressionMatchIterator();
  186. ~QRegularExpressionMatchIterator();
  187. QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator);
  188. void swap(QRegularExpressionMatchIterator &iterator /Constrained/);
  189. bool isValid() const;
  190. bool hasNext() const;
  191. QRegularExpressionMatch next();
  192. QRegularExpressionMatch peekNext() const;
  193. QRegularExpression regularExpression() const;
  194. QRegularExpression::MatchType matchType() const;
  195. QRegularExpression::MatchOptions matchOptions() const;
  196. };
  197. %If (Qt_6_8_0 -)
  198. bool operator!=(const QRegularExpression &lhs, const QRegularExpression &rhs);
  199. %End
  200. %If (Qt_6_8_0 -)
  201. bool operator==(const QRegularExpression &lhs, const QRegularExpression &rhs);
  202. %End