Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QREGEXP_H
00043 #define QREGEXP_H
00044
00045 #ifndef QT_NO_REGEXP
00046
00047 #include <QtCore/qstring.h>
00048 #ifdef QT3_SUPPORT
00049 #include <new>
00050 #endif
00051
00052 QT_BEGIN_HEADER
00053
00054 QT_BEGIN_NAMESPACE
00055
00056 QT_MODULE(Core)
00057
00058 struct QRegExpPrivate;
00059 class QStringList;
00060
00061 class Q_CORE_EXPORT QRegExp
00062 {
00063 public:
00064 enum PatternSyntax {
00065 RegExp,
00066 Wildcard,
00067 FixedString,
00068 RegExp2,
00069 WildcardUnix,
00070 W3CXmlSchema11 };
00071 enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
00072
00073 QRegExp();
00074 explicit QRegExp(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive,
00075 PatternSyntax syntax = RegExp);
00076 QRegExp(const QRegExp &rx);
00077 ~QRegExp();
00078 QRegExp &operator=(const QRegExp &rx);
00079
00080 bool operator==(const QRegExp &rx) const;
00081 inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
00082
00083 bool isEmpty() const;
00084 bool isValid() const;
00085 QString pattern() const;
00086 void setPattern(const QString &pattern);
00087 Qt::CaseSensitivity caseSensitivity() const;
00088 void setCaseSensitivity(Qt::CaseSensitivity cs);
00089 #ifdef QT3_SUPPORT
00090 inline QT3_SUPPORT bool caseSensitive() const { return caseSensitivity() == Qt::CaseSensitive; }
00091 inline QT3_SUPPORT void setCaseSensitive(bool sensitive)
00092 { setCaseSensitivity(sensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); }
00093 #endif
00094 PatternSyntax patternSyntax() const;
00095 void setPatternSyntax(PatternSyntax syntax);
00096 #ifdef QT3_SUPPORT
00097 inline QT3_SUPPORT bool wildcard() const { return patternSyntax() == Wildcard; }
00098 inline QT3_SUPPORT void setWildcard(bool aWildcard)
00099 { setPatternSyntax(aWildcard ? Wildcard : RegExp); }
00100 #endif
00101
00102 bool isMinimal() const;
00103 void setMinimal(bool minimal);
00104 #ifdef QT3_SUPPORT
00105 inline QT3_SUPPORT bool minimal() const { return isMinimal(); }
00106 #endif
00107
00108 bool exactMatch(const QString &str) const;
00109
00110 int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
00111 int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
00112 #ifdef QT3_SUPPORT
00113 inline QT3_SUPPORT int search(const QString &str, int from = 0,
00114 CaretMode caretMode = CaretAtZero) const
00115 { return indexIn(str, from, caretMode); }
00116 inline QT3_SUPPORT int searchRev(const QString &str, int from = -1,
00117 CaretMode caretMode = CaretAtZero) const
00118 { return lastIndexIn(str, from, caretMode); }
00119 #endif
00120 int matchedLength() const;
00121 #ifndef QT_NO_REGEXP_CAPTURE
00122 #ifdef QT_DEPRECATED
00123 QT_DEPRECATED int numCaptures() const;
00124 #endif
00125 int captureCount() const;
00126 QStringList capturedTexts() const;
00127 QStringList capturedTexts();
00128 QString cap(int nth = 0) const;
00129 QString cap(int nth = 0);
00130 int pos(int nth = 0) const;
00131 int pos(int nth = 0);
00132 QString errorString() const;
00133 QString errorString();
00134 #endif
00135
00136 static QString escape(const QString &str);
00137
00138 #ifdef QT3_SUPPORT
00139 inline QT3_SUPPORT_CONSTRUCTOR QRegExp(const QString &aPattern, bool cs, bool aWildcard = false)
00140 {
00141 new (this)
00142 QRegExp(aPattern, cs ? Qt::CaseSensitive : Qt::CaseInsensitive,
00143 aWildcard ? Wildcard : RegExp);
00144 }
00145 #endif
00146
00147 private:
00148 QRegExpPrivate *priv;
00149 };
00150
00151 Q_DECLARE_TYPEINFO(QRegExp, Q_MOVABLE_TYPE);
00152
00153 #ifndef QT_NO_DATASTREAM
00154 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QRegExp ®Exp);
00155 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegExp ®Exp);
00156 #endif
00157
00158 QT_END_NAMESPACE
00159
00160 QT_END_HEADER
00161
00162 #endif // QT_NO_REGEXP
00163
00164 #endif // QREGEXP_H