Blender V4.3
main_namemap.cc File Reference
#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_MapBKE_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_Mapget_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"}
 

Macro Definition Documentation

◆ MAX_NUMBER

#define MAX_NUMBER   1000000000

Definition at line 38 of file main_namemap.cc.

Referenced by id_name_final_build(), and UniqueName_Value::mark_used().

◆ MIN_NUMBER

#define MIN_NUMBER   1

Function Documentation

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

◆ BKE_main_namemap_create()

UniqueName_Map * BKE_main_namemap_create ( )

Definition at line 179 of file main_namemap.cc.

Referenced by get_namemap_for().

◆ BKE_main_namemap_destroy()

◆ BKE_main_namemap_get_name()

◆ BKE_main_namemap_remove_name()

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

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

◆ get_namemap_for()

static UniqueName_Map * get_namemap_for ( Main * bmain,
ID * id,
const bool ensure_created,
const bool do_global )
static

◆ id_name_final_build()

static bool id_name_final_build ( char * name,
char * base_name,
size_t base_name_len,
int number )
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().

◆ main_namemap_populate()

◆ main_namemap_validate_and_fix()

◆ namemap_add_name()

◆ namemap_remove_name()

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.main_namemap"}
static

Definition at line 31 of file main_namemap.cc.

Referenced by main_namemap_validate_and_fix().