libdacav 0.9.0
Buffered strings

This module addresses the necessity of building a string by appending incrementally pieces of text. More...

Typedefs

typedef struct dstrbuf dstrbuf_t
 Opaque type for string buffer.

Functions

dstrbuf_tdstrbuf_new (const char *sep, size_t len)
 Constructor that allocates a new (empty) string buffer.
void dstrbuf_insert (dstrbuf_t *strbuf, const char *str, size_t len)
 Insert a string.
char * dstrbuf_read (dstrbuf_t *strbuf)
 Read from buffer.
char * dstrbuf_extract (dstrbuf_t *strbuf)
 Extract from buffer.
void dstrbuf_free (dstrbuf_t *strbuf)
 Destructor for the string buffer.

Detailed Description

This module addresses the necessity of building a string by appending incrementally pieces of text.

Strings gets stored into a list of buffers, which gets transformed into a new string by request.


Typedef Documentation

typedef struct dstrbuf dstrbuf_t

Opaque type for string buffer.


Function Documentation

char* dstrbuf_extract ( dstrbuf_t strbuf)

Extract from buffer.

This function works as dstrbuf_insert, but consumes the buffer.

Note:
The library user is in charge of deallocating the returned string.
Parameters:
[in]strbufThe buffered string;
Returns:
A newly allocated null-terminated c string.
void dstrbuf_free ( dstrbuf_t strbuf)

Destructor for the string buffer.

Parameters:
[in]strbufThe string buffer to be freed.
void dstrbuf_insert ( dstrbuf_t strbuf,
const char *  str,
size_t  len 
)

Insert a string.

Note:
The library shall build its own copy of the string.
Parameters:
[in]strbufThe string buffer where the string must be added;
[in]strThe string to be added (must be null-terminated);
[in]lenThe string length (NULL-terminator not included). If 0 is provided, as length value, it will be inferred with strlen.
dstrbuf_t* dstrbuf_new ( const char *  sep,
size_t  len 
)

Constructor that allocates a new (empty) string buffer.

Parameters:
[in]sepThe separator to be inserted between any buffered string or NULL if the separator is not required;
[in]lenThe string length (NULL-terminator not included). If 0 is provided, as length value, it will be inferred with strlen.
Returns:
The new string buffer.
char* dstrbuf_read ( dstrbuf_t strbuf)

Read from buffer.

Note:
You are in charge of deallocating the returned string.
Parameters:
[in]strbufThe buffered string;
Returns:
A newly allocated null-terminated c string.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator