WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZMap.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2016 Bob Dinitto
4  *
5  * Filename: ZMap.h
6  * Created on: 2/1/2016
7  * Author: Bob Dinitto
8  *
9  * Zuble is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef ZMAP_H
26 #define ZMAP_H
27 
28 #include <QObject>
29 #include <QVariant>
30 #include <QMap>
31 #include <QJSValue>
32 
33 namespace Zbl
34 {
35 
40 class ZMap : public QObject
41 {
42  Q_OBJECT
43 
44  typedef QMap<QString, QJSValue> zMap;
45 public:
46  explicit ZMap(QObject *parent = 0);
47 
52  static void registerType();
53 
54 
59  Q_PROPERTY(int size READ getSize)
60 
61  int getSize();
62 
63 
64 
65 
72  Q_INVOKABLE bool has(const QString& key);
73 
81  Q_INVOKABLE QJSValue get(const QString& key);
82 
89  Q_INVOKABLE QVariantList keys();
90 
91 //signals:
92 
93 public slots:
94 
105  void set(const QString& key, QJSValue value);
106 
114  bool remove(const QString& key);
115 
116 
120  void clear();
121 
122 
123 protected:
124 
125  zMap m_map;
126 };
127 
128 
129 } // Zbl
130 
131 
132 #endif // ZMAP_H
A Javascript dictionary object.
Definition: ZMap.h:40
void clear()
Remove all key/value pairs from the map.
Definition: ZMap.cpp:87
QMap< QString, QJSValue > zMap
Definition: ZMap.h:44
Definition: ZAndGate.cpp:6
Q_INVOKABLE QVariantList keys()
Obtain the key names in the map.
Definition: ZMap.cpp:66
ZMap(QObject *parent=0)
Definition: ZMap.cpp:31
Q_INVOKABLE bool has(const QString &key)
Returns true if the map contains the specified key.
Definition: ZMap.cpp:46
int size
The number of items in the map.
Definition: ZMap.h:59
int getSize()
Definition: ZMap.cpp:41
zMap m_map
Definition: ZMap.h:125
static void registerType()
Register ZMailbox as a QML type.
Definition: ZMap.cpp:36