Blender
V3.3
|
#include "BLI_compiler_attrs.h"
Go to the source code of this file.
Functions | |
struct UniqueName_Map * | BKE_main_namemap_create (void) ATTR_WARN_UNUSED_RESULT |
void | BKE_main_namemap_destroy (struct UniqueName_Map **r_name_map) ATTR_NONNULL() |
bool | BKE_main_namemap_get_name (struct Main *bmain, struct ID *id, char *name) ATTR_NONNULL() |
void | BKE_main_namemap_remove_name (struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL() |
bool | BKE_main_namemap_validate (struct Main *bmain) ATTR_NONNULL() |
bool | BKE_main_namemap_validate_and_fix (struct 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.h.
struct UniqueName_Map* BKE_main_namemap_create | ( | void | ) |
void BKE_main_namemap_destroy | ( | struct UniqueName_Map ** | r_name_map | ) |
Definition at line 182 of file main_namemap.cc.
References UniqueName_TypeMap::base_name_to_num_suffix, UniqueName_TypeMap::full_names, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::size_in_bytes(), and blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::size_in_bytes().
Referenced by BKE_main_free(), library_runtime_reset(), and main_namemap_validate_and_fix().
Ensures the given name is unique within the given ID type.
In case of name collisions, the name will be adjusted to be unique.
Definition at line 248 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_split_name_num(), BLI_strncpy(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, get_namemap_for(), GS, id, 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, ID::name, UniqueName_Key::name, UniqueName_Value::use_if_unused(), and UniqueName_Value::use_smallest_unused().
Referenced by BKE_id_new_name_validate(), blender::bke::tests::change_lib(), and wm_window_match_keep_current_wm().
Remove a given name from usage.
Call this whenever deleting or renaming an object.
Definition at line 333 of file main_namemap.cc.
References UniqueName_TypeMap::base_name_to_num_suffix, BLI_assert, BLI_split_name_num(), BLI_strncpy(), UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, get_namemap_for(), GS, id, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), UniqueName_Value::mark_unused(), MAX_NAME, UniqueName_Value::max_value, MIN_NUMBER, ID::name, UniqueName_Key::name, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove(), and blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove().
Referenced by BKE_id_free_ex(), BKE_lib_id_clear_library_data(), BKE_lib_override_library_update(), BKE_libblock_management_main_remove(), BKE_libblock_rename(), BLO_update_defaults_startup_blend(), blender::bke::tests::change_lib(), blender::bke::tests::change_name(), do_versions_rename_id(), id_delete(), and namebutton_fn().
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 497 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(), blender::bke::tests::TEST(), and WM_file_read().
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 490 of file main_namemap.cc.
References BLI_assert, is_valid, and main_namemap_validate_and_fix().
Referenced by blo_do_versions_300().