blob: 4164aa02dd1efa21f3b2318ce851295d8c645622 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [qjs-as-container]
class Cache : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
Q_INVOKABLE QJSValue lookup(const QString &key) {
if (auto it = m_cache.constFind(key); it != m_cache.constEnd()) {
return *it; // impicit conversion
} else {
return QJSValue::UndefinedValue; // implicit conversion
}
}
QHash<QString, QString> m_cache;
}
//! [qjs-as-container]
|