Blender  V3.3
Functions
BKE_main_namemap.h File Reference
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Functions

struct UniqueName_MapBKE_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()
 

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

Definition in file BKE_main_namemap.h.

Function Documentation

◆ BKE_main_namemap_create()

struct UniqueName_Map* BKE_main_namemap_create ( void  )

Definition at line 176 of file main_namemap.cc.

References map.

Referenced by get_namemap_for().

◆ BKE_main_namemap_destroy()

void BKE_main_namemap_destroy ( struct UniqueName_Map **  r_name_map)

◆ BKE_main_namemap_get_name()

bool BKE_main_namemap_get_name ( struct Main bmain,
struct ID id,
char *  name 
)

◆ BKE_main_namemap_remove_name()

void BKE_main_namemap_remove_name ( struct Main bmain,
struct ID id,
const char *  name 
)

◆ BKE_main_namemap_validate()

bool BKE_main_namemap_validate ( struct 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 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().

◆ BKE_main_namemap_validate_and_fix()

bool BKE_main_namemap_validate_and_fix ( struct 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 490 of file main_namemap.cc.

References BLI_assert, is_valid, and main_namemap_validate_and_fix().

Referenced by blo_do_versions_300().