#ifndef SS_H #define SS_H /* * Simple String */ #ifdef __cplusplus extern "C" { #endif /* Data encapsulated by the string class. */ typedef struct ss { char* buf; unsigned long length; unsigned long capacity; } *ss_t; /* Construct an empty string instance. */ extern ss_t ss_new(void); /* Delete the string instance. Do not use s after calling this method. */ extern void ss_delete(ss_t s); /* Get the value of the string. Alternatively, use s->buf instead. */ extern const char* ss_get(ss_t s); /* Take ownership of the string. Returns s->buf after reinitializing * the string to be empty. Call free() on the pointer returned. */ extern char* ss_take(ss_t s); /* Get the length of the string. Alternatively, use s->length instead. */ extern unsigned long ss_length(ss_t s); /* Return whether the string is empty. */ extern int ss_is_empty(ss_t s); /* Append block to s. */ extern void ss_append_block(ss_t s, const char* block, unsigned long block_length); /* Append string to s. */ extern void ss_append(ss_t s, const char* cstr); /* Clear the string. */ extern void ss_clear(ss_t s); /* Reverse the string. */ extern void ss_reverse(ss_t s); /* Swap two strings which is generally faster than copying. */ extern void ss_swap(ss_t s1, ss_t s2); #ifdef __cplusplus } #endif #endif /* SS_H */