|
Blender V4.3
|
#include "BKE_idtype.hh"#include "BKE_lib_id.hh"#include "BKE_main.hh"#include "BKE_main_namemap.hh"#include "BLI_assert.h"#include "BLI_bitmap.h"#include "BLI_ghash.h"#include "BLI_listbase.h"#include "BLI_map.hh"#include "BLI_math_base.hh"#include "BLI_set.hh"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_string_utils.hh"#include "DNA_ID.h"#include "MEM_guardedalloc.h"#include "CLG_log.h"Go to the source code of this file.
Classes | |
| struct | UniqueName_Key |
| struct | UniqueName_Value |
| struct | UniqueName_TypeMap |
| struct | UniqueName_Map |
| struct | Uniqueness_Key |
Macros | |
| #define | MAX_NUMBER 1000000000 |
| #define | MIN_NUMBER 1 |
Functions | |
| static bool | id_name_final_build (char *name, char *base_name, size_t base_name_len, int number) |
| UniqueName_Map * | BKE_main_namemap_create () |
| void | BKE_main_namemap_destroy (UniqueName_Map **r_name_map) |
| void | BKE_main_namemap_clear (Main *bmain) |
| static void | main_namemap_populate (UniqueName_Map *name_map, Main *bmain, Library *library, ID *ignore_id, const bool do_global) |
| static UniqueName_Map * | get_namemap_for (Main *bmain, ID *id, const bool ensure_created, const bool do_global) |
| static bool | namemap_add_name (UniqueName_Map *name_map, ID *id, const char *name, const int number) |
| bool | BKE_main_namemap_get_name (Main *bmain, ID *id, char *name, const bool do_unique_in_bmain) |
| static void | namemap_remove_name (UniqueName_Map *name_map, ID *id, const char *name) |
| void | BKE_main_namemap_remove_name (Main *bmain, ID *id, const char *name) |
| static bool | main_namemap_validate_and_fix (Main *bmain, const bool do_fix) |
| bool | BKE_main_namemap_validate_and_fix (Main *bmain) |
| bool | BKE_main_namemap_validate (Main *bmain) |
Variables | |
| static CLG_LogRef | LOG = {"bke.main_namemap"} |
| #define MAX_NUMBER 1000000000 |
Definition at line 38 of file main_namemap.cc.
Referenced by id_name_final_build(), and UniqueName_Value::mark_used().
| #define MIN_NUMBER 1 |
Definition at line 40 of file main_namemap.cc.
Referenced by BKE_main_namemap_get_name(), main_namemap_populate(), and namemap_remove_name().
| 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().
|
static |
Definition at line 267 of file main_namemap.cc.
References BKE_main_namemap_create(), main_namemap_populate(), Main::name_map, and Main::name_map_global.
Referenced by BKE_main_namemap_get_name(), BKE_main_namemap_remove_name(), and main_namemap_validate_and_fix().
|
static |
Helper building final ID name from given base_name and number.
If everything goes well and we do generate a valid final ID name in given name, we return true. In case the final name would overflow the allowed ID name length, or given number is bigger than maximum allowed value, we truncate further the base_name (and given name, which is assumed to have the same 'base_name' part), and return false.
Definition at line 50 of file main_namemap.cc.
References BLI_str_utf8_invalid_strip(), BLI_strncpy(), MAX_NAME, MAX_NUMBER, and SNPRINTF_RLEN.
Referenced by BKE_main_namemap_get_name().
|
static |
Definition at line 224 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_assert_msg, BLI_string_split_name_number(), UniqueName_Map::find_by_type(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, UniqueName_TypeMap::full_names, GS, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_or_add_default(), UniqueName_Value::mark_used(), MIN_NUMBER, UniqueName_Key::name, STRNCPY, and UniqueName_Map::type_maps.
Referenced by get_namemap_for().
|
static |
Definition at line 470 of file main_namemap.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), BKE_id_new_name_validate(), BKE_idtype_idcode_iter_step(), BKE_main_namemap_clear(), BLI_assert, BLI_strncpy(), CLOG_ERROR, CLOG_INFO, CLOG_WARN, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), UniqueName_Map::find_by_type(), ListBase::first, FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, UniqueName_TypeMap::full_names, get_namemap_for(), GS, id_name(), is_valid, lib, Uniqueness_Key::lib, Main::libraries, LISTBASE_FOREACH_MUTABLE, LOG, MAX_NAME, UniqueName_Key::name, Uniqueness_Key::name, Main::name_map, RenameExistingNever, STRNCPY, and which_libbase().
Referenced by BKE_main_namemap_validate(), and BKE_main_namemap_validate_and_fix().
|
static |
Definition at line 296 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, UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, GS, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_or_add(), UniqueName_Value::mark_used(), MAX_NAME, UniqueName_Key::name, and STRNCPY.
Referenced by BKE_main_namemap_get_name().
|
static |
Definition at line 408 of file main_namemap.cc.
References UniqueName_TypeMap::base_name_to_num_suffix, BLI_assert, BLI_string_split_name_number(), UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, GS, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), UniqueName_Value::mark_unused(), MAX_NAME, UniqueName_Value::max_value, MIN_NUMBER, UniqueName_Key::name, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove(), and STRNCPY.
Referenced by BKE_main_namemap_remove_name().
|
static |
Definition at line 31 of file main_namemap.cc.
Referenced by main_namemap_validate_and_fix().