Blender V5.0
string_utils.cc File Reference
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <array>
#include <stdexcept>
#include "MEM_guardedalloc.h"
#include "BLI_array.hh"
#include "BLI_listbase.h"
#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.

Functions

blender::StringRef BLI_string_split_name_number (const blender::StringRef name_full, const char delim, int &r_number)
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 (blender::FunctionRef< bool(blender::StringRefNull)> unique_check, 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)
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 (std::string &haystack, const blender::StringRef needle, const blender::StringRef other)
void BLI_string_replace_char (char *str, char src, char dst)
bool BLI_string_replace_table_exact (char *string, const size_t string_maxncpy, 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
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)

Function Documentation

◆ BLI_string_flip_side_name()

size_t BLI_string_flip_side_name ( char * name_dst,
const char * name_src,
const bool strip_number,
const size_t name_dst_maxncpy )

◆ BLI_string_is_decimal()

bool BLI_string_is_decimal ( const char * string)

◆ BLI_string_join_array()

◆ BLI_string_join_array_by_sep_char()

◆ 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_num )

Definition at line 622 of file blenlib/intern/string_utils.cc.

References BLI_assert, i, MEM_calloc_arrayN(), and result.

◆ BLI_string_join_array_by_sep_charN()

◆ BLI_string_join_arrayN()

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

◆ BLI_string_len_array()

size_t BLI_string_len_array ( const char * strings[],
uint strings_num )

◆ BLI_string_replace()

void BLI_string_replace ( std::string & haystack,
blender::StringRef needle,
blender::StringRef other )

In-place replacement all occurrences of needle in haystack with other.

Definition at line 91 of file blenlib/intern/string_utils.cc.

References i, and blender::StringRefBase::size().

Referenced by blender::TEST().

◆ BLI_string_replace_char()

◆ BLI_string_replace_range()

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.

Returns
the length of string.

Definition at line 129 of file blenlib/intern/string_utils.cc.

References BLI_assert, and UNLIKELY.

Referenced by BLI_path_frame(), BLI_path_frame_range(), eval_template(), and version_escape_curly_braces().

◆ BLI_string_replace_table_exact()

bool BLI_string_replace_table_exact ( char * string,
size_t string_maxncpy,
const char * replace_table[][2],
int replace_table_len )

Simple exact-match string replacement.

Parameters
replace_tableArray of source, destination pairs.
Note
Larger tables should use a hash table.

Definition at line 113 of file blenlib/intern/string_utils.cc.

References BLI_string_debug_size_after_nil, BLI_strncpy(), i, and STREQ.

Referenced by BKE_workspace_tool_id_replace_table(), and blo_do_versions_userdef().

◆ BLI_string_replaceN()

char * BLI_string_replaceN ( const char *__restrict str,
const char *__restrict substr_old,
const char *__restrict substr_new )

◆ BLI_string_split_name_number() [1/2]

◆ BLI_string_split_name_number() [2/2]

size_t BLI_string_split_name_number ( const char * name,
const char delim,
char * r_name_left,
int * r_number )

◆ BLI_string_split_prefix()

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

◆ BLI_string_split_suffix()

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

◆ BLI_uniquename()

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

◆ BLI_uniquename_cb() [1/2]

std::string BLI_uniquename_cb ( blender::FunctionRef< bool(blender::StringRef)> unique_check,
char delim,
blender::StringRef name )

Return a name that is unique (according to criteria specified by caller in unique_check callback), incrementing its numeric suffix as necessary.

Parameters
unique_checkReturn true if name is not unique
delimDelimits numeric suffix in name
nameName to be made unique
Returns
name that can be assigned by the caller to make it unique.
Note
Contrary to the other functions with the same name, this function does not directly set the unique name. That is the responsibility of the caller.

Definition at line 451 of file blenlib/intern/string_utils.cc.

References BLI_snprintf(), BLI_string_split_name_number(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), left, len, and name.

◆ BLI_uniquename_cb() [2/2]

void BLI_uniquename_cb ( blender::FunctionRef< bool(blender::StringRefNull)> unique_check,
const char * defname,
char delim,
char * name,
size_t name_maxncpy )

◆ is_char_sep()

bool is_char_sep ( const char c)
static