4#ifndef __CWIST_SSTRING_H__
5#define __CWIST_SSTRING_H__
@ ERR_SSTRING_NULL_STRING
@ ERR_SSTRING_RESIZE_TOO_LARGE
@ ERR_SSTRING_ZERO_LENGTH
@ ERR_SSTRING_RESIZE_TOO_SMALL
int cwist_sstring_compare(cwist_sstring *str, const char *compare_to)
Compare with a C string.
cwist_error_t cwist_sstring_append_len(cwist_sstring *str, const char *data, size_t len)
Append raw bytes with length.
cwist_error_t cwist_sstring_adopt_region(cwist_sstring *str, char *base, size_t offset, size_t len)
Adopt a heap buffer as a region view without copying.
size_t cwist_sstring_get_size(cwist_sstring *str)
Get the current size.
cwist_sstring * cwist_sstring_create(void)
Create a new sstring instance.
cwist_error_t cwist_sstring_init(cwist_sstring *str)
Initialize an sstring.
cwist_sstring * cwist_sstring_substr(cwist_sstring *str, int start, int length)
Extract a substring.
cwist_error_t cwist_sstring_append(cwist_sstring *str, const char *data)
Append a C string.
cwist_error_t cwist_sstring_assign_len(cwist_sstring *str, const char *data, size_t len)
Assign raw bytes with length.
cwist_error_t cwist_sstring_assign(cwist_sstring *str, const char *data)
Assign a C string.
cwist_error_t cwist_sstring_copy(cwist_sstring *origin, char *destination)
Copy to a C string buffer.
cwist_error_t cwist_sstring_append_sstring(cwist_sstring *str, const cwist_sstring *from)
Append another sstring.
struct cwist_sstring cwist_sstring
void cwist_sstring_destroy(cwist_sstring *str)
Destroy an sstring instance.
cwist_error_t cwist_sstring_change_size(cwist_sstring *str, size_t size, bool blow_data)
Change the internal buffer size.
cwist_error_t cwist_sstring_borrow(cwist_sstring *str, const char *data, size_t len)
Borrow an external buffer without copying.
cwist_error_t cwist_sstring_rtrim(cwist_sstring *str)
Right-trim whitespace.
cwist_error_t cwist_sstring_trim(cwist_sstring *str)
Trim whitespace from both ends.
cwist_error_t cwist_sstring_ltrim(cwist_sstring *str)
Left-trim whitespace.
cwist_error_t cwist_sstring_copy_sstring(cwist_sstring *origin, const cwist_sstring *from)
Copy from another sstring.
cwist_error_t cwist_sstring_seek(cwist_sstring *str, char *substr, int location)
Seek a substring at a location.
int cwist_sstring_compare_sstring(cwist_sstring *left, const cwist_sstring *right)
Compare two sstrings.
cwist_error_t cwist_sstring_adopt_len(cwist_sstring *str, char *buf, size_t len)
Adopt a heap buffer, taking ownership without copying.
Integrated error structure used throughout the system.
int(* compare)(struct cwist_sstring *left, const struct cwist_sstring *right)
Should mimic strcmp, internally use strncmp.
char * data
Access directly only when raw handling is necessary.
cwist_error_t(* append)(struct cwist_sstring *str, const struct cwist_sstring *from)
Append another sstring.
cwist_error_t(* copy)(struct cwist_sstring *str, const struct cwist_sstring *from)
size_t(* get_size)(struct cwist_sstring *str)
bool borrows_buffer
data is borrowed (static/arena); never freed, detached on mutation