Blender  V2.93
Typedefs | Functions
BLI_dynstr.h File Reference

A dynamically sized string ADT. More...

#include <stdarg.h>
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Typedefs

typedef struct DynStr DynStr
 

Functions

DynStrBLI_dynstr_new (void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
 
DynStrBLI_dynstr_new_memarena (void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
 
void BLI_dynstr_append (DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
 
void BLI_dynstr_nappend (DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
 
void BLI_dynstr_appendf (DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
 
void ATTR_NONNULL (1, 2)
 
void BLI_dynstr_vappendf (DynStr *__restrict ds, const char *__restrict format, va_list args) ATTR_PRINTF_FORMAT(2
 
int BLI_dynstr_get_len (DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
char * BLI_dynstr_get_cstring (DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
void BLI_dynstr_get_cstring_ex (DynStr *__restrict ds, char *__restrict rets) ATTR_NONNULL()
 
void BLI_dynstr_clear (DynStr *ds) ATTR_NONNULL()
 
void BLI_dynstr_free (DynStr *ds) ATTR_NONNULL()
 

Detailed Description

A dynamically sized string ADT.

Dynamic String

This ADT is designed purely for dynamic string creation through appending, not for general usage, the intent is to build up dynamic strings using a DynStr object, then convert it to a c-string and work with that.

Definition in file BLI_dynstr.h.

Typedef Documentation

◆ DynStr

typedef struct DynStr DynStr

The abstract DynStr type

Definition at line 1 of file BLI_dynstr.h.

Function Documentation

◆ ATTR_NONNULL()

void ATTR_NONNULL ( ,
 
)

◆ BLI_dynstr_append()

void BLI_dynstr_append ( DynStr *__restrict  ds,
const char *  cstr 
)

◆ BLI_dynstr_appendf()

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

◆ BLI_dynstr_clear()

void BLI_dynstr_clear ( DynStr ds)

Clear the DynStr

Parameters
dsThe DynStr to clear.

Definition at line 335 of file BLI_dynstr.c.

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

Referenced by BLI_dynstr_free(), clear(), and menu_items_from_ui_create().

◆ BLI_dynstr_free()

void BLI_dynstr_free ( DynStr ds)

Free the DynStr

Parameters
dsThe DynStr to free.

Definition at line 358 of file BLI_dynstr.c.

References BLI_dynstr_clear(), BLI_memarena_free(), MEM_freeN, and DynStr::memarena.

Referenced by BKE_cryptomatte_entries_to_matte_id(), BKE_mesh_runtime_debug_info(), BKE_reportf(), BKE_reports_prepend(), BKE_reports_prependf(), BKE_reports_string(), BLI_sprintfN(), BLI_str_replaceN(), bmp_slots_as_args(), BPy_enum_as_string(), code_generate_fragment(), code_generate_geometry(), code_generate_interface(), code_generate_vertex(), console_copy_exec(), blender::gpu::GPUPlatformGlobal::create_gpu_name(), blender::gpu::GPUPlatformGlobal::create_key(), DM_debug_info(), DRW_shader_library_create_shader_string(), eevee_get_defines(), EEVEE_shaders_cryptomatte_sh_get(), EEVEE_shaders_depth_of_field_gather_get(), EEVEE_shaders_depth_of_field_resolve_get(), EEVEE_shaders_depth_of_field_scatter_get(), get_rna_access(), gpu_material_library_generate_code(), IDP_reprN(), make(), mathutils_dynstr_to_py(), menu_items_from_ui_create(), outliner_orphans_purge_invoke(), blender::gpu::Shader::print_log(), pyrna_func_call(), report_copy_exec(), rna_idp_path_create(), RNA_path_append(), rna_path_rename_fix(), RNA_pointer_as_string_id(), RNA_pointer_as_string_keywords_ex(), RNA_property_as_string(), RNA_struct_available_or_report(), studiolight_write_solid_light(), UI_layout_introspect(), WM_operator_pystring_ex(), wm_platform_support_create_link(), WM_reportf(), workbench_build_defines(), and workbench_shader_volume_get().

◆ BLI_dynstr_get_cstring()

char* BLI_dynstr_get_cstring ( DynStr ds)

Get a DynStr's contents as a c-string. The returned c-string should be freed using MEM_freeN.

Parameters
dsThe DynStr of interest.
Returns
The contents of ds as a c-string.

Definition at line 323 of file BLI_dynstr.c.

References BLI_dynstr_get_cstring_ex(), DynStr::curlen, and MEM_mallocN.

Referenced by BKE_cryptomatte_entries_to_matte_id(), BKE_mesh_runtime_debug_info(), BKE_reportf(), BKE_reports_prepend(), BKE_reports_prependf(), BKE_reports_string(), BLI_sprintfN(), BLI_str_replaceN(), bmp_slots_as_args(), BPy_enum_as_string(), code_generate_fragment(), code_generate_geometry(), code_generate_interface(), code_generate_vertex(), console_copy_exec(), blender::gpu::GPUPlatformGlobal::create_gpu_name(), blender::gpu::GPUPlatformGlobal::create_key(), DM_debug_info(), DRW_shader_library_create_shader_string(), eevee_get_defines(), EEVEE_shaders_cryptomatte_sh_get(), EEVEE_shaders_depth_of_field_gather_get(), EEVEE_shaders_depth_of_field_resolve_get(), EEVEE_shaders_depth_of_field_scatter_get(), get_rna_access(), gpu_material_library_generate_code(), IDP_reprN(), outliner_orphans_purge_invoke(), blender::gpu::Shader::print_log(), pyrna_func_call(), report_copy_exec(), rna_idp_path_create(), RNA_path_append(), rna_path_rename_fix(), RNA_pointer_as_string_id(), RNA_pointer_as_string_keywords_ex(), RNA_property_as_string(), RNA_struct_available_or_report(), studiolight_write_solid_light(), UI_layout_introspect(), WM_operator_pystring_ex(), WM_reportf(), workbench_build_defines(), and workbench_shader_volume_get().

◆ BLI_dynstr_get_cstring_ex()

void BLI_dynstr_get_cstring_ex ( 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 299 of file BLI_dynstr.c.

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

Referenced by add(), BLI_dynstr_get_cstring(), mathutils_dynstr_to_py(), strdup_memarena_from_dynstr(), and wm_platform_support_create_link().

◆ BLI_dynstr_get_len()

int BLI_dynstr_get_len ( DynStr ds)

◆ 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 133 of file BLI_dynstr.c.

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

Referenced by BKE_cryptomatte_entries_to_matte_id(), BLI_str_replaceN(), console_copy_exec(), menu_items_from_ui_create(), blender::gpu::Shader::print_log(), repr_str(), and rna_path_rename_fix().

◆ BLI_dynstr_new()

DynStr* BLI_dynstr_new ( void  )

Create a new DynStr.

Returns
Pointer to a new DynStr.

Definition at line 71 of file BLI_dynstr.c.

References DynStr::curlen, DynStr::elems, DynStr::last, MEM_mallocN, DynStr::memarena, and NULL.

Referenced by BKE_cryptomatte_entries_to_matte_id(), BKE_mesh_runtime_debug_info(), BKE_reportf(), BKE_reports_prepend(), BKE_reports_prependf(), BKE_reports_string(), BLI_sprintfN(), BLI_str_replaceN(), bmp_slots_as_args(), BPy_enum_as_string(), code_generate_fragment(), code_generate_geometry(), code_generate_interface(), code_generate_vertex(), Color_str(), console_copy_exec(), blender::gpu::GPUPlatformGlobal::create_gpu_name(), blender::gpu::GPUPlatformGlobal::create_key(), DM_debug_info(), DRW_shader_library_create_shader_string(), eevee_get_defines(), EEVEE_shaders_cryptomatte_sh_get(), EEVEE_shaders_depth_of_field_gather_get(), EEVEE_shaders_depth_of_field_resolve_get(), EEVEE_shaders_depth_of_field_scatter_get(), Euler_str(), get_rna_access(), gpu_material_library_generate_code(), IDP_reprN(), Matrix_str(), outliner_orphans_purge_invoke(), blender::gpu::Shader::print_log(), pyrna_func_call(), Quaternion_str(), report_copy_exec(), rna_idp_path_create(), RNA_path_append(), rna_path_rename_fix(), RNA_pointer_as_string_id(), RNA_pointer_as_string_keywords_ex(), RNA_property_as_string(), RNA_struct_available_or_report(), studiolight_write_solid_light(), UI_layout_introspect(), Vector_str(), WM_operator_pystring_ex(), wm_platform_support_create_link(), WM_reportf(), workbench_build_defines(), and workbench_shader_volume_get().

◆ BLI_dynstr_new_memarena()

DynStr* BLI_dynstr_new_memarena ( void  )

Create a new DynStr.

Returns
Pointer to a new DynStr.

Definition at line 86 of file BLI_dynstr.c.

References BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, DynStr::curlen, DynStr::elems, DynStr::last, MEM_mallocN, DynStr::memarena, and NULL.

Referenced by make(), and menu_items_from_ui_create().

◆ BLI_dynstr_vappendf()

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