| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/templates/hash_map.h" |
| 34 |
#include "core/templates/local_vector.h" |
| 35 |
#include "core/templates/pair.h" |
| 36 |
#include "core/variant/variant_deep_duplicate.h" |
| 37 |
|
| 38 |
class Array; |
| 39 |
class StringName; |
| 40 |
class Variant; |
| 41 |
struct ContainerType; |
| 42 |
struct ContainerTypeValidate; |
| 43 |
struct DictionaryPrivate; |
| 44 |
struct StringLikeVariantComparator; |
| 45 |
|
| 46 |
class Dictionary { |
| 47 |
mutable DictionaryPrivate *_p; |
| 48 |
|
| 49 |
void _ref(const Dictionary &p_from) const; |
| 50 |
void _unref() const; |
| 51 |
|
| 52 |
public: |
| 53 |
using ConstIterator = HashMap<Variant, Variant, HashMapHasherDefault, StringLikeVariantComparator>::ConstIterator; |
| 54 |
|
| 55 |
ConstIterator begin() const; |
| 56 |
ConstIterator end() const; |
| 57 |
|
| 58 |
LocalVector<Variant> get_key_list() const; |
| 59 |
Variant get_key_at_index(int p_index) const; |
| 60 |
Variant get_value_at_index(int p_index) const; |
| 61 |
|
| 62 |
Variant &operator[](const Variant &p_key); |
| 63 |
const Variant &operator[](const Variant &p_key) const; |
| 64 |
|
| 65 |
const Variant *getptr(const Variant &p_key) const; |
| 66 |
Variant *getptr(const Variant &p_key); |
| 67 |
|
| 68 |
Variant get_valid(const Variant &p_key) const; |
| 69 |
Variant get(const Variant &p_key, const Variant &p_default) const; |
| 70 |
Variant get_or_add(const Variant &p_key, const Variant &p_default); |
| 71 |
bool set(const Variant &p_key, const Variant &p_value); |
| 72 |
|
| 73 |
int size() const; |
| 74 |
bool is_empty() const; |
| 75 |
void reserve(int p_new_capacity); |
| 76 |
void clear(); |
| 77 |
void sort(); |
| 78 |
void merge(const Dictionary &p_dictionary, bool p_overwrite = false); |
| 79 |
Dictionary merged(const Dictionary &p_dictionary, bool p_overwrite = false) const; |
| 80 |
|
| 81 |
bool has(const Variant &p_key) const; |
| 82 |
bool has_all(const Array &p_keys) const; |
| 83 |
Variant find_key(const Variant &p_value) const; |
| 84 |
|
| 85 |
bool erase(const Variant &p_key); |
| 86 |
|
| 87 |
bool operator==(const Dictionary &p_dictionary) const; |
| 88 |
bool operator!=(const Dictionary &p_dictionary) const; |
| 89 |
bool recursive_equal(const Dictionary &p_dictionary, int recursion_count) const; |
| 90 |
|
| 91 |
uint32_t hash() const; |
| 92 |
uint32_t recursive_hash(int recursion_count) const; |
| 93 |
void operator=(const Dictionary &p_dictionary); |
| 94 |
|
| 95 |
void assign(const Dictionary &p_dictionary); |
| 96 |
const Variant *next(const Variant *p_key = nullptr) const; |
| 97 |
|
| 98 |
Array keys() const; |
| 99 |
Array values() const; |
| 100 |
|
| 101 |
Dictionary duplicate(bool p_deep = false) const; |
| 102 |
Dictionary duplicate_deep(ResourceDeepDuplicateMode p_deep_subresources_mode = RESOURCE_DEEP_DUPLICATE_INTERNAL) const; |
| 103 |
Dictionary recursive_duplicate(bool p_deep, ResourceDeepDuplicateMode p_deep_subresources_mode, int recursion_count) const; |
| 104 |
|
| 105 |
void set_typed(const ContainerType &p_key_type, const ContainerType &p_value_type); |
| 106 |
void set_typed(uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script); |
| 107 |
|
| 108 |
bool is_typed() const; |
| 109 |
bool is_typed_key() const; |
| 110 |
bool is_typed_value() const; |
| 111 |
bool is_same_instance(const Dictionary &p_other) const; |
| 112 |
bool is_same_typed(const Dictionary &p_other) const; |
| 113 |
bool is_same_typed_key(const Dictionary &p_other) const; |
| 114 |
bool is_same_typed_value(const Dictionary &p_other) const; |
| 115 |
|
| 116 |
ContainerType get_key_type() const; |
| 117 |
ContainerType get_value_type() const; |
| 118 |
uint32_t get_typed_key_builtin() const; |
| 119 |
uint32_t get_typed_value_builtin() const; |
| 120 |
StringName get_typed_key_class_name() const; |
| 121 |
StringName get_typed_value_class_name() const; |
| 122 |
Variant get_typed_key_script() const; |
| 123 |
Variant get_typed_value_script() const; |
| 124 |
const ContainerTypeValidate &get_key_validator() const; |
| 125 |
const ContainerTypeValidate &get_value_validator() const; |
| 126 |
|
| 127 |
void make_read_only(); |
| 128 |
bool is_read_only() const; |
| 129 |
|
| 130 |
const void *id() const; |
| 131 |
|
| 132 |
Dictionary(const Dictionary &p_base, uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script); |
| 133 |
Dictionary(const Dictionary &p_from); |
| 134 |
Dictionary(std::initializer_list<KeyValue<Variant, Variant>> p_init); |
| 135 |
Dictionary(); |
| 136 |
~Dictionary(); |
| 137 |
}; |