Blender  V2.93
Macros | Typedefs | Functions
BLI_string_utils.h File Reference
#include <stdarg.h>
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Macros

#define BLI_string_join(result, result_len, ...)
 
#define BLI_string_joinN(...)    BLI_string_join_arrayN(((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
 
#define BLI_string_join_by_sep_charN(sep, ...)
 
#define BLI_string_join_by_sep_char_with_tableN(sep, table, ...)
 

Typedefs

typedef bool(* UniquenameCheckCallback) (void *arg, const char *name)
 

Functions

size_t BLI_split_name_num (char *left, int *nr, const char *name, const char delim)
 
bool BLI_string_is_decimal (const char *string) ATTR_NONNULL()
 
void BLI_string_split_suffix (const char *string, char *r_body, char *r_suf, const size_t str_len)
 
void BLI_string_split_prefix (const char *string, char *r_pre, char *r_body, const size_t str_len)
 
char * BLI_string_join_array (char *result, size_t result_len, const char *strings[], uint strings_len) ATTR_NONNULL()
 
char * BLI_string_join_array_by_sep_char (char *result, size_t result_len, char sep, const char *strings[], uint strings_len) ATTR_NONNULL()
 
char * BLI_string_join_arrayN (const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
char * BLI_string_join_array_by_sep_charN (char sep, const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
char * BLI_string_join_array_by_sep_char_with_tableN (char sep, char *table[], const char *strings[], uint strings_len) ATTR_NONNULL()
 
void BLI_string_flip_side_name (char *r_name, const char *from_name, const bool strip_number, const size_t name_len)
 
bool BLI_uniquename_cb (UniquenameCheckCallback unique_check, void *arg, const char *defname, char delim, char *name, size_t name_len)
 
bool BLI_uniquename (struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t len)
 

Macro Definition Documentation

◆ BLI_string_join

#define BLI_string_join (   result,
  result_len,
  ... 
)
Value:
result, result_len, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
char * BLI_string_join_array(char *result, size_t result_len, const char *strings[], uint strings_len) ATTR_NONNULL()
Definition: string_utils.c:419
#define VA_NARGS_COUNT(...)

Definition at line 66 of file BLI_string_utils.h.

◆ BLI_string_join_by_sep_char_with_tableN

#define BLI_string_join_by_sep_char_with_tableN (   sep,
  table,
  ... 
)
Value:
sep, table, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
char * BLI_string_join_array_by_sep_char_with_tableN(char sep, char *table[], const char *strings[], uint strings_len) ATTR_NONNULL()
Definition: string_utils.c:508

Definition at line 74 of file BLI_string_utils.h.

◆ BLI_string_join_by_sep_charN

