|
Blender V4.3
|
#include <cctype>#include <cstdlib>#include <cstring>#include <array>#include "MEM_guardedalloc.h"#include "BLI_array.hh"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_string_utils.hh"#include "BLI_utildefines.h"#include "BLI_dynstr.h"#include "DNA_listBase.h"#include "BLI_strict_flags.h"Go to the source code of this file.
Classes | |
| struct | UniqueNameCheckData |
Functions | |
| size_t | BLI_string_split_name_number (const char *name, const char delim, char *r_name_left, int *r_number) |
| bool | BLI_string_is_decimal (const char *string) |
| static bool | is_char_sep (const char c) |
| void | BLI_string_split_suffix (const char *string, const size_t string_maxlen, char *r_body, char *r_suf) |
| void | BLI_string_split_prefix (const char *string, const size_t string_maxlen, char *r_pre, char *r_body) |
| size_t | BLI_string_flip_side_name (char *name_dst, const char *name_src, const bool strip_number, const size_t name_dst_maxncpy) |
| void | BLI_uniquename_cb (UniquenameCheckCallback unique_check, void *arg, const char *defname, char delim, char *name, size_t name_maxncpy) |
| std::string | BLI_uniquename_cb (blender::FunctionRef< bool(blender::StringRef)> unique_check, const char delim, const blender::StringRef name) |
| static bool | uniquename_find_dupe (const ListBase *list, void *vlink, const char *name, int name_offset) |
| static bool | uniquename_unique_check (void *arg, const char *name) |
| void | BLI_uniquename (const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) |
| size_t | BLI_string_len_array (const char *strings[], uint strings_num) |
String Replace | |
| char * | BLI_string_replaceN (const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new) |
| void | BLI_string_replace_char (char *str, char src, char dst) |
| bool | BLI_string_replace_table_exact (char *string, const size_t string_len, const char *replace_table[][2], int replace_table_len) |
| size_t | BLI_string_replace_range (char *string, size_t string_maxncpy, int src_beg, int src_end, const char *dst) |
Join Strings | |
For non array versions of these functions, use the macros: | |
| size_t | BLI_string_join_array (char *result, size_t result_maxncpy, const char *strings[], uint strings_num) |
| size_t | BLI_string_join_array_by_sep_char (char *result, size_t result_maxncpy, char sep, const char *strings[], uint strings_num) |
| char * | BLI_string_join_arrayN (const char *strings[], uint strings_num) |
| char * | BLI_string_join_array_by_sep_charN (char sep, const char *strings[], uint strings_num) |
| char * | BLI_string_join_array_by_sep_char_with_tableN (char sep, char *table[], const char *strings[], uint strings_num) |
| size_t BLI_string_flip_side_name | ( | char * | name_dst, |
| const char * | name_src, | ||
| const bool | strip_number, | ||
| const size_t | name_dst_maxncpy ) |
Definition at line 267 of file string_utils.cc.
References BLI_snprintf_rlen(), BLI_strcasestr(), BLI_string_debug_size, BLI_strncpy(), BLI_strncpy_rlen(), BLI_strnlen(), is_char_sep(), and len.
| bool BLI_string_is_decimal | ( | const char * | string | ) |
Definition at line 198 of file string_utils.cc.
Referenced by ED_text_is_syntax_highlight_supported(), and TEST().
| size_t BLI_string_join_array | ( | char * | result, |
| size_t | result_maxncpy, | ||
| const char * | strings[], | ||
| uint | strings_num ) |
Join strings, return the length of the resulting string.
Definition at line 548 of file string_utils.cc.
References BLI_string_debug_size, result, and UNLIKELY.
Referenced by _BLI_string_join_10(), _BLI_string_join_11(), _BLI_string_join_12(), _BLI_string_join_3(), _BLI_string_join_4(), _BLI_string_join_5(), _BLI_string_join_6(), _BLI_string_join_7(), _BLI_string_join_8(), _BLI_string_join_9(), draw_selected_name(), draw_seq_in_view(), draw_seq_text_get_overlay_string(), draw_viewport_name(), make_renderinfo_string(), and string_join_array_test_truncate().
| size_t BLI_string_join_array_by_sep_char | ( | char * | result, |
| size_t | result_maxncpy, | ||
| char | sep, | ||
| const char * | strings[], | ||
| uint | strings_num ) |
A version of BLI_string_join_array that takes a separator which can be any character including '\0'.
Definition at line 571 of file string_utils.cc.
References BLI_string_debug_size, result, and UNLIKELY.
Referenced by _BLI_string_join_by_sep_char_10(), _BLI_string_join_by_sep_char_11(), _BLI_string_join_by_sep_char_12(), _BLI_string_join_by_sep_char_13(), _BLI_string_join_by_sep_char_4(), _BLI_string_join_by_sep_char_5(), _BLI_string_join_by_sep_char_6(), _BLI_string_join_by_sep_char_7(), _BLI_string_join_by_sep_char_8(), _BLI_string_join_by_sep_char_9(), BPy_BMElem_StringFromHType_ex(), RE_render_result_full_channel_name(), and string_join_array_with_sep_char_test_truncate().
| char * BLI_string_join_array_by_sep_char_with_tableN | ( | char | sep, |
| char * | table[], | ||
| const char * | strings[], | ||
| uint | strings_num ) |
Definition at line 635 of file string_utils.cc.
References BLI_assert, and result.
| char * BLI_string_join_array_by_sep_charN | ( | char | sep, |
| const char * | strings[], | ||
| uint | strings_num ) |
A version of BLI_string_join_by_sep_char that takes a separator which can be any character including '\0'.
Definition at line 614 of file string_utils.cc.
References BLI_assert, BLI_string_len_array(), and result.
Referenced by _BLI_string_join_by_sep_charN_10(), _BLI_string_join_by_sep_charN_11(), _BLI_string_join_by_sep_charN_2(), _BLI_string_join_by_sep_charN_3(), _BLI_string_join_by_sep_charN_4(), _BLI_string_join_by_sep_charN_5(), _BLI_string_join_by_sep_charN_6(), _BLI_string_join_by_sep_charN_7(), _BLI_string_join_by_sep_charN_8(), _BLI_string_join_by_sep_charN_9(), and string_join_array_with_sep_char_test_truncate().
| char * BLI_string_join_arrayN | ( | const char * | strings[], |
| uint | strings_num ) |
Join an array of strings into a newly allocated, null terminated string.
Definition at line 598 of file string_utils.cc.
References BLI_assert, BLI_string_len_array(), and result.
Referenced by _BLI_string_joinN_1(), _BLI_string_joinN_10(), _BLI_string_joinN_2(), _BLI_string_joinN_3(), _BLI_string_joinN_4(), _BLI_string_joinN_5(), _BLI_string_joinN_6(), _BLI_string_joinN_7(), _BLI_string_joinN_8(), _BLI_string_joinN_9(), blender::gpu::combine_sources(), blender::gpu::Shader::print_log(), and string_join_array_test_truncate().
| size_t BLI_string_len_array | ( | const char * | strings[], |
| uint | strings_num ) |
Definition at line 528 of file string_utils.cc.
Referenced by BLI_string_join_array_by_sep_charN(), BLI_string_join_arrayN(), draw_selected_name(), and make_renderinfo_string().
| void BLI_string_replace_char | ( | char * | str, |
| char | src, | ||
| char | dst ) |
In-place replace every src to dst in str.
| str | The string to operate on. |
| src | The character to replace. |
| dst | The character to replace with. |
Definition at line 88 of file string_utils.cc.
References str.
Referenced by BLI_path_abs(), BLI_path_rel(), BLI_path_slash_native(), BLI_path_to_display_name(), blender::gpu::create_gpu_name(), blender::gpu::create_key(), blender::io::stl::export_frame(), blender::io::usd::export_packed_texture(), blender::bke::bake::file_name_to_frame(), blender::bke::bake::frame_to_file_name(), blender::io::usd::get_relative_path(), blender::io::usd::get_tex_image_asset_filepath(), memiter_words10k_test(), str_replace_char_strdup(), str_replace_char_with_relative_exception(), uri_from_filename(), view_layer_add_lightgroup_exec(), viewlayer_aov_make_name_unique(), and viewlayer_lightgroup_make_name_unique().
| size_t BLI_string_replace_range | ( | char * | string, |
| size_t | string_maxncpy, | ||
| int | src_beg, | ||
| int | src_end, | ||
| const char * | dst ) |
Write dst into the range between src_beg & src_end, resize within string_maxncpy limits, ensure null terminated.
string. Definition at line 114 of file string_utils.cc.
References BLI_assert, int, and UNLIKELY.
Referenced by BLI_path_frame(), and BLI_path_frame_range().
| bool BLI_string_replace_table_exact | ( | char * | string, |
| size_t | string_len, | ||
| const char * | replace_table[][2], | ||
| int | replace_table_len ) |
Simple exact-match string replacement.
| replace_table | Array of source, destination pairs. |
Definition at line 98 of file string_utils.cc.
References BLI_string_debug_size_after_nil, BLI_strncpy(), and STREQ.
Referenced by BKE_workspace_tool_id_replace_table(), and blo_do_versions_userdef().
| char * BLI_string_replaceN | ( | const char *__restrict | str, |
| const char *__restrict | substr_old, | ||
| const char *__restrict | substr_new ) |
Definition at line 33 of file string_utils.cc.
References BLI_assert, BLI_dynstr_append(), BLI_dynstr_free(), BLI_dynstr_get_cstring(), BLI_dynstr_nappend(), BLI_dynstr_new(), BLI_strdup(), and str.
| size_t BLI_string_split_name_number | ( | const char * | name, |
| const char | delim, | ||
| char * | r_name_left, | ||
| int * | r_number ) |
Definition at line 165 of file string_utils.cc.
References int.
Referenced by BLI_uniquename_cb(), and BLI_uniquename_cb().
| void BLI_string_split_prefix | ( | const char * | string, |
| const size_t | string_maxlen, | ||
| char * | r_pre, | ||
| char * | r_body ) |
Definition at line 242 of file string_utils.cc.
References BLI_string_debug_size, BLI_strncpy(), BLI_strnlen(), is_char_sep(), and len.
| void BLI_string_split_suffix | ( | const char * | string, |
| const size_t | string_maxlen, | ||
| char * | r_body, | ||
| char * | r_suf ) |
Definition at line 218 of file string_utils.cc.
References BLI_string_debug_size, BLI_strncpy(), BLI_strnlen(), is_char_sep(), and len.
| void BLI_uniquename | ( | const ListBase * | list, |
| void * | vlink, | ||
| const char * | defname, | ||
| char | delim, | ||
| int | name_offset, | ||
| size_t | name_maxncpy ) |
Definition at line 501 of file string_utils.cc.
References BLI_assert, BLI_uniquename_cb(), ELEM, UniqueNameCheckData::lb, POINTER_OFFSET, and uniquename_unique_check().
| std::string BLI_uniquename_cb | ( | blender::FunctionRef< bool(blender::StringRef)> | unique_check, |
| char | delim, | ||
| blender::StringRef | name ) |
Ensures name is unique (according to criteria specified by caller in unique_check callback), incrementing its numeric suffix as necessary.
| unique_check | Return true if name is not unique |
| delim | Delimits numeric suffix in name |
| name | Name to be ensured unique |
Definition at line 430 of file string_utils.cc.
References BLI_snprintf(), BLI_string_split_name_number(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), and len.
| void BLI_uniquename_cb | ( | UniquenameCheckCallback | unique_check, |
| void * | arg, | ||
| const char * | defname, | ||
| char | delim, | ||
| char * | name, | ||
| size_t | name_maxncpy ) |
Definition at line 391 of file string_utils.cc.
References BLI_string_debug_size_after_nil, BLI_string_split_name_number(), BLI_strncpy(), BLI_strncpy_utf8_rlen(), len, SNPRINTF, and UNLIKELY.
Referenced by BLI_uniquename().
|
static |
Definition at line 213 of file string_utils.cc.
References ELEM.
Referenced by BLI_string_flip_side_name(), BLI_string_split_prefix(), and BLI_string_split_suffix().
|
static |
Generic function to set a unique name. It is only designed to be used in situations where the name is part of the struct.
For places where this is used, see constraint.cc for example...
| name_offset | should be calculated using offsetof(structname, membername) macro from stddef.h |
Definition at line 471 of file string_utils.cc.
References POINTER_OFFSET, and STREQ.
Referenced by uniquename_unique_check().
|
static |
Definition at line 494 of file string_utils.cc.
References uniquename_find_dupe().
Referenced by BLI_uniquename().