Qt 4.8
|
The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode string. More...
#include <qstringmatcher.h>
Classes | |
struct | Data |
Public Functions | |
Qt::CaseSensitivity | caseSensitivity () const |
Returns the case sensitivity setting for this string matcher. More... | |
int | indexIn (const QString &str, int from=0) const |
Searches the string str from character position from (default 0, i.e. More... | |
int | indexIn (const QChar *str, int length, int from=0) const |
Searches the string starting at str (of length length) from character position from (default 0, i. More... | |
QStringMatcher & | operator= (const QStringMatcher &other) |
Assigns the other string matcher to this string matcher. More... | |
QString | pattern () const |
Returns the string pattern that this string matcher will search for. More... | |
QStringMatcher () | |
Constructs an empty string matcher that won't match anything. More... | |
QStringMatcher (const QString &pattern, Qt::CaseSensitivity cs=Qt::CaseSensitive) | |
Constructs a string matcher that will search for pattern, with case sensitivity cs. More... | |
QStringMatcher (const QChar *uc, int len, Qt::CaseSensitivity cs=Qt::CaseSensitive) | |
QStringMatcher (const QStringMatcher &other) | |
Copies the other string matcher to this string matcher. More... | |
void | setCaseSensitivity (Qt::CaseSensitivity cs) |
Sets the case sensitivity setting of this string matcher to cs. More... | |
void | setPattern (const QString &pattern) |
Sets the string that this string matcher will search for to pattern. More... | |
~QStringMatcher () | |
Destroys the string matcher. More... | |
Properties | |
union { | |
Data p | |
uint q_data [256] | |
}; | |
QStringMatcherPrivate * | d_ptr |
Qt::CaseSensitivity | q_cs |
QString | q_pattern |
The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode string.
This class is useful when you have a sequence of QChar that you want to repeatedly match against some strings (perhaps in a loop), or when you want to search for the same sequence of characters multiple times in the same string. Using a matcher object and indexIn() is faster than matching a plain QString with QString::indexOf() if repeated matching takes place. This class offers no benefit if you are doing one-off string matches.
Create the QStringMatcher with the QString you want to search for. Then call indexIn() on the QString that you want to search.
Definition at line 55 of file qstringmatcher.h.
QStringMatcher::QStringMatcher | ( | ) |
Constructs an empty string matcher that won't match anything.
Call setPattern() to give it a pattern to match.
Definition at line 154 of file qstringmatcher.cpp.
QStringMatcher::QStringMatcher | ( | const QString & | pattern, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) |
Constructs a string matcher that will search for pattern, with case sensitivity cs.
Call indexIn() to perform a search.
Definition at line 166 of file qstringmatcher.cpp.
QStringMatcher::QStringMatcher | ( | const QChar * | uc, |
int | length, | ||
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) |
Constructs a string matcher that will search for the pattern referred to by uc with the given length and case sensitivity specified by cs.
Definition at line 181 of file qstringmatcher.cpp.
QStringMatcher::QStringMatcher | ( | const QStringMatcher & | other | ) |
Copies the other string matcher to this string matcher.
Definition at line 192 of file qstringmatcher.cpp.
QStringMatcher::~QStringMatcher | ( | ) |
|
inline |
Returns the case sensitivity setting for this string matcher.
Definition at line 74 of file qstringmatcher.h.
int QStringMatcher::indexIn | ( | const QString & | str, |
int | from = 0 |
||
) | const |
Searches the string str from character position from (default 0, i.e.
from the first character), for the string pattern() that was set in the constructor or in the most recent call to setPattern(). Returns the position where the pattern() matched in str, or -1 if no match was found.
Definition at line 274 of file qstringmatcher.cpp.
Referenced by QtPrivate::QStringList_filter(), qt_string_count(), and QString::replace().
int QStringMatcher::indexIn | ( | const QChar * | str, |
int | length, | ||
int | from = 0 |
||
) | const |
Searches the string starting at str (of length length) from character position from (default 0, i.
e. from the first character), for the string pattern() that was set in the constructor or in the most recent call to setPattern(). Returns the position where the pattern() matched in str, or -1 if no match was found.
Definition at line 298 of file qstringmatcher.cpp.
QStringMatcher & QStringMatcher::operator= | ( | const QStringMatcher & | other | ) |
Assigns the other string matcher to this string matcher.
Definition at line 208 of file qstringmatcher.cpp.
Referenced by QStringMatcher().
QString QStringMatcher::pattern | ( | ) | const |
Returns the string pattern that this string matcher will search for.
Definition at line 244 of file qstringmatcher.cpp.
Referenced by setPattern().
void QStringMatcher::setCaseSensitivity | ( | Qt::CaseSensitivity | cs | ) |
Sets the case sensitivity setting of this string matcher to cs.
Definition at line 257 of file qstringmatcher.cpp.
void QStringMatcher::setPattern | ( | const QString & | pattern | ) |
Sets the string that this string matcher will search for to pattern.
Definition at line 224 of file qstringmatcher.cpp.
union { ... } |
|
private |
Definition at line 77 of file qstringmatcher.h.
Data QStringMatcher::p |
Definition at line 92 of file qstringmatcher.h.
Referenced by indexIn(), pattern(), QStringMatcher(), setCaseSensitivity(), and setPattern().
|
private |
Definition at line 79 of file qstringmatcher.h.
Referenced by indexIn(), operator=(), setCaseSensitivity(), and setPattern().
uint QStringMatcher::q_data[256] |
Definition at line 91 of file qstringmatcher.h.
Referenced by operator=(), and QStringMatcher().
|
private |
Definition at line 78 of file qstringmatcher.h.
Referenced by operator=(), pattern(), setCaseSensitivity(), and setPattern().