summaryrefslogtreecommitdiff
path: root/core/dictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/dictionary.cpp')
-rw-r--r--core/dictionary.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 75c8531251..6770b798f1 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -199,6 +199,18 @@ Array Dictionary::keys() const {
}
+Array Dictionary::values() const {
+
+ Array varr;
+ varr.resize(size());
+ const Variant *key=NULL;
+ int i=0;
+ while((key=next(key))){
+ varr[i++] = _p->variant_map[*key];
+ }
+ return varr;
+}
+
const Variant* Dictionary::next(const Variant* p_key) const {
return _p->variant_map.next(p_key);
@@ -220,6 +232,20 @@ Error Dictionary::parse_json(const String& p_json) {
return OK;
}
+Dictionary Dictionary::copy() const {
+
+ Dictionary n(is_shared());
+
+ List<Variant> keys;
+ get_key_list(&keys);
+
+ for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ n[E->get()]=operator[](E->get());
+ }
+
+ return n;
+}
+
String Dictionary::to_json() const {
return JSON::print(*this);
@@ -250,5 +276,3 @@ Dictionary::~Dictionary() {
_unref();
}
-
-