Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmljsannotation_p.h
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
4#ifndef QQMLJSANNOTATION_P_H
5#define QQMLJSANNOTATION_P_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#include <QtCore/qglobal.h>
18#include <QtCore/qhash.h>
19
20#include <variant>
21
23
28
30{
31 using Value = std::variant<QString, double>;
32
34 QHash<QString, Value> bindings;
35
36 bool isDeprecation() const;
38
39 friend bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) {
40 return a.name == b.name &&
41 a.bindings == b.bindings;
42 }
43
44 friend bool operator!=(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) {
45 return !(a == b);
46 }
47
48 friend size_t qHash(const QQmlJSAnnotation &annotation, size_t seed = 0)
49 {
51 seed = combine(seed, annotation.name);
52
53 for (auto it = annotation.bindings.constBegin(); it != annotation.bindings.constEnd(); ++it) {
54 size_t h = combine(seed, it.key());
55 // use + to keep the result independent of the ordering of the keys
56
57 const auto &var = it.value();
58
59 if (var.index() == std::variant_npos)
60 continue;
61
62 if (std::holds_alternative<double>(var))
63 seed += combine(h, std::get<double>(var));
64 else if (std::holds_alternative<QString>(var))
65 seed += combine(h, std::get<QString>(var));
66 else
67 Q_UNREACHABLE();
68 }
69
70 return seed;
71 }
72};
73
75
76#endif // QQMLJSANNOTATION_P_H
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1219
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1215
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSet< QString >::iterator it
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLfloat GLfloat GLfloat GLfloat h
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
QQQmlJSDeprecation deprecation() const
friend bool operator!=(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b)
QHash< QString, Value > bindings
friend size_t qHash(const QQmlJSAnnotation &annotation, size_t seed=0)
friend bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b)
bool isDeprecation() const
std::variant< QString, double > Value