13 const char16_t *uc = needle.
utf16();
17 memset(skiptable, l, 256 *
sizeof(
uchar));
21 skiptable[*uc & 0xff] = l;
25 const char16_t *
start = uc;
36 const char16_t *uc = haystack.
utf16();
38 const char16_t *puc = needle.
utf16();
46 const char16_t *current = uc +
index + pl_minus_one;
47 const char16_t *
end = uc + l;
49 while (current <
end) {
50 qsizetype skip = skiptable[*current & 0xff];
54 if (*(current - skip) != puc[pl_minus_one-skip])
58 if (skip > pl_minus_one)
59 return (current - uc) - pl_minus_one;
63 if (skiptable[*(current - skip) & 0xff] == pl)
68 if (current >
end - skip)
75 const char16_t *
start = puc;
79 const qsizetype foldBufferEnd = foldBufferLength - 1;
80 const char16_t *current = uc +
index + foldBufferEnd;
81 const char16_t *
end = uc + l;
83 while (current <
end) {
87 while (skip < foldBufferLength) {
88 if (
foldCase(current - skip, uc) != foldBuffer[foldBufferEnd - skip])
92 if (skip > foldBufferEnd) {
93 qsizetype candidatePos = (current - uc) - foldBufferEnd;
95 haystack.
sliced(
qMin(haystack.
size(), candidatePos + foldBufferLength));
96 if (restNeedle.
size() == 0
103 if (skiptable[
foldCase(current - skip, uc) & 0xff] == foldBufferLength)
104 skip = foldBufferLength - skip;
108 if (current >
end - skip)
116void QStringMatcher::updateSkipTable()
207 if (
this != &
other) {
208 q_pattern =
other.q_pattern;
211 memcpy(q_skiptable,
other.q_skiptable,
sizeof(q_skiptable));
298 return bm_find(
str, from, q_sv, q_skiptable, q_cs);
317 uchar skiptable[256];
319 if (haystackOffset < 0)
321 return bm_find(haystack, haystackOffset, needle, skiptable, cs);
QStringMatcher & operator=(const QStringMatcher &other)
Assigns the other string matcher to this string matcher.
~QStringMatcher()
Destroys the string matcher.
void setPattern(const QString &pattern)
Sets the string that this string matcher will search for to pattern.
void setCaseSensitivity(Qt::CaseSensitivity cs)
Sets the case sensitivity setting of this string matcher to cs.
QString pattern() const
Returns the string pattern that this string matcher will search for.
QStringMatcher()=default
Constructs an empty string matcher that won't match anything.
qsizetype indexIn(const QString &str, qsizetype from=0) const
Searches the string str from character position from (default 0, i.e.
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr const storage_type * utf16() const noexcept
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QStringView sliced(qsizetype pos) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE void bm_init_skiptable(const uchar *cc, qsizetype len, uchar *skiptable)
static qsizetype bm_find(const uchar *cc, qsizetype l, qsizetype index, const uchar *puc, qsizetype pl, const uchar *skiptable)
static char32_t foldCase(const char16_t *ch, const char16_t *start)
constexpr const T & qMin(const T &a, const T &b)
static qsizetype bm_find(QStringView haystack, qsizetype index, QStringView needle, const uchar *skiptable, Qt::CaseSensitivity cs)
static void bm_init_skiptable(QStringView needle, uchar *skiptable, Qt::CaseSensitivity cs)
qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype haystackOffset, QStringView needle, Qt::CaseSensitivity cs)
static QT_BEGIN_NAMESPACE constexpr qsizetype FoldBufferCapacity