QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Dynamic Strings

Data Structures

struct  dstring_mem_s
 
struct  dstring_s
 

Typedefs

typedef struct dstring_mem_s dstring_mem_t
 
typedef struct dstring_s dstring_t
 

Functions

dstring_t * _dstring_new (dstring_mem_t *mem)
 Create a new dstring. More...
 
void dstring_adjust (dstring_t *dstr)
 Resize the string buffer if necessary. More...
 
void dstring_append (dstring_t *dstr, const char *data, unsigned int len)
 Append len bytes from data onto the end of the dstring. More...
 
void dstring_appendstr (dstring_t *dstr, const char *str)
 Append the null terminated string to the end of the dstring. More...
 
void dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len)
 Append up to len bytes from the string to the end of the dstring. More...
 
void dstring_clear (dstring_t *dstr)
 Set the size of the dstring to 0 bytes. More...
 
void dstring_clearstr (dstring_t *dstr)
 Clear the dstring to be equivalent to "". More...
 
void dstring_copy (dstring_t *dstr, const char *data, unsigned int len)
 Copy len bytes from data into the dstring, replacing any existing data. More...
 
void dstring_copystr (dstring_t *dstr, const char *str)
 Copy the null terminated string into the dstring. More...
 
void dstring_copysubstr (dstring_t *dstr, const char *str, unsigned int len)
 Copy up to len bytes from the string into the dstring. More...
 
void dstring_delete (dstring_t *dstr)
 Delete a dstring. More...
 
char * dstring_freeze (dstring_t *dstr)
 Delete the dstring object retaining the string buffer. More...
 
void dstring_insert (dstring_t *dstr, unsigned int pos, const char *data, unsigned int len)
 Insert len bytes from data int the dstring at pos. More...
 
void dstring_insertstr (dstring_t *dstr, unsigned int pos, const char *str)
 Insert the null terminated string into the dstring at pos. More...
 
void dstring_insertsubstr (dstring_t *dstr, unsigned int pos, const char *str, unsigned int len)
 Insert up to len bytes from the string into the dstring at pos. More...
 
dstring_t * dstring_new (void)
 
void dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen, const char *data, unsigned int len)
 Replace rlen bytes in dstring at pos with len bytes from data. More...
 
char * dstring_reserve (dstring_t *dstr, unsigned len)
 Open up a hole in the string buffer. More...
 
char * dstring_reservestr (dstring_t *dstr, unsigned len)
 Open up a hole in the string buffer. More...
 
void dstring_snip (dstring_t *dstr, unsigned int pos, unsigned int len)
 Remove len bytes from the dstring starting at pos. More...
 
dstring_t * dstring_strdup (const char *str)
 Create a new dstring from a string. More...
 

Variables

dstring_mem_t dstring_default_mem
 
dstring_t * _dstring_newstr (dstring_mem_t *mem)
 Allocate a new dstring pre-initialized as a null terminated string. More...
 
dstring_t * dstring_newstr (void)
 
int dvsprintf (dstring_t *dstr, const char *fmt, va_list args)
 Formatted printing to dstrings. More...
 
int dsprintf (dstring_t *dstr, const char *fmt,...)
 
int davsprintf (dstring_t *dstr, const char *fmt, va_list args)
 Formatted printing to dstrings. More...
 
int dasprintf (dstring_t *dstr, const char *fmt,...)
 

Detailed Description

Typedef Documentation

typedef struct dstring_mem_s dstring_mem_t
typedef struct dstring_s dstring_t

Function Documentation

dstring_t* _dstring_new ( dstring_mem_t *  mem)
inline

Create a new dstring.

size and truesize start at 0 and no string buffer is allocated.

dstring_t* _dstring_newstr ( dstring_mem_t *  mem)
inline

Allocate a new dstring pre-initialized as a null terminated string.

size will be 1 and the first byte 0.

int dasprintf ( dstring_t *  dstr,
const char *  fmt,
  ... 
)
int davsprintf ( dstring_t *  dstr,
const char *  fmt,
va_list  args 
)

Formatted printing to dstrings.

Formatted string is appened to the dstring. Embedded nulls in the dstring are ignored.

int dsprintf ( dstring_t *  dstr,
const char *  fmt,
  ... 
)
void dstring_adjust ( dstring_t *  dstr)
inline

