This module addresses the necessity of building a string by appending incrementally pieces of text.
More...
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
Opaque type for string buffer.
Function Documentation
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] | strbuf | The buffered string; |
- Returns:
- A newly allocated null-terminated c string.
Destructor for the string buffer.
- Parameters:
-
[in] | strbuf | The 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] | strbuf | The string buffer where the string must be added; |
[in] | str | The string to be added (must be null-terminated); |
[in] | len | The 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] | sep | The separator to be inserted between any buffered string or NULL if the separator is not required; |
[in] | len | The string length (NULL-terminator not included). If 0 is provided, as length value, it will be inferred with strlen. |
- Returns:
- The new string buffer.
Read from buffer.
- Note:
- You are in charge of deallocating the returned string.
- Parameters:
-
[in] | strbuf | The buffered string; |
- Returns:
- A newly allocated null-terminated c string.