1// Copyright (C) 2016 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#ifndef QV4IDENTIFIERHASH_P_H
4#define QV4IDENTIFIERHASH_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <qstring.h>
18#include <private/qv4global_p.h>
19#include <private/qv4propertykey_p.h>
20
21QT_BEGIN_NAMESPACE
22
23namespace QV4 {
24
25struct IdentifierHashEntry;
26struct IdentifierHashData;
27struct Q_QML_PRIVATE_EXPORT IdentifierHash
28{
29 IdentifierHash() = default;
30 IdentifierHash(ExecutionEngine *engine);
31 IdentifierHash(const IdentifierHash &other);
32 ~IdentifierHash();
33 IdentifierHash &operator=(const IdentifierHash &other);
34
35 bool isEmpty() const { return !d; }
36
37 int count() const;
38
39 void detach();
40
41 void add(const QString &str, int value);
42 void add(Heap::String *str, int value);
43
44 int value(const QString &str) const;
45 int value(String *str) const;
46 QString findId(int value) const;
47
48private:
49 inline IdentifierHashEntry *addEntry(PropertyKey i);
50 inline const IdentifierHashEntry *lookup(PropertyKey identifier) const;
51 inline const IdentifierHashEntry *lookup(const QString &str) const;
52 inline const IdentifierHashEntry *lookup(String *str) const;
53 inline const PropertyKey toIdentifier(const QString &str) const;
54 inline const PropertyKey toIdentifier(Heap::String *str) const;
55
56 IdentifierHashData *d = nullptr;
57};
58
59} // namespace QV4
60
61QT_END_NAMESPACE
62
63#endif // QV4_IDENTIFIERHASH_P_H
64

source code of qtdeclarative/src/qml/jsruntime/qv4identifierhash_p.h