|
Blender V4.3
|
#include "BLI_compiler_attrs.h"Go to the source code of this file.
Functions | |
| UniqueName_Map * | BKE_main_namemap_create () ATTR_WARN_UNUSED_RESULT |
| void | BKE_main_namemap_destroy (UniqueName_Map **r_name_map) ATTR_NONNULL() |
| void | BKE_main_namemap_clear (Main *bmain) ATTR_NONNULL() |
| bool | BKE_main_namemap_get_name (Main *bmain, ID *id, char *name, const bool do_unique_in_bmain) ATTR_NONNULL() |
| void | BKE_main_namemap_remove_name (Main *bmain, ID *id, const char *name) ATTR_NONNULL() |
| bool | BKE_main_namemap_validate (Main *bmain) ATTR_NONNULL() |
| bool | BKE_main_namemap_validate_and_fix (Main *bmain) ATTR_NONNULL() |
API to ensure name uniqueness.
Main database contains the UniqueName_Map which is a cache that tracks names, base names and their suffixes currently in use. So that whenever a new name has to be assigned or validated, it can quickly ensure uniqueness and adjust the name in case of collisions.
BKE_main_namemap_ Should be used for functions in this file. Definition in file BKE_main_namemap.hh.
| void BKE_main_namemap_clear | ( | Main * | bmain | ) |
Destroy all name_maps in given bmain:
Definition at line 201 of file main_namemap.cc.
References BKE_main_namemap_destroy(), and Main::next.
Referenced by BKE_blendfile_override(), BKE_main_merge(), blo_join_main(), blo_split_main(), main_namemap_validate_and_fix(), and swap_old_bmain_data_for_blendfile().
| UniqueName_Map * BKE_main_namemap_create | ( | ) |
Definition at line 179 of file main_namemap.cc.
Referenced by get_namemap_for().
| void BKE_main_namemap_destroy | ( | UniqueName_Map ** | r_name_map | ) |
Definition at line 185 of file main_namemap.cc.
References printf.
Referenced by BKE_lib_override_library_create_from_id(), BKE_lib_override_library_main_resync(), BKE_lib_override_library_resync(), BKE_main_clear(), BKE_main_namemap_clear(), lib_override_library_create_do(), and library_runtime_reset().
| bool BKE_main_namemap_get_name | ( | Main * | bmain, |
| ID * | id, | ||
| char * | name, | ||
| const bool | do_unique_in_bmain ) |
Ensures the given name is unique within the given ID type.
In case of name collisions, the name will be adjusted to be unique.
| do_unique_in_bmain | if true, ensure that the final name is unique in the whole Main (for the given ID type), not only in the set of IDs from the same library. |
Definition at line 315 of file main_namemap.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), UniqueName_TypeMap::base_name_to_num_suffix, BLI_assert, BLI_string_split_name_number(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, get_namemap_for(), GS, id_name_final_build(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_or_add_cb(), UniqueName_Value::mark_used(), MAX_NAME, UniqueName_Value::max_value, MIN_NUMBER, UniqueName_Key::name, namemap_add_name(), STRNCPY, UniqueName_Value::use_if_unused(), and UniqueName_Value::use_smallest_unused().
Referenced by BKE_id_new_name_validate(), blender::bke::tests::change_lib(), blender::bke::tests::change_name_global(), lib_override_library_create_from(), and blender::bke::tests::TEST().
Remove a given name from usage.
Call this whenever deleting or renaming an object.
Definition at line 433 of file main_namemap.cc.
References BLI_assert, get_namemap_for(), and namemap_remove_name().
Referenced by BKE_id_move_to_same_lib(), BKE_lib_id_clear_library_data(), BKE_lib_override_library_update(), BKE_libblock_management_main_remove(), BKE_libblock_rename(), blender::bke::tests::change_lib(), blender::bke::tests::change_name_global(), id_delete(), id_free(), and reuse_bmain_move_id().
| bool BKE_main_namemap_validate | ( | Main * | bmain | ) |
Check that all ID names in given bmain are unique (per ID type and library), and that existing name maps are consistent with existing relevant IDs.
This is typically called within an assert, or in tests.
Definition at line 618 of file main_namemap.cc.
References main_namemap_validate_and_fix().
Referenced by BKE_lib_override_library_main_resync(), BKE_lib_override_library_main_update(), BKE_main_merge(), setup_app_data(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), and WM_file_read().
| bool BKE_main_namemap_validate_and_fix | ( | Main * | bmain | ) |
Same as BKE_main_namemap_validate, but also fixes any issue by re-generating all name maps, and ensuring again all ID names are unique.
This is typically only used in do_versions code to fix broken files.
Definition at line 611 of file main_namemap.cc.
References BLI_assert, is_valid, and main_namemap_validate_and_fix().
Referenced by after_liblink_merged_bmain_process(), blo_do_versions_300(), do_versions_after_setup(), and write_file_main_validate_pre().