|
cwist
Modern C web framework with libttak runtime
|
sstring.h interface. More...


Go to the source code of this file.
Classes | |
| struct | cwist_sstring |
Typedefs | |
| typedef struct cwist_sstring | cwist_sstring |
sstring.h interface.
Definition in file sstring.h.
| cwist_error_t cwist_sstring_adopt_len | ( | cwist_sstring * | str, |
| char * | buf, | ||
| size_t | len | ||
| ) |
Adopt a cwist_alloc'd heap buffer, taking ownership without copying.
Adopt a cwist_alloc'd heap buffer, taking ownership without copying.
Adopt a heap buffer, taking ownership without copying.
| str | Target string object; any owned buffer it holds is released. |
| buf | cwist_alloc'd buffer with room for a NUL at buf[len]; ownership transfers to the string (freed on destroy/reassign). NULL clears. |
| len | Payload length in bytes. |
< adopted buffer size is unknown beyond len + NUL
| cwist_error_t cwist_sstring_adopt_region | ( | cwist_sstring * | str, |
| char * | base, | ||
| size_t | offset, | ||
| size_t | len | ||
| ) |
Adopt a cwist_alloc'd heap buffer as a region view without copying.
| str | Target string object; any owned buffer it holds is released. |
| base | Allocation base (cwist_alloc'd); ownership transfers to the string. |
| offset | Payload start relative to base. |
| len | Payload length in bytes. |
base must have room for a NUL at base[offset + len]. Growth reallocs base and preserves the offset.Adopt a cwist_alloc'd heap buffer as a region view without copying.
| str | Target string object; any owned buffer it holds is released. |
| base | cwist_alloc'd allocation base; ownership transfers to the string (freed on destroy/reassign). NULL clears. |
| offset | Payload start relative to base. |
| len | Payload length in bytes; base[offset + len] must be the NUL slot. |
base and preserves the offset, so data keeps viewing the same region. < adopted region size is unknown beyond len + NUL
| cwist_error_t cwist_sstring_append | ( | cwist_sstring * | str, |
| const char * | data | ||
| ) |
Append a C string.
Append a C string.
| str | Target string object. |
| data | Source string to append. |
Definition at line 559 of file sstring.c.
Referenced by cwist_sstring_append(), and cwist_sstring_append_sstring().
| cwist_error_t cwist_sstring_append_len | ( | cwist_sstring * | str, |
| const char * | data, | ||
| size_t | len | ||
| ) |
| cwist_error_t cwist_sstring_append_sstring | ( | cwist_sstring * | str, |
| const cwist_sstring * | from | ||
| ) |
Append another sstring.
Append another sstring.
Append the contents of one CWIST string onto another.
| str | Destination string. |
| from | Source CWIST string. |
Definition at line 700 of file sstring.c.
Referenced by cwist_sstring_create(), and cwist_sstring_init().
| cwist_error_t cwist_sstring_assign | ( | cwist_sstring * | str, |
| const char * | data | ||
| ) |
Assign a C string.
Assign a C string.
| str | Target string object. |
| data | Source string, or NULL to clear the value. |
Definition at line 504 of file sstring.c.
Referenced by cwist_sstring_assign(), and cwist_sstring_copy_sstring().
| cwist_error_t cwist_sstring_assign_len | ( | cwist_sstring * | str, |
| const char * | data, | ||
| size_t | len | ||
| ) |
| cwist_error_t cwist_sstring_borrow | ( | cwist_sstring * | str, |
| const char * | data, | ||
| size_t | len | ||
| ) |
Borrow an external buffer without copying; detached to heap on first mutation.
Borrow an external buffer without copying; detached to heap on first mutation.
Borrow an external buffer without copying.
| str | Target string object; any owned buffer it holds is released. |
| data | Borrowed bytes; must outlive the string (literal, arena chunk, ...). |
| len | Length of the borrowed bytes. |
< borrowed capacity is unknown until detach
| cwist_error_t cwist_sstring_change_size | ( | cwist_sstring * | str, |
| size_t | new_size, | ||
| bool | blow_data | ||
| ) |
Change the internal buffer size.
Change the internal buffer size.
| str | String object to resize. |
| new_size | Requested new size in bytes. |
| blow_data | When true, allow shrinking below the current content length. |
Definition at line 417 of file sstring.c.
Referenced by cwist_sstring_assign().
| int cwist_sstring_compare | ( | cwist_sstring * | str, |
| const char * | compare_to | ||
| ) |
| int cwist_sstring_compare_sstring | ( | cwist_sstring * | left, |
| const cwist_sstring * | right | ||
| ) |
Compare two sstrings.
Compare two sstrings.
Compare two CWIST string objects using strcmp semantics.
| left | Left-hand string. |
| right | Right-hand string. |
Definition at line 320 of file sstring.c.
Referenced by cwist_sstring_create(), cwist_sstring_init(), and cwist_sstring_init_escaped().
| cwist_error_t cwist_sstring_copy | ( | cwist_sstring * | origin, |
| char * | destination | ||
| ) |
| cwist_error_t cwist_sstring_copy_sstring | ( | cwist_sstring * | origin, |
| const cwist_sstring * | from | ||
| ) |
Copy from another sstring.
Copy from another sstring.
Copy one CWIST string into another.
| origin | Destination string object. |
| from | Source string object, or NULL to clear the destination. |
Definition at line 786 of file sstring.c.
Referenced by cwist_sstring_create(), cwist_sstring_init(), and cwist_sstring_init_escaped().
| cwist_sstring * cwist_sstring_create | ( | void | ) |
Allocate and initialize a new heap-owned CWIST string object.
Create a new sstring instance.
Definition at line 802 of file sstring.c.
Referenced by cwist_sstring_substr().
| void cwist_sstring_destroy | ( | cwist_sstring * | str | ) |
Destroy a heap-owned CWIST string and its backing buffer.
Destroy an sstring instance.
| str | String object to destroy. |
Definition at line 823 of file sstring.c.
Referenced by cwist_sstring_substr().
| size_t cwist_sstring_get_size | ( | cwist_sstring * | str | ) |
Get the current size.
Get the current size.
Return the cached string size in bytes.
| str | String object to inspect. |
Definition at line 306 of file sstring.c.
Referenced by cwist_sstring_create(), cwist_sstring_init(), and cwist_sstring_init_escaped().
| cwist_error_t cwist_sstring_init | ( | cwist_sstring * | str | ) |
| cwist_error_t cwist_sstring_ltrim | ( | cwist_sstring * | str | ) |
Left-trim whitespace.
Left-trim whitespace.
| str | String object to mutate. |
Definition at line 329 of file sstring.c.
Referenced by cwist_sstring_trim().
| cwist_error_t cwist_sstring_rtrim | ( | cwist_sstring * | str | ) |
Right-trim whitespace.
Right-trim whitespace.
| str | String object to mutate. |
Definition at line 365 of file sstring.c.
Referenced by cwist_sstring_trim().
| cwist_error_t cwist_sstring_seek | ( | cwist_sstring * | str, |
| char * | substr, | ||
| int | location | ||
| ) |
Seek a substring at a location.
Seek a substring at a location.
| str | Source string object. |
| substr | Destination C buffer. |
| location | Starting offset inside the source string. |
| cwist_sstring * cwist_sstring_substr | ( | cwist_sstring * | str, |
| int | start, | ||
| int | length | ||
| ) |
| cwist_error_t cwist_sstring_trim | ( | cwist_sstring * | str | ) |