Blender V5.0
BKE_main_namemap.hh File Reference

Go to the source code of this file.

Functions

void BKE_main_namemap_destroy (UniqueName_Map **r_name_map) ATTR_NONNULL()
void BKE_main_namemap_clear (Main &bmain)
bool BKE_main_global_namemap_contain_name (Main &bmain, short id_type, blender::StringRef name)
bool BKE_main_namemap_contain_name (Main &bmain, Library *lib, short id_type, blender::StringRef name)
bool BKE_main_global_namemap_get_unique_name (Main &bmain, ID &id, char *r_name)
bool BKE_main_namemap_get_unique_name (Main &bmain, ID &id, char *r_name)
void BKE_main_namemap_remove_id (Main &bmain, ID &id)
bool BKE_main_namemap_validate (Main &bmain)
bool BKE_main_namemap_validate_and_fix (Main &bmain)

Detailed Description

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.

Names

  • BKE_main_namemap_ Should be used for functions in this file.

Definition in file BKE_main_namemap.hh.

Function Documentation

◆ BKE_main_global_namemap_contain_name()

bool BKE_main_global_namemap_contain_name ( Main & bmain,
short id_type,
blender::StringRef name )

Check if the given name is already in use in the whole Main data-base (local and all linked data).

Returns
true if the name is already in use.

Definition at line 409 of file main_namemap.cc.

References BLI_assert, Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), UniqueName_Map::find_by_type(), UniqueName_TypeMap::full_names, get_global_namemap_for(), MAX_ID_NAME, and name.

◆ BKE_main_global_namemap_get_unique_name()

bool BKE_main_global_namemap_get_unique_name ( Main & bmain,
ID & id,
char * r_name )

Ensures the given name is unique within the given ID type, in the whole Main data-base (local and all linked data).

In case of name collisions, the name will be adjusted to be unique.

Returns
true if the name had to be adjusted for uniqueness.

Definition at line 591 of file main_namemap.cc.

References BLI_assert, BLI_strncpy(), MAX_ID_NAME, and namemap_get_name().

Referenced by blender::bke::tests::change_name_global(), and lib_override_library_create_from().

◆ BKE_main_namemap_clear()

void BKE_main_namemap_clear ( Main & bmain)

Destroy all name_maps in given bmain:

  • In bmain itself for local IDs.
  • In the split bmains in the list is any (for linked IDs in some cases, e.g. if called during readfile code).
  • In all of the libraries IDs (for linked IDs).

Definition at line 346 of file main_namemap.cc.

References BKE_main_namemap_destroy(), BLI_assert_msg, and Main::split_mains.

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().

◆ BKE_main_namemap_contain_name()

bool BKE_main_namemap_contain_name ( Main & bmain,
Library * lib,
short id_type,
blender::StringRef name )

◆ BKE_main_namemap_destroy()

◆ BKE_main_namemap_get_unique_name()

bool BKE_main_namemap_get_unique_name ( Main & bmain,
ID & id,
char * r_name )

Same as #BKE_main_global_namemap_get_name, but only make the name unique in the local or related library namemap.

Definition at line 582 of file main_namemap.cc.

References BLI_assert, BLI_strncpy(), MAX_ID_NAME, and namemap_get_name().

Referenced by BKE_id_new_name_validate(), blender::bke::tests::change_lib(), and blender::bke::tests::TEST().

◆ BKE_main_namemap_remove_id()

◆ BKE_main_namemap_validate()

◆ BKE_main_namemap_validate_and_fix()

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 764 of file main_namemap.cc.

References BLI_assert, 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().