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
qqmljsannotation.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant
4
6
8
9bool QQmlJSAnnotation::isDeprecation() const { return name == QStringLiteral("Deprecated"); }
10
12 Q_ASSERT(isDeprecation());
13 QQQmlJSDeprecation deprecation;
14 if (bindings.contains(QStringLiteral("reason"))) {
15
16 auto reason = bindings[QStringLiteral("reason")];
17
18 if (std::holds_alternative<QString>(reason)) {
19 deprecation.reason = std::get<QString>(reason);
20 }
21 }
22
23 return deprecation;
24}
25
26// hidden friend
27bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) noexcept
28{
29 return a.name == b.name &&
30 a.bindings == b.bindings;
31}
32
33// hidden friend
34size_t qHash(const QQmlJSAnnotation &annotation, size_t seed) noexcept
35{
36 QtPrivate::QHashCombine combine(seed);
37 seed = combine(seed, annotation.name);
38
39 for (auto it = annotation.bindings.constBegin(); it != annotation.bindings.constEnd(); ++it) {
40 size_t h = combine(seed, it.key());
41 // use + to keep the result independent of the ordering of the keys
42
43 const auto &var = it.value();
44
45 if (var.valueless_by_exception())
46 continue;
47
48 if (auto v = get_if<double>(&var))
49 seed += combine(h, *v);
50 else if (auto v = get_if<QString>(&var))
51 seed += combine(h, *v);
52 else
53 Q_UNREACHABLE();
54 }
55
56 return seed;
57}
58
59QT_END_NAMESPACE
Combined button and popup list for selecting options.
bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) noexcept
size_t qHash(const QQmlJSAnnotation &annotation, size_t seed) noexcept
QQQmlJSDeprecation deprecation() const
bool isDeprecation() const