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
5#ifndef QSTRINGMATCHER_H
6#define QSTRINGMATCHER_H
7
8#include <QtCore/qstring.h>
9#include <QtCore/qstringview.h>
10
11QT_BEGIN_NAMESPACE
12
13
14class QStringMatcherPrivate;
15
16class Q_CORE_EXPORT QStringMatcher
17{
18 void updateSkipTable();
19public:
20 QStringMatcher() = default;
21 explicit QStringMatcher(const QString &pattern,
22 Qt::CaseSensitivity cs = Qt::CaseSensitive);
23 QStringMatcher(const QChar *uc, qsizetype len,
24 Qt::CaseSensitivity cs = Qt::CaseSensitive)
25 : QStringMatcher(QStringView(uc, len), cs)
26 {}
27 QStringMatcher(QStringView pattern,
28 Qt::CaseSensitivity cs = Qt::CaseSensitive);
29 QStringMatcher(const QStringMatcher &other);
30 ~QStringMatcher();
31
32 QStringMatcher &operator=(const QStringMatcher &other);
33
34 void setPattern(const QString &pattern);
35 void setCaseSensitivity(Qt::CaseSensitivity cs);
36
37 qsizetype indexIn(const QString &str, qsizetype from = 0) const
38 { return indexIn(str: QStringView(str), from); }
39 qsizetype indexIn(const QChar *str, qsizetype length, qsizetype from = 0) const
40 { return indexIn(str: QStringView(str, length), from); }
41 qsizetype indexIn(QStringView str, qsizetype from = 0) const;
42 QString pattern() const;
43 inline Qt::CaseSensitivity caseSensitivity() const { return q_cs; }
44
45private:
46 QStringMatcherPrivate *d_ptr = nullptr;
47 Qt::CaseSensitivity q_cs = Qt::CaseSensitive;
48 QString q_pattern;
49 QStringView q_sv;
50 uchar q_skiptable[256] = {};
51};
52
53QT_END_NAMESPACE
54
55#endif // QSTRINGMATCHER_H
56

source code of qtbase/src/corelib/text/qstringmatcher.h