Resize the string buffer if necessary.

The buffer is guaranteed to be large enough to hold size bytes (rounded up to the next 1kB boundary)

void dstring_append ( dstring_t *  dstr,
const char *  data,
unsigned int  len 
)

Append len bytes from data onto the end of the dstring.

void dstring_appendstr ( dstring_t *  dstr,
const char *  str 
)

Append the null terminated string to the end of the dstring.

The dstring does not have to be null terminated but will become so. However, any embedded nulls will be treated as the end of the dstring.

void dstring_appendsubstr ( dstring_t *  dstr,
const char *  str,
unsigned int  len 
)

Append up to len bytes from the string to the end of the dstring.

The dstring does not have to be null terminated but will become so. However, any embedded nulls will be treated as the end of the dstring.

void dstring_clear ( dstring_t *  dstr)

Set the size of the dstring to 0 bytes.

Does not free the string buffer anticipating reuse.

void dstring_clearstr ( dstring_t *  dstr)

Clear the dstring to be equivalent to "".

Does not resize the string buffer but size is set to 1. dstr = dstring_new (); dstring_clearstr (dstr); is exactly equivalent to dstr = dstring_newstr ();

void dstring_copy ( dstring_t *  dstr,
const char *  data,
unsigned int  len 
)

Copy len bytes from data into the dstring, replacing any existing data.

void dstring_copystr ( dstring_t *  dstr,
const char *  str 
)

Copy the null terminated string into the dstring.

Replaces any existing data. The dstring does not have to be null terminated but will become so.

void dstring_copysubstr ( dstring_t *  dstr,
const char *  str,
unsigned int  len 
)

Copy up to len bytes from the string into the dstring.

Replaces any existing data. The dstring does not have to be null terminated but will become so.

void dstring_delete ( dstring_t *  dstr)

Delete a dstring.

Both the string buffer and dstring object are freed.

char* dstring_freeze ( dstring_t *  dstr)

Delete the dstring object retaining the string buffer.

The string buffer will be just big enough to hold the data. Does NOT ensure the string is null terminated.

void dstring_insert ( dstring_t *  dstr,
unsigned int  pos,
const char *  data,
unsigned int  len 
)

Insert len bytes from data int the dstring at pos.

If pos is past the end of the dstring, equivalent to dstring_append.

void dstring_insertstr ( dstring_t *  dstr,
unsigned int  pos,
const char *  str 
)

Insert the null terminated string into the dstring at pos.

The dstring is NOT forced to be null terminated.

void dstring_insertsubstr ( dstring_t *  dstr,
unsigned int  pos,
const char *  str,
unsigned int  len 
)

Insert up to len bytes from the string into the dstring at pos.

The dstring is NOT forced to be null terminated.

dstring_t* dstring_new ( void  )
dstring_t* dstring_newstr ( void  )
void dstring_replace ( dstring_t *  dstr,
unsigned int  pos,
unsigned int  rlen,
const char *  data,
unsigned int  len 
)

Replace rlen bytes in dstring at pos with len bytes from data.

Moves trailing bytes as needed.

char* dstring_reserve ( dstring_t *  dstr,
unsigned  len 
)

Open up a hole in the string buffer.

The contents of the opened hole are undefined.

Parameters
dstrthe dstring in which to open the hole.
lenthe size of the hole to open.
Returns
pointer to the beginning of the opened hole.
char* dstring_reservestr ( dstring_t *  dstr,
unsigned  len 
)

Open up a hole in the string buffer.

The contents of the opened hole are undefined. The size of the opened hole will be 1 bigger than specified allowing for a null terminator.

Parameters
dstrthe dstring in which to open the hole.
lenthe size of the hole to open.
Returns
pointer to the current null terminator or beginning of the opened hole if there was no terminator.
void dstring_snip ( dstring_t *  dstr,
unsigned int  pos,
unsigned int  len 
)

Remove len bytes from the dstring starting at pos.

dstring_t* dstring_strdup ( const char *  str)

Create a new dstring from a string.

Similar to strdup().

Parameters
strthe string to copy
Returns
inititialized dstring
int dvsprintf ( dstring_t *  dstr,
const char *  fmt,
va_list  args 
)

Formatted printing to dstrings.

Existing data is replaced by the formatted string.

Variable Documentation

dstring_mem_t dstring_default_mem