diff options
-rw-r--r-- | source/blender/blenlib/BLI_serialize.hh | 18 | ||||
-rw-r--r-- | source/blender/blenlib/intern/serialize.cc | 18 | ||||
-rw-r--r-- | source/blender/blenlib/tests/BLI_serialize_test.cc | 4 | ||||
-rw-r--r-- | source/blender/editors/asset/intern/asset_indexer.cc | 36 |
4 files changed, 38 insertions, 38 deletions
diff --git a/source/blender/blenlib/BLI_serialize.hh b/source/blender/blenlib/BLI_serialize.hh index 051731ab801..b1002b07fd3 100644 --- a/source/blender/blenlib/BLI_serialize.hh +++ b/source/blender/blenlib/BLI_serialize.hh @@ -36,7 +36,7 @@ * - DoubleValue: for double precision floating point numbers * - BooleanValue: for boolean values * - ArrayValue: An array of any supported value. - * - ObjectValue: A key value pair where keys are std::string. + * - DictionaryValue: A key value pair where keys are std::string. * - NullValue: for null values. * * # Basic usage @@ -97,7 +97,7 @@ enum class eValueType { class Value; class StringValue; -class ObjectValue; +class DictionaryValue; template<typename T, eValueType V> class PrimitiveValue; using IntValue = PrimitiveValue<int64_t, eValueType::Int>; using DoubleValue = PrimitiveValue<double, eValueType::Double>; @@ -122,7 +122,7 @@ using ArrayValue = ContainerValue<Vector<std::shared_ptr<Value>>, eValueType::Ar * - `NullValue`: represents nothing (null pointer or optional). * - `BooleanValue`: contains a boolean (true/false). * - `DoubleValue`: contains a double precision floating point number. - * - `ObjectValue`: represents an object (key value pairs where keys are strings and values can be + * - `DictionaryValue`: represents an object (key value pairs where keys are strings and values can be * of different types. * */ @@ -174,10 +174,10 @@ class Value { const ArrayValue *as_array_value() const; /** - * Casts to an ObjectValue. + * Casts to an DictionaryValue. * Will return nullptr when it is a different type. */ - const ObjectValue *as_object_value() const; + const DictionaryValue *as_object_value() const; }; /** @@ -228,7 +228,7 @@ class StringValue : public Value { /** * Template for arrays and objects. * - * Both ArrayValue and ObjectValue store their values in an array. + * Both ArrayValue and DictionaryValue store their values in an array. */ template< /** The container type where the elements are stored in. */ @@ -264,10 +264,10 @@ class ContainerValue : public Value { }; /** - * Internal storage type for ObjectValue. + * Internal storage type for DictionaryValue. * * The elements are stored as an key value pair. The value is a shared pointer so it can be shared - * when using `ObjectValue::create_lookup`. + * when using `DictionaryValue::create_lookup`. */ using ObjectElementType = std::pair<std::string, std::shared_ptr<Value>>; @@ -275,7 +275,7 @@ using ObjectElementType = std::pair<std::string, std::shared_ptr<Value>>; * Object is a key-value container where the key must be a std::string. * Internally it is stored in a blender::Vector to ensure the order of keys. */ -class ObjectValue : public ContainerValue<Vector<ObjectElementType>, eValueType::Object> { +class DictionaryValue : public ContainerValue<Vector<ObjectElementType>, eValueType::Object> { public: using LookupValue = std::shared_ptr<Value>; using Lookup = Map<std::string, LookupValue>; diff --git a/source/blender/blenlib/intern/serialize.cc b/source/blender/blenlib/intern/serialize.cc index 52aff140e3e..a17d7a189f6 100644 --- a/source/blender/blenlib/intern/serialize.cc +++ b/source/blender/blenlib/intern/serialize.cc @@ -44,12 +44,12 @@ const ArrayValue *Value::as_array_value() const return static_cast<const ArrayValue *>(this); } -const ObjectValue *Value::as_object_value() const +const DictionaryValue *Value::as_object_value() const { if (type_ != eValueType::Object) { return nullptr; } - return static_cast<const ObjectValue *>(this); + return static_cast<const DictionaryValue *>(this); } static void convert_to_json(nlohmann::ordered_json &j, const Value &value); @@ -66,13 +66,13 @@ static void convert_to_json(nlohmann::ordered_json &j, const ArrayValue &value) } } -static void convert_to_json(nlohmann::ordered_json &j, const ObjectValue &value) +static void convert_to_json(nlohmann::ordered_json &j, const DictionaryValue &value) { - const ObjectValue::Items &attributes = value.elements(); + const DictionaryValue::Items &attributes = value.elements(); /* Create a json object to store the attributes. If this isn't done and attributes is empty it * would return use a null value, in stead of an empty object. */ j = "{}"_json; - for (const ObjectValue::Item &attribute : attributes) { + for (const DictionaryValue::Item &attribute : attributes) { nlohmann::ordered_json json_item; convert_to_json(json_item, *attribute.second); j[attribute.first] = json_item; @@ -99,7 +99,7 @@ static void convert_to_json(nlohmann::ordered_json &j, const Value &value) } case eValueType::Object: { - const ObjectValue &object = *value.as_object_value(); + const DictionaryValue &object = *value.as_object_value(); convert_to_json(j, object); break; } @@ -133,10 +133,10 @@ static std::unique_ptr<ArrayValue> convert_from_json_to_array(const nlohmann::or return array; } -static std::unique_ptr<ObjectValue> convert_from_json_to_object(const nlohmann::ordered_json &j) +static std::unique_ptr<DictionaryValue> convert_from_json_to_object(const nlohmann::ordered_json &j) { - std::unique_ptr<ObjectValue> object = std::make_unique<ObjectValue>(); - ObjectValue::Items &elements = object->elements(); + std::unique_ptr<DictionaryValue> object = std::make_unique<DictionaryValue>(); + DictionaryValue::Items &elements = object->elements(); for (auto element : j.items()) { std::string key = element.key(); nlohmann::ordered_json element_json = element.value(); diff --git a/source/blender/blenlib/tests/BLI_serialize_test.cc b/source/blender/blenlib/tests/BLI_serialize_test.cc index 6c55a85ca1e..120fcdc3e81 100644 --- a/source/blender/blenlib/tests/BLI_serialize_test.cc +++ b/source/blender/blenlib/tests/BLI_serialize_test.cc @@ -93,8 +93,8 @@ TEST(serialize, object_to_json) { JsonFormatter json; std::stringstream out; - ObjectValue value_object; - ObjectValue::Items &attributes = value_object.elements(); + DictionaryValue value_object; + DictionaryValue::Items &attributes = value_object.elements(); attributes.append_as(std::pair(std::string("best_number"), new IntValue(42))); json.serialize(out, value_object); diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index fa55560d3c8..87fbda068f2 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -145,7 +145,7 @@ struct AssetEntryReader { /** * \brief Lookup table containing the elements of the entry. */ - ObjectValue::Lookup lookup; + DictionaryValue::Lookup lookup; StringRefNull get_name_with_idcode() const { @@ -153,7 +153,7 @@ struct AssetEntryReader { } public: - AssetEntryReader(const ObjectValue &entry) : lookup(entry.create_lookup()) + AssetEntryReader(const DictionaryValue &entry) : lookup(entry.create_lookup()) { } @@ -204,7 +204,7 @@ struct AssetEntryReader { void add_tags_to_meta_data(AssetMetaData *asset_data) const { - const ObjectValue::LookupValue *value_ptr = lookup.lookup_ptr(ATTRIBUTE_ENTRIES_TAGS); + const DictionaryValue::LookupValue *value_ptr = lookup.lookup_ptr(ATTRIBUTE_ENTRIES_TAGS); if (value_ptr == nullptr) { return; } @@ -220,10 +220,10 @@ struct AssetEntryReader { struct AssetEntryWriter { private: - ObjectValue::Items &attributes; + DictionaryValue::Items &attributes; public: - AssetEntryWriter(ObjectValue &entry) : attributes(entry.elements()) + AssetEntryWriter(DictionaryValue &entry) : attributes(entry.elements()) { } @@ -301,7 +301,7 @@ static void init_value_from_file_indexer_entry(AssetEntryWriter &result, /* TODO: asset_data.IDProperties */ } -static void init_value_from_file_indexer_entries(ObjectValue &result, +static void init_value_from_file_indexer_entries(DictionaryValue &result, const FileIndexerEntries &indexer_entries) { ArrayValue *entries = new ArrayValue(); @@ -313,7 +313,7 @@ static void init_value_from_file_indexer_entries(ObjectValue &result, if (indexer_entry->datablock_info.asset_data == nullptr) { continue; } - ObjectValue *entry_value = new ObjectValue(); + DictionaryValue *entry_value = new DictionaryValue(); AssetEntryWriter entry(*entry_value); init_value_from_file_indexer_entry(entry, indexer_entry); items.append_as(entry_value); @@ -326,7 +326,7 @@ static void init_value_from_file_indexer_entries(ObjectValue &result, return; } - ObjectValue::Items &attributes = result.elements(); + DictionaryValue::Items &attributes = result.elements(); attributes.append_as(std::pair(ATTRIBUTE_ENTRIES, entries)); } @@ -366,10 +366,10 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, } static int init_indexer_entries_from_value(FileIndexerEntries &indexer_entries, - const ObjectValue &value) + const DictionaryValue &value) { - const ObjectValue::Lookup attributes = value.create_lookup(); - const ObjectValue::LookupValue *entries_value = attributes.lookup_ptr(ATTRIBUTE_ENTRIES); + const DictionaryValue::Lookup attributes = value.create_lookup(); + const DictionaryValue::LookupValue *entries_value = attributes.lookup_ptr(ATTRIBUTE_ENTRIES); BLI_assert(entries_value != nullptr); if (entries_value == nullptr) { @@ -534,7 +534,7 @@ struct AssetIndex { /** * `blender::io::serialize::Value` representing the contents of an index file. * - * Value is used over #ObjectValue as the contents of the index could be corrupted and doesn't + * Value is used over #DictionaryValue as the contents of the index could be corrupted and doesn't * represent an object. In case corrupted files are detected the `get_version` would return * `UNKNOWN_VERSION`. */ @@ -546,8 +546,8 @@ struct AssetIndex { */ AssetIndex(const FileIndexerEntries &indexer_entries) { - std::unique_ptr<ObjectValue> root = std::make_unique<ObjectValue>(); - ObjectValue::Items &root_attributes = root->elements(); + std::unique_ptr<DictionaryValue> root = std::make_unique<DictionaryValue>(); + DictionaryValue::Items &root_attributes = root->elements(); root_attributes.append_as(std::pair(ATTRIBUTE_VERSION, new IntValue(CURRENT_VERSION))); init_value_from_file_indexer_entries(*root, indexer_entries); @@ -564,12 +564,12 @@ struct AssetIndex { int get_version() const { - const ObjectValue *root = contents->as_object_value(); + const DictionaryValue *root = contents->as_object_value(); if (root == nullptr) { return UNKNOWN_VERSION; } - const ObjectValue::Lookup attributes = root->create_lookup(); - const ObjectValue::LookupValue *version_value = attributes.lookup_ptr(ATTRIBUTE_VERSION); + const DictionaryValue::Lookup attributes = root->create_lookup(); + const DictionaryValue::LookupValue *version_value = attributes.lookup_ptr(ATTRIBUTE_VERSION); if (version_value == nullptr) { return UNKNOWN_VERSION; } @@ -588,7 +588,7 @@ struct AssetIndex { */ int extract_into(FileIndexerEntries &indexer_entries) const { - const ObjectValue *root = contents->as_object_value(); + const DictionaryValue *root = contents->as_object_value(); const int num_entries_read = init_indexer_entries_from_value(indexer_entries, *root); return num_entries_read; } |