squareball 0.2.0.28-7bb8 A general-purpose library for C99

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

All Data Structures Files Functions Variables Typedefs
Data Structures
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_t * | sb_string_new (void)
char * | sb_string_free (sb_string_t *str, bool free_str)
sb_string_t * | sb_string_dup (sb_string_t *str)
sb_string_t * | sb_string_append_len (sb_string_t *str, const char *suffix, size_t len)
sb_string_t * | sb_string_append (sb_string_t *str, const char *suffix)
sb_string_t * | sb_string_append_c (sb_string_t *str, char c)
sb_string_t * | sb_string_append_printf (sb_string_t *str, const char *format,...)
sb_string_t * | sb_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

  str | The string object.
  suffix | The 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

  str | The string object.
  c | The 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

  str | The string object.
  suffix | The 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

  str | The string object.
  suffix | The suffix to append to the string object.
  len | The 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

  str | The string object.
  format | A 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

  str | The 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

  str | The string object.
  free_str | Boolean 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.