squareball  0.2.0.53-dd5b
A general-purpose library for C99
sb-string.h File Reference

String object that grows automatically, as required by the content added to it. More...

#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  sb_string_t
 

Functions

sb_string_tsb_string_new (void)
 
char * sb_string_free (sb_string_t *str, bool free_str)
 
sb_string_tsb_string_dup (sb_string_t *str)
 
sb_string_tsb_string_append_len (sb_string_t *str, const char *suffix, size_t len)
 
sb_string_tsb_string_append (sb_string_t *str, const char *suffix)
 
sb_string_tsb_string_append_c (sb_string_t *str, char c)
 
sb_string_tsb_string_append_printf (sb_string_t *str, const char *format,...)
 
sb_string_tsb_string_append_escaped (sb_string_t *str, const char *suffix)
 

Detailed Description

String object that grows automatically, as required by the content added to it.

Function Documentation

sb_string_t* sb_string_append ( sb_string_t str,
const char *  suffix 
)

Function that appends a nul-terminated suffix to the string object.

Parameters
strThe string object.
suffixThe nul-terminated suffix to append to the string object.
Returns
The modified string object.
Examples:
hello_string.c.
sb_string_t* sb_string_append_c ( sb_string_t str,
char  c 
)

Function that appends a character to the string object.

Parameters
strThe string object.
cThe character to append to the string object.
Returns
The modified string object.
Examples:
hello_string.c.
sb_string_t* sb_string_append_escaped ( sb_string_t str,
const char *  suffix 
)

Function that appends a nul-terminated suffix to string object, escaping the suffix before appending.

Parameters
strThe string object.
suffixThe nul-terminated suffix to append to the string object.
Returns
The modified string object.
sb_string_t* sb_string_append_len ( sb_string_t str,
const char *  suffix,
size_t  len 
)

Function that appends len bytes from suffix to the string object.

Parameters
strThe string object.
suffixThe suffix to append to the string object.
lenThe number of bytes from suffix to append to the string object.
Returns
The modified string object.
Examples:
hello_string.c.
sb_string_t* sb_string_append_printf ( sb_string_t str,
const char *  format,
  ... 
)

Function that appends to an string object with a printf(3)-like interface.

Parameters
strThe string object.
formatA printf(3) format.
...One or more printf(3)-like parameters.
Returns
The modified string object.
Examples:
hello_string.c.
sb_string_t* sb_string_dup ( sb_string_t str)

Function that duplicates a string object.

Parameters
strThe string object.
Returns
A newly-allocated copy of str.
char* sb_string_free ( sb_string_t str,
bool  free_str 
)

Function that frees memory allocated for a string object. If free_str is false, it will only free the memory allocated for the object, and return the string stored on it.

Parameters
strThe string object.
free_strBoolean that indicates if the memory allocated to internal string should be free'd.
Returns
Internal string, passing ownership of it to the caller of the function, if free_str is false, or NULL.
Examples:
hello_string.c.
sb_string_t* sb_string_new ( void  )

Function that creates an empty string object.

Returns
New string object.
Examples:
hello_string.c.