QLatin1StringMatcher Class▲
-
Header: QLatin1StringMatcher
-
Since: Qt 6.5
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
-
qmake: QT += core
-
Group: QLatin1StringMatcher is part of tools, string-processing
Detailed Description▲
A QLatin1StringMatcher can search for one QLatin1StringView as a substring of another, either ignoring case or taking it into account.
This class is useful when you have a Latin-1 encoded string that you want to repeatedly search for in some QLatin1StringViews (perhaps in a loop), or when you want to search for all instances of it in a given QLatin1StringView. Using a matcher object and indexIn() is faster than matching a plain QLatin1StringView with QLatin1StringView::indexOf() if repeated matching takes place. This class offers no benefit if you are doing one-off matches. The string to be searched for must not be destroyed or changed before the matcher object is destroyed, as the matcher accesses the string when searching for it.
Create a QLatin1StringMatcher for the QLatin1StringView you want to search for and the case sensitivity. Then call indexIn() with the QLatin1StringView that you want to search within.
See Also▲
See also QLatin1StringView, QStringMatcher, QByteArrayMatcher
Member Function Documentation▲
QLatin1StringMatcher::QLatin1StringMatcher()▲
Construct an empty Latin-1 string matcher. This will match at each position in any string.
See Also▲
See also setPattern(), setCaseSensitivity(), indexIn()
QLatin1StringMatcher::QLatin1StringMatcher(QLatin1StringView pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive)▲
Constructs a Latin-1 string matcher that searches for the given pattern with given case sensitivity cs. The pattern argument must not be destroyed before this matcher object. Call indexIn() to find the pattern in the given QLatin1StringView.
QLatin1StringMatcher::~QLatin1StringMatcher()▲
Destroys the Latin-1 string matcher.
Qt::CaseSensitivity QLatin1StringMatcher::caseSensitivity() const▲
qsizetype QLatin1StringMatcher::indexIn(QLatin1StringView haystack, qsizetype from = 0) const▲
Searches for the pattern in the given haystack starting from from.
See Also▲
See also caseSensitivity(), pattern()
QLatin1StringView QLatin1StringMatcher::pattern() const▲
Returns the Latin-1 pattern that the matcher searches for.
See Also▲
See also setPattern(), indexIn()
void QLatin1StringMatcher::setCaseSensitivity(Qt::CaseSensitivity cs)▲
void QLatin1StringMatcher::setPattern(QLatin1StringView pattern)▲
Sets the pattern to search for. The string pointed to by the QLatin1StringView must not be destroyed before the matcher is destroyed, unless it is set to point to a different pattern with longer lifetime first.