#define BLI_string_join_by_sep_charN (   sep,
  ... 
)
Value:
sep, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
char * BLI_string_join_array_by_sep_charN(char sep, const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string_utils.c:480

Definition at line 71 of file BLI_string_utils.h.

◆ BLI_string_joinN

#define BLI_string_joinN (   ...)     BLI_string_join_arrayN(((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))

Definition at line 69 of file BLI_string_utils.h.

Typedef Documentation

◆ UniquenameCheckCallback

typedef bool(* UniquenameCheckCallback) (void *arg, const char *name)

Definition at line 37 of file BLI_string_utils.h.

Function Documentation

◆ BLI_split_name_num()

size_t BLI_split_name_num ( char *  left,
int *  nr,
const char *  name,
const char  delim 
)

Looks for a numeric suffix preceded by delim character on the end of name, puts preceding part into *left and value of suffix into *nr. Returns the length of *left.

Foo.001 -> "Foo", 1 Returning the length of "Foo"

Parameters
leftWhere to return copy of part preceding delim
nrWhere to return value of numeric suffix
nameString to split
delimDelimiter character
Returns
Length of left

Definition at line 55 of file string_utils.c.

References Freestyle::a, and left.

Referenced by BKE_mball_basis_find(), BKE_mball_is_basis_for(), BKE_mball_properties_copy(), BLI_uniquename_cb(), check_for_dupid(), and init_meta().

◆ BLI_string_flip_side_name()

void BLI_string_flip_side_name ( char *  r_name,
const char *  from_name,
const bool  strip_number,
const size_t  name_len 
)

Finds the best possible flipped (left/right) name. For renaming; check for unique names afterwards.

Parameters
r_nameflipped name, assumed to be a pointer to a string of at least name_len size.
from_nameoriginal name, assumed to be a pointer to a string of at least name_len size.
strip_numberIf set, remove number extensions.

Definition at line 159 of file string_utils.c.

References BLI_snprintf(), BLI_strcasestr(), BLI_strncpy(), BLI_strnlen(), is_char_sep(), len, and NULL.

Referenced by action_flip_pchan(), action_flip_pchan_rna_paths(), add_verts_to_dgroups(), armature_duplicate_selected_exec(), armature_symmetrize_exec(), BKE_object_defgroup_flip_index(), BKE_object_defgroup_flip_map(), BKE_object_defgroup_flip_map_single(), BKE_object_defgroup_mirror_selection(), BKE_pose_channel_get_mirrored(), ED_armature_bones_flip_names(), ED_armature_ebone_get_mirrored(), ED_wpaint_mirror_vgroup_ensure(), flip_names(), object_select_mirror_exec(), pose_bone_do_paste(), updateDuplicateCustomBoneShapes(), and updateDuplicateSubtarget().

◆ BLI_string_is_decimal()

bool BLI_string_is_decimal ( const char *  string)

Definition at line 85 of file string_utils.c.

Referenced by ED_text_is_syntax_highlight_supported(), and TEST().

◆ BLI_string_join_array()

char* BLI_string_join_array ( char *  result,
size_t  result_len,
const char *  strings[],
uint  strings_len 
)

Definition at line 419 of file string_utils.c.

References Freestyle::c, and result.

Referenced by draw_seq_text_get_overlay_string(), and draw_viewport_name().

◆ BLI_string_join_array_by_sep_char()

char* BLI_string_join_array_by_sep_char ( char *  result,
size_t  result_len,
char  sep,
const char *  strings[],
uint  strings_len 
)

A version of BLI_string_join that takes a separator which can be any character including '\0'.

Definition at line 439 of file string_utils.c.

References Freestyle::c, and result.

Referenced by set_pass_full_name(), and set_pass_name().

◆ BLI_string_join_array_by_sep_char_with_tableN()

char* BLI_string_join_array_by_sep_char_with_tableN ( char  sep,
char *  table[],
const char *  strings[],
uint  strings_len 
)

A version of BLI_string_join_array_by_sep_charN that takes a table array. The new location of each string is written into this array.

Definition at line 508 of file string_utils.c.

References BLI_strcpy_rlen(), Freestyle::c, MEM_mallocN, and result.

◆ BLI_string_join_array_by_sep_charN()

char* BLI_string_join_array_by_sep_charN ( char  sep,
const char *  strings[],
uint  strings_len 
)

A version of BLI_string_joinN that takes a separator which can be any character including '\0'.

Definition at line 480 of file string_utils.c.

References BLI_strcpy_rlen(), Freestyle::c, MEM_mallocN, and result.

◆ BLI_string_join_arrayN()

char* BLI_string_join_arrayN ( const char *  strings[],
uint  strings_len 
)

Join an array of strings into a newly allocated, null terminated string.

Definition at line 462 of file string_utils.c.

References BLI_strcpy_rlen(), Freestyle::c, MEM_mallocN, and result.

Referenced by blender::gpu::Shader::print_log(), and string_join_array_maybe_alloc().

◆ BLI_string_split_prefix()

void BLI_string_split_prefix ( const char *  string,
char *  r_pre,
char *  r_body,
const size_t  str_len 
)

"a.b.c" -> ("a.", "b.c")

Definition at line 130 of file string_utils.c.

References BLI_strncpy(), BLI_strnlen(), is_char_sep(), and len.

Referenced by select_similar_prefix().

◆ BLI_string_split_suffix()

void BLI_string_split_suffix ( const char *  string,
char *  r_body,
char *  r_suf,
const size_t  str_len 
)

based on BLI_split_dirfile() / os.path.splitext(), "a.b.c" -> ("a.b", ".c").

Definition at line 109 of file string_utils.c.

References BLI_strncpy(), BLI_strnlen(), is_char_sep(), and len.

Referenced by select_similar_suffix().

◆ BLI_uniquename()

bool BLI_uniquename ( ListBase list,
void *  vlink,
const char *  defname,
char  delim,
int  name_offset,
size_t  name_len 
)

Ensures that the specified block has a unique name within the containing list, incrementing its numeric suffix as necessary. Returns true if name had to be adjusted.

Parameters
listList containing the block
vlinkThe block to check the name for
defnameTo initialize block name if latter is empty
delimDelimits numeric suffix in name
name_offsetOffset of name within block structure
name_lenMaximum length of name area

Definition at line 381 of file string_utils.c.

References BLI_assert, BLI_uniquename_cb(), data, ELEM, NULL, POINTER_OFFSET, and uniquename_unique_check().

Referenced by action_groups_add_new(), AnimationImporter::add_bone_fcurve(), add_to_modifier_list(), BKE_asset_metadata_tag_add(), BKE_constraint_unique_name(), BKE_freestyle_lineset_unique_name(), BKE_gpencil_layer_addnew(), BKE_gpencil_modifier_unique_name(), BKE_gpencil_palette_addnew(), BKE_gpencil_palettecolor_addnew(), BKE_keyblock_add(), BKE_keyingset_add(), BKE_mask_layer_unique_name(), BKE_modifier_unique_name(), BKE_nla_action_stash(), BKE_nlatrack_add(), BKE_pose_add_group(), BKE_preferences_asset_library_name_set(), BKE_scene_add_render_view(), BKE_shaderfx_unique_name(), BKE_tracking_object_unique_name(), BKE_tracking_plane_track_unique_name(), BKE_tracking_track_unique_name(), BKE_view_layer_add(), BKE_view_layer_rename(), do_versions_nodetree_customnodes(), driver_add_new_variable(), ED_gpencil_join_objects_exec(), fcurve_add_to_list(), gpencil_layer_copy_exec(), namebutton_fn(), nodeUniqueName(), poselib_add_exec(), poselib_rename_exec(), psys_unique_name(), SEQ_modifier_unique_name(), tracks_map_merge(), viewlayer_aov_make_name_unique(), and workspace_layout_name_set().

◆ BLI_uniquename_cb()

bool BLI_uniquename_cb ( UniquenameCheckCallback  unique_check,
void *  arg,
const char *  defname,
char  delim,
char *  name,
size_t  name_len 
)

Ensures name is unique (according to criteria specified by caller in unique_check callback), incrementing its numeric suffix as necessary. Returns true if name had to be adjusted.

Parameters
unique_checkReturn true if name is not unique
argAdditional arg to unique_check–meaning is up to caller
defnameTo initialize name if latter is empty
delimDelimits numeric suffix in name
nameName to be ensured unique
name_lenMaximum length of name area
Returns
true if there if the name was changed

Definition at line 294 of file string_utils.c.

References BLI_snprintf(), BLI_split_name_num(), BLI_strncpy(), BLI_strncpy_utf8_rlen(), left, and len.

Referenced by BKE_nlastrip_validate_name(), BKE_object_defgroup_unique_name(), BKE_object_facemap_unique_name(), BLI_uniquename(), CustomData_set_layer_unique_name(), dynamicPaintSurface_setUniqueName(), ed_armature_bone_unique_name(), ED_armature_ebone_unique_name(), make_socket(), ntree_interface_identifier(), ntreeCompositOutputFileUniqueLayer(), ntreeCompositOutputFileUniquePath(), surface_setUniqueOutputName(), unique_socket_template_identifier(), and uniqueOrientationName().