48 int l =
qMin(len, 255);
49 memset(skiptable, l, 256*
sizeof(
uchar));
53 skiptable[*uc & 0xff] =
l;
59 skiptable[
foldCase(uc, start) & 0xff] =
l;
69 return index > (int)l ? -1 : index;
70 const uint pl_minus_one = pl - 1;
72 register const ushort *current = uc + index + pl_minus_one;
75 while (current < end) {
76 uint skip = skiptable[*current & 0xff];
80 if (*(current - skip) != puc[pl_minus_one-skip])
84 if (skip > pl_minus_one)
85 return (current - uc) - pl_minus_one;
89 if (skiptable[*(current - skip) & 0xff] == pl)
94 if (current > end - skip)
99 while (current < end) {
104 if (
foldCase(current - skip, uc) !=
foldCase(puc + pl_minus_one - skip, puc))
108 if (skip > pl_minus_one)
109 return (current - uc) - pl_minus_one;
112 if (skiptable[
foldCase(current - skip, uc) & 0xff] == pl)
117 if (current > end - skip)
210 if (
this != &other) {
323 const QChar *haystack,
int haystackLen,
int haystackOffset,
326 uchar skiptable[256];
328 if (haystackOffset < 0)
330 return bm_find((
const ushort *)haystack, haystackLen, haystackOffset,
331 (
const ushort *)needle, needleLen, skiptable, cs);
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
static void bm_init_skiptable(const ushort *uc, int len, uchar *skiptable, Qt::CaseSensitivity cs)
~QStringMatcher()
Destroys the string matcher.
The QString class provides a Unicode character string.
The QChar class provides a 16-bit Unicode character.
The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode stri...
void setCaseSensitivity(Qt::CaseSensitivity cs)
Sets the case sensitivity setting of this string matcher to cs.
#define QT_BEGIN_NAMESPACE
This macro expands to.
int size() const
Returns the number of characters in this string.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QStringMatcherPrivate * d_ptr
QString pattern() const
Returns the string pattern that this string matcher will search for.
static int bm_find(const ushort *uc, uint l, int index, const ushort *puc, uint pl, const uchar *skiptable, Qt::CaseSensitivity cs)
static uint foldCase(const ushort *ch, const ushort *start)
void * qMemSet(void *dest, int c, size_t n)
void setPattern(const QString &pattern)
Sets the string that this string matcher will search for to pattern.
QStringMatcher()
Constructs an empty string matcher that won't match anything.
int indexIn(const QString &str, int from=0) const
Searches the string str from character position from (default 0, i.e.
static const KeyPair *const end
int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int haystackOffset, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
QStringMatcher & operator=(const QStringMatcher &other)
Assigns the other string matcher to this string matcher.