Blender  V3.3
Classes | Macros | Functions | Variables
main_namemap.cc File Reference
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_main_namemap.h"
#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_utf8.h"
#include "BLI_string_utils.h"
#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)
 
struct UniqueName_MapBKE_main_namemap_create ()
 
void BKE_main_namemap_destroy (struct UniqueName_Map **r_name_map)
 
static void main_namemap_populate (UniqueName_Map *name_map, struct Main *bmain, ID *ignore_id)
 
static UniqueName_Mapget_namemap_for (Main *bmain, ID *id, bool ensure_created)
 
bool BKE_main_namemap_get_name (struct Main *bmain, struct ID *id, char *name)
 
void BKE_main_namemap_remove_name (struct Main *bmain, struct 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 35 of file main_namemap.cc.

◆ MIN_NUMBER

#define MIN_NUMBER   1

Definition at line 37 of file main_namemap.cc.

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

◆ get_namemap_for()

static UniqueName_Map* get_namemap_for ( Main bmain,
ID id,
bool  ensure_created 
)
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 47 of file main_namemap.cc.

References ARRAY_SIZE, BLI_snprintf_rlen(), BLI_str_utf8_invalid_strip(), BLI_strncpy(), MAX_NAME, and MAX_NUMBER.

Referenced by BKE_main_namemap_get_name().

◆ main_namemap_populate()

static void main_namemap_populate ( UniqueName_Map name_map,
struct Main bmain,
ID ignore_id 
)
static

◆ main_namemap_validate_and_fix()

static bool main_namemap_validate_and_fix ( Main bmain,
const bool  do_fix 
)
static

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.main_namemap"}
static

Definition at line 28 of file main_namemap.cc.

Referenced by main_namemap_validate_and_fix().