Blender V2.61 - r43446
Typedefs | Functions

BLI_dynstr.h File Reference

A dynamically sized string ADT. More...

#include <stdarg.h>

Go to the source code of this file.

Typedefs

typedef struct DynStr DynStr

Functions

DynStrBLI_dynstr_new (void)
void BLI_dynstr_append (DynStr *ds, const char *cstr)
void BLI_dynstr_nappend (DynStr *ds, const char *cstr, int len)
void BLI_dynstr_appendf (DynStr *ds, const char *format,...)
void BLI_dynstr_vappendf (DynStr *ds, const char *format, va_list args)
int BLI_dynstr_get_len (DynStr *ds)
char * BLI_dynstr_get_cstring (DynStr *ds)
void BLI_dynstr_get_cstring_ex (DynStr *ds, char *str)
void BLI_dynstr_free (DynStr *ds)

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

typedef struct DynStr DynStr

The abstract DynStr type

Definition at line 46 of file BLI_dynstr.h.


Function Documentation

void BLI_dynstr_append ( DynStr ds,
const char *  cstr 
)
void BLI_dynstr_appendf ( DynStr ds,
const char *  format,
  ... 
)
void BLI_dynstr_free ( DynStr ds)
char* BLI_dynstr_get_cstring ( DynStr ds)
void BLI_dynstr_get_cstring_ex ( DynStr ds,
char *  str 
)

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

Parameters:
dsThe DynStr of interest.
strThe string to fill.
Returns:
The contents of ds as a c-string.

Definition at line 229 of file BLI_dynstr.c.

References DynStr::curlen, DynStr::elems, DynStrElem::next, DynStrElem::str, and strlen().

Referenced by BLI_dynstr_get_cstring(), and mathutils_dynstr_to_py().

int BLI_dynstr_get_len ( DynStr ds)

Find the length of a DynStr.

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

Definition at line 224 of file BLI_dynstr.c.

References DynStr::curlen.

Referenced by BKE_reportf(), BKE_reports_prepend(), BKE_reports_prependf(), BKE_reports_string(), console_copy_exec(), IDnames_to_pupstring(), IMAnames_to_pupstring(), and mathutils_dynstr_to_py().

void BLI_dynstr_nappend ( DynStr 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 97 of file BLI_dynstr.c.

References BLI_strnlen(), DynStr::curlen, DynStr::elems, DynStr::last, DynStrElem::next, NULL, and DynStrElem::str.

Referenced by console_copy_exec().

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

Definition at line 115 of file BLI_dynstr.c.

References BLI_dynstr_append(), len(), MEM_callocN(), MEM_freeN(), NULL, and va_copy.

Referenced by BKE_reportf(), BKE_reports_prependf(), and BLI_sprintfN().