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 #ifndef QREGEXP_H
00039 #define QREGEXP_H
00040
00041 #ifndef QT_H
00042 #include "qstringlist.h"
00043 #endif // QT_H
00044
00045 #ifndef QT_NO_REGEXP
00046 class QRegExpEngine;
00047 struct QRegExpPrivate;
00048
00049 class Q_EXPORT QRegExp
00050 {
00051 public:
00052 enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
00053
00054 QRegExp();
00055 QRegExp( const QString& pattern, bool caseSensitive = TRUE,
00056 bool wildcard = FALSE );
00057 QRegExp( const QRegExp& rx );
00058 ~QRegExp();
00059 QRegExp& operator=( const QRegExp& rx );
00060
00061 bool operator==( const QRegExp& rx ) const;
00062 bool operator!=( const QRegExp& rx ) const { return !operator==( rx ); }
00063
00064 bool isEmpty() const;
00065 bool isValid() const;
00066 QString pattern() const;
00067 void setPattern( const QString& pattern );
00068 bool caseSensitive() const;
00069 void setCaseSensitive( bool sensitive );
00070 #ifndef QT_NO_REGEXP_WILDCARD
00071 bool wildcard() const;
00072 void setWildcard( bool wildcard );
00073 #endif
00074 bool minimal() const;
00075 void setMinimal( bool minimal );
00076
00077 bool exactMatch( const QString& str ) const;
00078 #ifndef QT_NO_COMPAT
00079 int match( const QString& str, int index = 0, int *len = 0,
00080 bool indexIsStart = TRUE ) const;
00081 #endif
00082
00083 #if defined(Q_QDOC)
00084 int search( const QString& str, int offset = 0,
00085 CaretMode caretMode = CaretAtZero ) const;
00086 int searchRev( const QString& str, int offset = -1,
00087 CaretMode caretMode = CaretAtZero ) const;
00088 #else
00089
00090 int search( const QString& str, int offset = 0 ) const;
00091 int search( const QString& str, int offset, CaretMode caretMode ) const;
00092 int searchRev( const QString& str, int offset = -1 ) const;
00093 int searchRev( const QString& str, int offset, CaretMode caretMode ) const;
00094 #endif
00095 int matchedLength() const;
00096 #ifndef QT_NO_REGEXP_CAPTURE
00097 int numCaptures() const;
00098 QStringList capturedTexts();
00099 QString cap( int nth = 0 );
00100 int pos( int nth = 0 );
00101 QString errorString();
00102 #endif
00103
00104 static QString escape( const QString& str );
00105
00106 private:
00107 void compile( bool caseSensitive );
00108
00109 static int caretIndex( int offset, CaretMode caretMode );
00110
00111 QRegExpEngine *eng;
00112 QRegExpPrivate *priv;
00113 };
00114 #endif // QT_NO_REGEXP
00115 #endif // QREGEXP_H