Blender V5.0
BLI_dynstr.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "BLI_dynstr.h"
#include "BLI_memarena.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Classes

struct  DynStrElem
struct  DynStr

Functions

DynStrBLI_dynstr_new ()
DynStrBLI_dynstr_new_memarena ()
template<typename T>
Tdynstr_alloc (DynStr *__restrict ds, size_t num=1)
void BLI_dynstr_append (DynStr *__restrict ds, const char *cstr)
void BLI_dynstr_nappend (DynStr *__restrict ds, const char *cstr, int len)
void BLI_dynstr_vappendf (DynStr *__restrict ds, const char *__restrict format, va_list args)
void BLI_dynstr_appendf (DynStr *__restrict ds, const char *__restrict format,...)
int BLI_dynstr_get_len (const DynStr *ds)
void BLI_dynstr_get_cstring_ex (const DynStr *__restrict ds, char *__restrict rets)
char * BLI_dynstr_get_cstring (const DynStr *ds)
void BLI_dynstr_clear (DynStr *ds)
void BLI_dynstr_free (DynStr *ds)

Detailed Description

Dynamically sized string ADT.

Definition in file BLI_dynstr.cc.

Function Documentation

◆ BLI_dynstr_append()

◆ BLI_dynstr_appendf()

void BLI_dynstr_appendf ( DynStr *__restrict ds,
const char *__restrict format,
... )

Definition at line 106 of file BLI_dynstr.cc.

References BLI_dynstr_append(), BLI_vsprintfN_with_buffer(), LIKELY, MEM_freeN(), and str.

◆ BLI_dynstr_clear()

void BLI_dynstr_clear ( DynStr * ds)

Clear the DynStr

Parameters
dsThe DynStr to clear.

Definition at line 150 of file BLI_dynstr.cc.

References BLI_memarena_clear(), DynStr::curlen, DynStr::elems, free(), DynStr::last, DynStr::memarena, and DynStrElem::next.

Referenced by BLI_dynstr_free(), and BLI_dynstr_vappendf().

◆ BLI_dynstr_free()

◆ BLI_dynstr_get_cstring()

◆ BLI_dynstr_get_cstring_ex()

void BLI_dynstr_get_cstring_ex ( const DynStr *__restrict ds,
char *__restrict rets )

Get a DynStr's contents as a c-string. The rets argument must be allocated to be at least the size of BLI_dynstr_get_len(ds) + 1.

Parameters
dsThe DynStr of interest.
retsThe string to fill.

Definition at line 127 of file BLI_dynstr.cc.

References BLI_assert, DynStrElem::next, and DynStrElem::str.

Referenced by BLI_dynstr_get_cstring(), BLI_dynstr_vappendf(), mathutils_dynstr_to_py(), and wm_platform_support_create_link().

◆ BLI_dynstr_get_len()

int BLI_dynstr_get_len ( const DynStr * ds)

Find the length of a DynStr.

Parameters
dsThe DynStr of interest.
Returns
The length of ds.

Definition at line 122 of file BLI_dynstr.cc.

References DynStr::curlen.

Referenced by BKE_reports_string(), BLI_dynstr_vappendf(), console_select_to_buffer(), IDP_reprN(), mathutils_dynstr_to_py(), studiolight_write_solid_light(), and wm_platform_support_create_link().

◆ BLI_dynstr_nappend()

void BLI_dynstr_nappend ( DynStr *__restrict ds,
const char * cstr,
int len )

Append a length clamped c-string to a DynStr.

Parameters
dsThe DynStr to append to.
cstrThe c-string to append.
lenThe maximum length of the c-string to copy.

Definition at line 75 of file BLI_dynstr.cc.

References BLI_strnlen(), dynstr_alloc(), len, DynStrElem::next, and DynStrElem::str.

Referenced by BKE_cryptomatte_entries_to_matte_id(), BLI_string_replaceN(), console_select_to_buffer(), blender::gpu::Shader::print_log(), repr_str(), and rna_path_rename_fix().

◆ BLI_dynstr_new()

◆ BLI_dynstr_new_memarena()

DynStr * BLI_dynstr_new_memarena ( void )

Create a new DynStr.

Returns
Pointer to a new DynStr.

Definition at line 42 of file BLI_dynstr.cc.

References BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, MEM_callocN(), and DynStr::memarena.

◆ BLI_dynstr_vappendf()

void BLI_dynstr_vappendf ( DynStr *__restrict ds,
const char *__restrict format,
va_list args )

Definition at line 95 of file BLI_dynstr.cc.

References BLI_dynstr_append(), BLI_vsprintfN_with_buffer(), MEM_freeN(), and str.

◆ dynstr_alloc()

template<typename T>
T * dynstr_alloc ( DynStr *__restrict ds,
size_t num = 1 )
inline

Definition at line 50 of file BLI_dynstr.cc.

References BLI_memarena_alloc(), num, and T.

Referenced by BLI_dynstr_append(), and BLI_dynstr_nappend().