47 m_cs(
Qt::CaseSensitive),
48 m_caseSensitiveSearcher(m_pattern.
data(), m_pattern.
data())
76void QLatin1StringMatcher::setSearcher() noexcept
84 m_foldBuffer[
i] =
static_cast<char>(
foldCase(m_pattern[
i].toLatin1()));
87 CaseInsensitiveSearcher(m_foldBuffer, &m_foldBuffer[bufferSize]);
94void QLatin1StringMatcher::freeSearcher() noexcept
112 if (m_pattern.latin1() ==
pattern.latin1() && m_pattern.size() ==
pattern.size())
163 return indexIn_helper(haystack, from);
177 return indexIn_helper(haystack, from);
183template <
typename String>
184qsizetype QLatin1StringMatcher::indexIn_helper(String haystack,
qsizetype from)
const noexcept
186 static_assert(QtPrivate::isLatin1OrUtf16View<String>);
188 if (m_pattern.isEmpty() && from == haystack.size())
191 from += haystack.size();
192 if (from >= haystack.size())
195 const auto start = [haystack] {
196 if constexpr (std::is_same_v<String, QStringView>)
197 return haystack.utf16();
199 return haystack.begin();
206 found = m_caseSensitiveSearcher(
begin,
end, m_pattern.begin(), m_pattern.end()).begin;
210 const qsizetype bufferSize = std::min(m_pattern.size(),
qsizetype(
sizeof m_foldBuffer));
212 const bool needleLongerThanBuffer = restNeedle.size() > 0;
213 String restHaystack = haystack;
215 found = m_caseInsensitiveSearcher(found,
end, m_foldBuffer, &m_foldBuffer[bufferSize])
219 }
else if (!needleLongerThanBuffer) {
222 restHaystack = haystack.sliced(
223 qMin(haystack.size(),
230 return std::distance(
start, found);
Q_CORE_EXPORT qsizetype indexIn(QLatin1StringView haystack, qsizetype from=0) const noexcept
Searches for the pattern in the given haystack starting from from.
Q_CORE_EXPORT Qt::CaseSensitivity caseSensitivity() const noexcept
Returns the case sensitivity the matcher uses.
Q_CORE_EXPORT void setPattern(QLatin1StringView pattern) noexcept
Sets the pattern to search for.
Q_CORE_EXPORT ~QLatin1StringMatcher() noexcept
Destroys the Latin-1 string matcher.
CaseInsensitiveSearcher m_caseInsensitiveSearcher
Q_CORE_EXPORT QLatin1StringView pattern() const noexcept
Returns the Latin-1 pattern that the matcher searches for.
Q_CORE_EXPORT void setCaseSensitivity(Qt::CaseSensitivity cs) noexcept
Sets the case sensitivity to cs.
CaseSensitiveSearcher m_caseSensitiveSearcher
Q_CORE_EXPORT QLatin1StringMatcher() noexcept
Construct an empty Latin-1 string matcher.
constexpr const char * data() const noexcept
constexpr const_iterator end() const noexcept
constexpr QLatin1StringView sliced(qsizetype pos) const
constexpr qsizetype size() const noexcept
Combined button and popup list for selecting options.
static char32_t foldCase(const char16_t *ch, const char16_t *start)
constexpr const T & qMin(const T &a, const T &b)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)