1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLPREVIEWBLACKLIST_H
5#define QQMLPREVIEWBLACKLIST_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qhash.h>
19#include <QtCore/qchar.h>
20#include <QtCore/qstring.h>
21#include <algorithm>
22
23QT_BEGIN_NAMESPACE
24
25class QQmlPreviewBlacklist
26{
27public:
28 void blacklist(const QString &path);
29 void whitelist(const QString &path);
30 bool isBlacklisted(const QString &path) const;
31 void clear();
32
33private:
34 class Node {
35 public:
36 enum PrefixResult {
37 MatchedLeaf,
38 MatchedBranch,
39 Unmatched,
40 };
41
42 Node();
43 Node(const Node &other);
44 Node(Node &&other) noexcept;
45
46 ~Node();
47
48 Node &operator=(const Node &other);
49 Node &operator=(Node &&other) noexcept;
50
51 void split(QString::iterator it, QString::iterator end);
52 void insert(const QString &path, int offset);
53 void remove(const QString &path, int offset);
54 PrefixResult findPrefix(const QString &path, int offset) const;
55
56 private:
57 Node(const QString &mine, const QHash<QChar, Node *> &next = QHash<QChar, Node *>(),
58 bool isLeaf = true);
59
60 QString m_mine;
61 QHash<QChar, Node *> m_next;
62 bool m_isLeaf = false;
63 };
64
65 Node m_root;
66};
67
68QT_END_NAMESPACE
69
70#endif // QQMLPREVIEWBLACKLIST_H
71

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h