Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstringmatcher.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2019 Mail.ru Group.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:trivial-impl-only
5
6#ifndef QSTRINGMATCHER_H
7#define QSTRINGMATCHER_H
8
9#include <QtCore/qstring.h>
10#include <QtCore/qstringview.h>
11
13
14
15class QStringMatcherPrivate;
16
17class Q_CORE_EXPORT QStringMatcher
18{
19 void updateSkipTable();
20public:
21 QStringMatcher() = default;
22 explicit QStringMatcher(const QString &pattern,
23 Qt::CaseSensitivity cs = Qt::CaseSensitive);
24 QStringMatcher(const QChar *uc, qsizetype len,
25 Qt::CaseSensitivity cs = Qt::CaseSensitive)
26 : QStringMatcher(QStringView(uc, len), cs)
27 {}
28 QStringMatcher(QStringView pattern,
29 Qt::CaseSensitivity cs = Qt::CaseSensitive);
30 QStringMatcher(const QStringMatcher &other);
31 ~QStringMatcher();
32
33 QStringMatcher &operator=(const QStringMatcher &other);
34
35 void setPattern(const QString &pattern);
36 void setCaseSensitivity(Qt::CaseSensitivity cs);
37
38 qsizetype indexIn(const QString &str, qsizetype from = 0) const
39 { return indexIn(QStringView(str), from); }
40 qsizetype indexIn(const QChar *str, qsizetype length, qsizetype from = 0) const
41 { return indexIn(QStringView(str, length), from); }
42 qsizetype indexIn(QStringView str, qsizetype from = 0) const;
43 QString pattern() const;
44 QStringView patternView() const noexcept
45 { return q_sv; }
46
47 inline Qt::CaseSensitivity caseSensitivity() const { return q_cs; }
48
49private:
50 QStringMatcherPrivate *d_ptr = nullptr;
51 Qt::CaseSensitivity q_cs = Qt::CaseSensitive;
52 QString q_pattern;
53 QStringView q_sv;
54 uchar q_skiptable[256] = {};
55};
56
57QT_END_NAMESPACE
58
59#endif // QSTRINGMATCHER_H
QString convertToQString(QAnyStringView string)
Definition qstring.cpp:5643
Definition qlist.h:80
char32_t next(char32_t invalidAs=QChar::ReplacementCharacter)
bool hasNext() const
\inmodule QtCore
QList< uint > convertToUcs4(QStringView string)
Definition qstring.cpp:5899
QByteArray convertToUtf8(QStringView string)
Definition qstring.cpp:5844
QByteArray convertToLocal8Bit(QStringView string)
Definition qstring.cpp:5801
QByteArray convertToLatin1(QStringView string)
Definition qstring.cpp:5660
static QString convertCase(T &str, QUnicodeTables::Case which)
Definition qstring.cpp:7272
static constexpr NormalizationCorrection uc_normalization_corrections[]
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.cpp:9800
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.cpp:9840
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLower(QStringView s) noexcept
Definition qstring.cpp:5580
const QString & asString(const QString &s)
Definition qstring.h:1680
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept
Definition qstring.cpp:906
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
Definition qstring.cpp:1376
qsizetype findString(QStringView str, qsizetype from, QChar needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1StringView s) noexcept
Definition qstring.cpp:851
constexpr bool isLatin1(QLatin1StringView s) noexcept
Definition qstring.h:77
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrcasechr(QStringView str, char16_t ch) noexcept
Definition qstring.cpp:776
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isUpper(QStringView s) noexcept
Definition qstring.cpp:5585
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrchr(QStringView str, char16_t ch) noexcept
Definition qstring.cpp:688
void qt_to_latin1_unchecked(uchar *dst, const char16_t *uc, qsizetype len)
Definition qstring.cpp:1189
static char16_t foldCase(char16_t ch) noexcept
Definition qchar.cpp:1698
#define __has_feature(x)
uint QT_FASTCALL fetch1Pixel< QPixelLayout::BPP1LSB >(const uchar *src, int index)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
static bool isAscii_helper(const char16_t *&ptr, const char16_t *end)
Definition qstring.cpp:859
static Int toIntegral(QStringView string, bool *ok, int base)
Definition qstring.cpp:7755
void qt_to_latin1(uchar *dst, const char16_t *src, qsizetype length)
Definition qstring.cpp:1184
Qt::strong_ordering compareThreeWay(const QByteArray &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6817
static void append_utf8(QString &qs, const char *cs, qsizetype len)
Definition qstring.cpp:7389
#define ATTRIBUTE_NO_SANITIZE
Definition qstring.cpp:367
bool qt_is_ascii(const char *&ptr, const char *end) noexcept
Definition qstring.cpp:787
static void replace_in_place(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3715
static bool checkCase(QStringView s, QUnicodeTables::Case c) noexcept
Definition qstring.cpp:5569
static void replace_helper(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3759
Q_CORE_EXPORT void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept
Definition qstring.cpp:921
static int ucstrcmp(const char16_t *a, size_t alen, const Char2 *b, size_t blen)
Definition qstring.cpp:1349
bool comparesEqual(const QByteArray &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6823
Q_DECLARE_TYPEINFO(Part, Q_PRIMITIVE_TYPE)
static void removeStringImpl(QString &s, const T &needle, Qt::CaseSensitivity cs)
Definition qstring.cpp:3495
static bool needsReallocate(const QString &str, qsizetype newSize)
Definition qstring.cpp:2631
static int qArgDigitValue(QChar ch) noexcept
Definition qstring.cpp:1616
bool comparesEqual(const QByteArray &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6812
#define REHASH(a)
Definition qstring.cpp:66
static void replace_with_copy(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3692
bool comparesEqual(const QByteArrayView &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6801
static int ucstrncmp(const char16_t *a, const char16_t *b, size_t l)
Definition qstring.cpp:1267
static Q_NEVER_INLINE int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char *b)
Definition qstring.cpp:1222
static QByteArray qt_convert_to_latin1(QStringView string)
Definition qstring.cpp:5666
static bool ucstreq(const char16_t *a, size_t alen, const Char2 *b)
Definition qstring.cpp:1342
static QList< uint > qt_convert_to_ucs4(QStringView string)
Definition qstring.cpp:5871
qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs)
static QByteArray qt_convert_to_local_8bit(QStringView string)
Definition qstring.cpp:5778
static LengthMod parse_length_modifier(const char *&c) noexcept
Definition qstring.cpp:7445
static ArgEscapeData findArgEscapes(QStringView s)
Definition qstring.cpp:8637
static QByteArray qt_convert_to_utf8(QStringView str)
Definition qstring.cpp:5824
static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype length)
Definition qstring.cpp:1005
QtPrivate::QCaseInsensitiveLatin1Hash CaseInsensitiveL1
Definition qstring.cpp:1356
LengthMod
Definition qstring.cpp:7434
@ lm_z
Definition qstring.cpp:7434
@ lm_none
Definition qstring.cpp:7434
@ lm_t
Definition qstring.cpp:7434
@ lm_l
Definition qstring.cpp:7434
@ lm_ll
Definition qstring.cpp:7434
@ lm_hh
Definition qstring.cpp:7434
@ lm_L
Definition qstring.cpp:7434
@ lm_h
Definition qstring.cpp:7434
@ lm_j
Definition qstring.cpp:7434
static void insert_helper(QString &str, qsizetype i, const T &toInsert)
Definition qstring.cpp:2970
static int latin1nicmp(const char *lhsChar, qsizetype lSize, const char *rhsChar, qsizetype rSize)
Definition qstring.cpp:1358
Qt::strong_ordering compareThreeWay(const QByteArrayView &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6795
static char16_t to_unicode(const char c)
Definition qstring.cpp:9042
Qt::strong_ordering compareThreeWay(const QByteArray &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6828
static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetype field_width, QStringView arg, QStringView larg, QChar fillChar)
Definition qstring.cpp:8713
static QVarLengthArray< char16_t > qt_from_latin1_to_qvla(QLatin1StringView str)
Definition qstring.cpp:996
static Q_NEVER_INLINE int ucstricmp8(const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end)
Definition qstring.cpp:1240
void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, qsizetype from)
Definition qstring.cpp:8527
static uint parse_flag_characters(const char *&c) noexcept
Definition qstring.cpp:7397
static Q_NEVER_INLINE int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char16_t *b)
Definition qstring.cpp:1195
static char16_t to_unicode(const QChar c)
Definition qstring.cpp:9041
QDataStream & operator>>(QDataStream &in, QString &str)
Definition qstring.cpp:9574
static int getEscape(const Char *uc, qsizetype *pos, qsizetype len)
Definition qstring.cpp:9045
static int ucstrncmp(const char16_t *a, const char *b, size_t l)
Definition qstring.cpp:1320
static bool can_consume(const char *&c, char ch) noexcept
Definition qstring.cpp:7436
static int parse_field_width(const char *&c, qsizetype size)
Definition qstring.cpp:7417
Qt::strong_ordering compareThreeWay(const QByteArrayView &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6806
#define qUtf16Printable(string)
Definition qstring.h:1697
qsizetype occurrences
Definition qstring.cpp:8631
qsizetype escape_len
Definition qstring.cpp:8634
qsizetype locale_occurrences
Definition qstring.cpp:8632
\inmodule QtCore \reentrant
Definition qchar.h:18
constexpr char16_t unicode() const noexcept
Converts a Latin-1 character to an 16-bit-encoded Unicode representation of the character.
Definition qchar.h:22
constexpr QLatin1Char(char c) noexcept
Constructs a Latin-1 character for c.
Definition qchar.h:20
@ BlankBeforePositive
Definition qlocale_p.h:270
@ AddTrailingZeroes
Definition qlocale_p.h:267
static int difference(char lhs, char rhs)