Qt 4.8
qregexp.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QREGEXP_H
43 #define QREGEXP_H
44 
45 #ifndef QT_NO_REGEXP
46 
47 #include <QtCore/qstring.h>
48 #ifdef QT3_SUPPORT
49 #include <new>
50 #endif
51 
53 
55 
56 QT_MODULE(Core)
57 
58 struct QRegExpPrivate;
59 class QStringList;
60 
62 {
63 public:
70  W3CXmlSchema11 };
71  enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
72 
73  QRegExp();
74  explicit QRegExp(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive,
75  PatternSyntax syntax = RegExp);
76  QRegExp(const QRegExp &rx);
77  ~QRegExp();
78  QRegExp &operator=(const QRegExp &rx);
79 #ifdef Q_COMPILER_RVALUE_REFS
80  inline QRegExp &operator=(QRegExp &&other)
81  { qSwap(priv,other.priv); return *this; }
82 #endif
83  inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
84 
85  bool operator==(const QRegExp &rx) const;
86  inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
87 
88  bool isEmpty() const;
89  bool isValid() const;
90  QString pattern() const;
91  void setPattern(const QString &pattern);
92  Qt::CaseSensitivity caseSensitivity() const;
93  void setCaseSensitivity(Qt::CaseSensitivity cs);
94 #ifdef QT3_SUPPORT
95  inline QT3_SUPPORT bool caseSensitive() const { return caseSensitivity() == Qt::CaseSensitive; }
96  inline QT3_SUPPORT void setCaseSensitive(bool sensitive)
97  { setCaseSensitivity(sensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); }
98 #endif
99  PatternSyntax patternSyntax() const;
100  void setPatternSyntax(PatternSyntax syntax);
101 #ifdef QT3_SUPPORT
102  inline QT3_SUPPORT bool wildcard() const { return patternSyntax() == Wildcard; }
103  inline QT3_SUPPORT void setWildcard(bool aWildcard)
104  { setPatternSyntax(aWildcard ? Wildcard : RegExp); }
105 #endif
106 
107  bool isMinimal() const;
108  void setMinimal(bool minimal);
109 #ifdef QT3_SUPPORT
110  inline QT3_SUPPORT bool minimal() const { return isMinimal(); }
111 #endif
112 
113  bool exactMatch(const QString &str) const;
114 
115  int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
116  int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
117 #ifdef QT3_SUPPORT
118  inline QT3_SUPPORT int search(const QString &str, int from = 0,
119  CaretMode caretMode = CaretAtZero) const
120  { return indexIn(str, from, caretMode); }
121  inline QT3_SUPPORT int searchRev(const QString &str, int from = -1,
122  CaretMode caretMode = CaretAtZero) const
123  { return lastIndexIn(str, from, caretMode); }
124 #endif
125  int matchedLength() const;
126 #ifndef QT_NO_REGEXP_CAPTURE
127 #ifdef QT_DEPRECATED
128  QT_DEPRECATED int numCaptures() const;
129 #endif
130  int captureCount() const;
131  QStringList capturedTexts() const;
132  QStringList capturedTexts();
133  QString cap(int nth = 0) const;
134  QString cap(int nth = 0);
135  int pos(int nth = 0) const;
136  int pos(int nth = 0);
137  QString errorString() const;
139 #endif
140 
141  static QString escape(const QString &str);
142 
143 #ifdef QT3_SUPPORT
144  inline QT3_SUPPORT_CONSTRUCTOR QRegExp(const QString &aPattern, bool cs, bool aWildcard = false)
145  {
146  new (this)
148  aWildcard ? Wildcard : RegExp);
149  }
150 #endif
151 
152 private:
154 };
155 
157 
158 #ifndef QT_NO_DATASTREAM
161 #endif
162 
164 
166 
167 #endif // QT_NO_REGEXP
168 
169 #endif // QREGEXP_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
Q_DECLARE_TYPEINFO(QRegExp, Q_MOVABLE_TYPE)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isEmpty(const char *str)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &in, QRegExp &regExp)
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
Q_GUI_EXPORT QString escape(const QString &plain)
Converts the plain text string plain to a HTML string with HTML metacharacters <, >...
void swap(QRegExp &other)
Swaps regular expression other with this regular expression.
Definition: qregexp.h:83
CaseSensitivity
Definition: qnamespace.h:1451
PatternSyntax
The syntax used to interpret the meaning of the pattern.
Definition: qregexp.h:64
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
QRegExpPrivate * priv
Definition: qregexp.h:153
Q_CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QRegExp &regExp)
bool operator!=(const QRegExp &rx) const
Returns true if this regular expression is not equal to rx; otherwise returns false.
Definition: qregexp.h:86
static const QMetaObjectPrivate * priv(const uint *data)
#define QT_DEPRECATED
Definition: qglobal.h:1094
CaretMode
The CaretMode enum defines the different meanings of the caret (^) in a regular expression.
Definition: qregexp.h:71
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
#define QT_END_HEADER
Definition: qglobal.h:137
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023