Blender V4.3
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 (const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
char * BLI_dynstr_get_cstring (const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
void BLI_dynstr_get_cstring_ex (const 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 28 of file BLI_dynstr.h.

Function Documentation

◆ ATTR_NONNULL()

ATTR_WARN_UNUSED_RESULT ATTR_NONNULL ( 1 ,
2  )

Given a edge and one of its vertices, returns the other vertex.

Tests whether one loop is next to another within the same face.

◆ BLI_dynstr_append()

◆ BLI_dynstr_appendf()

◆ BLI_dynstr_clear()

void BLI_dynstr_clear ( DynStr * ds)

Clear the DynStr

Parameters
dsThe DynStr to clear.

Definition at line 156 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(), and menu_items_from_ui_create().

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

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

Referenced by 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 ( const 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 81 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_string_replaceN(), console_select_to_buffer(), menu_items_from_ui_create(), 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 47 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 menu_items_from_ui_create().

◆ BLI_dynstr_vappendf()

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

Referenced by help_print_ds_fn().