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
qqmldirdata_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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// Qt-Security score:significant
4
5#ifndef QQMLDIRDATA_P_H
6#define QQMLDIRDATA_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qqmltypeloader_p.h>
20
22
23class Q_AUTOTEST_EXPORT QQmlQmldirData : public QQmlTypeLoader::Blob
24{
25private:
26 friend class QQmlTypeLoader;
27
28public:
29 QQmlQmldirData(const QUrl &, QQmlTypeLoader *);
30
31 const QString &content() const;
32 QV4::CompiledData::Location importLocation(Blob *blob) const;
33
34 template<typename Callback>
35 bool processImports(Blob *blob, const Callback &callback) const
36 {
37 assertTypeLoaderThread();
38 bool result = true;
39 const auto range = m_imports.equal_range(blob);
40 for (auto it = range.first; it != range.second; ++it) {
41 // Do we need to resolve this import?
42 if ((it->import->priority == 0) || (it->import->priority > it->priority)) {
43 // This is the (current) best resolution for this import
44 if (!callback(it->import))
45 result = false;
46 it->import->priority = it->priority;
47 }
48 }
49 return result;
50 }
51
52 void setPriority(Blob *, const PendingImportPtr &, int);
53
54protected:
55 void dataReceived(const SourceCodeData &) override;
56 void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) override;
57
58private:
59 struct PrioritizedImport {
60 PendingImportPtr import;
61 int priority = 0;
62 };
63
64 QString m_content;
65 QMultiHash<Blob *, PrioritizedImport> m_imports;
66};
67
68QT_END_NAMESPACE
69
70#endif // QQMLDIRDATA_P_H