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
9using namespace Qt::StringLiterals;
10
11bool QQmlJSAnnotation::isDeprecation() const { return name == QStringLiteral("Deprecated"); }
12
13QQQmlJSDeprecation QQmlJSAnnotation::deprecation() const {
14 Q_ASSERT(isDeprecation());
15 QQQmlJSDeprecation deprecation;
16 if (const auto it = bindings.find(u"reason"_s); it != bindings.end()) {
17 if (auto v = get_if<QString>(&it.value()))
18 deprecation.reason = *v;
19 }
20
21 return deprecation;
22}
23
24// hidden friend
25bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) noexcept
26{
27 return a.name == b.name &&
28 a.bindings == b.bindings;
29}
30
31// hidden friend
32size_t qHash(const QQmlJSAnnotation &annotation, size_t seed) noexcept
33{
34 QtPrivate::QHashCombine combine(seed);
35 seed = combine(seed, annotation.name);
36
37 for (auto it = annotation.bindings.constBegin(); it != annotation.bindings.constEnd(); ++it) {
38 size_t h = combine(seed, it.key());
39 // use + to keep the result independent of the ordering of the keys
40
41 const auto &var = it.value();
42
43 if (var.valueless_by_exception())
44 continue;
45
46 if (auto v = get_if<double>(&var))
47 seed += combine(h, *v);
48 else if (auto v = get_if<QString>(&var))
49 seed += combine(h, *v);
50 else
51 Q_UNREACHABLE();
52 }
53
54 return seed;
55}
56
57QT_END_NAMESPACE
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
Definition qbytearray.h:803
Combined button and popup list for selecting options.
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192