sstring.h: string handling
Provided functions allow efficient operations on strings. Internal
string format is binary, supporting arbitrary data. Operations
on strings involving format interpretation, e.g. string length is
interpreted as UTF-8 when calling to the Unicode function ss_len_u(),
and as raw data when calling the functions not using Unicode
interpretation (ss_len()/ss_size()). Strings below 256 bytes take just
5 bytes for internal structure, and 5 * sizeof(size_t) for bigger
strings. Unicode size is cached between operations, when possible, so
in those cases UTF-8 string length computation would be O(1).
uint32_t ss_adler32(const srt_string *s)
- String Adler32 checksum
- const srt_string *s: string
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_adler32r(const srt_string *s, uint32_t adler, size_t off1, size_t off2)
- Adler32 checksum for substring
- const srt_string *s: string
- uint32_t adler: Adler32 resulting from previous chained Adler32 calls (use S_ADLER32_INIT for the first call)
- size_t off1: start offset
- size_t off2: end offset
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_alloc(size_t initial_heap_reserve)
- Allocate string (heap)
- size_t initial_heap_reserve: space preallocated to store n elements
- Return (srt_string *): allocated string
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool ss_alloc_errors(const srt_string *s)
- Check if string had allocation errors
- const srt_string *s: string
- Return (srt_bool): S_TRUE: has errors; S_FALSE: no errors
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_alloca(size_t max_size)
- Allocate string (stack)
- size_t max_size: space preallocated to store n elements
- Return (srt_string *): allocated string
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_at(const srt_string *s, size_t off)
- Random access to byte
- const srt_string *s: string
- size_t off: offset (bytes)
- Return (int): 0..255: byte retrieved ok; < 0: out of range
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_capacity(const srt_string *s)
- Get allocated space
- const srt_string *s: vector
- Return (size_t): current allocated space (in bytes)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_capacity_left(const srt_string *s)
- Get preallocated space left
- const srt_string *s: string
- Return (size_t): allocated space left (in bytes)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat(srt_string **s, const srt_string *s1, ...)
- Concatenate to string one or more strings
- srt_string **s: output string
- const srt_string *s1: input string
- ...: optional input strings
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_c(srt_string **s, const char *s1, ...)
- Concatenate multiple C strings (byte/UTF-8 mode)
- srt_string **s: output string
- const char *s1: input string
- ...: optional input strings
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_char(srt_string **s, int c)
- Concatenate string with a string with just one character
- srt_string **s: output string
- int c: input character
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_cn(srt_string **s, const char *src, size_t src_size)
- Concatenate C substring (byte/UTF-8 mode)
- srt_string **s: output string
- const char *src: input C string
- size_t src_size: input string size (bytes)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_b64(srt_string **s, const srt_string *src)
- Concatenate string with input string base64 decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_esc_dquote(srt_string **s, const srt_string *src)
- Concatenate string unescaping "" as "
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_esc_json(srt_string **s, const srt_string *src)
- Concatenate string with input string JSON escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_esc_squote(srt_string **s, const srt_string *src)
- Concatenate string unescaping '' as '
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_esc_url(srt_string **s, const srt_string *src)
- Concatenate string with input string URL escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_esc_xml(srt_string **s, const srt_string *src)
- Concatenate string with input string XML escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_hex(srt_string **s, const srt_string *src)
- Concatenate string with input string hexadecimal (lowercase) decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_dec_lz(srt_string **s, const srt_string *src)
- Concatenate string with input string LZ decoded copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_HEX(srt_string **s, const srt_string *src)
- Concatenate string with input string hexadecimal (uppercase) encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_b64(srt_string **s, const srt_string *src)
- Concatenate string with input string base64 encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_esc_dquote(srt_string **s, const srt_string *src)
- Concatenate string escaping " as ""
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_esc_json(srt_string **s, const srt_string *src)
- Concatenate string with input string JSON escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_esc_squote(srt_string **s, const srt_string *src)
- Concatenate string escaping ' as ''
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_esc_url(srt_string **s, const srt_string *src)
- Concatenate string with input string URL escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_esc_xml(srt_string **s, const srt_string *src)
- Concatenate string with input string XML escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_hex(srt_string **s, const srt_string *src)
- Concatenate string with input string hexadecimal (lowercase) encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_lz(srt_string **s, const srt_string *src)
- Concatenate string with input string LZ encoded copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_enc_lzh(srt_string **s, const srt_string *src)
- Concatenate string with input string LZ encoded copy (high compression)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_erase(srt_string **s, const srt_string *src, size_t off, size_t n)
- Concatenate string with erase operation (byte/UTF-8 mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: input string byte offset for erase start
- size_t n: erase count (bytes)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)
- Concatenate string with erase operation (Unicode character mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t char_off: input character string offset for erase start
- size_t n: erase count (characters)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_int(srt_string **s, int64_t num)
- Concatenate integer
- srt_string **s: output string
- int64_t num: integer (any signed integer size)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_ltrim(srt_string **s, const srt_string *src)
- Concatenate string with input string plus left-trim space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_printf(srt_string **s, size_t size, const char *fmt, ...)
- Concatenate string with printf operation
- srt_string **s: output string
- size_t size: printf output size (bytes)
- const char *fmt: printf format
- ...: printf parameters
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap)
- Concatenate string with printf_va operation
- srt_string **s: output string
- size_t size: printf output size (bytes)
- const char *fmt: printf format
- va_list ap: printf_va parameters
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_read(srt_string **s, FILE *handle, size_t max_bytes)
- Cat data read from file handle
- srt_string **s: output string
- FILE *handle: file handle
- size_t max_bytes: read max size (in bytes)
- Return (srt_string *): output result
- Time complexity: O(n): WARNING: involves external file I/O
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)
- Concatenate string with replace operation
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: offset for starting the replace operation (0 for the whole input string)
- const srt_string *s1: pattern to be replaced
- const srt_string *s2: patter replacement
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte)
- Concatenate string with input string copy plus resize operation (byte/UTF-8 mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t n: number of bytes of input string
- char fill_byte: byte for refill
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char)
- Concatenate string with input string copy plus resize operation (Unicode character)
- srt_string **s: output string
- srt_string *src: input string
- size_t n: number of characters of input string
- int fill_char: character for refill
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_rtrim(srt_string **s, const srt_string *src)
- Concatenate string with input string plus right-trim space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_substr(srt_string **s, const srt_string *src, size_t off, size_t n)
- Concatenate substring (byte/UTF-8 mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: input string substring byte offset
- size_t n: input string substring size (bytes)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)
- Concatenate substring (Unicode character mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t char_off: input substring character offset
- size_t n: input string substring size (characters)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_tolower(srt_string **s, const srt_string *src)
- Concatenate "lowercased" string
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_toupper(srt_string **s, const srt_string *src)
- Concatenate "uppercased" string
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_trim(srt_string **s, const srt_string *src)
- Concatenate string with input string plus trim (left and right) space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_w(srt_string **s, const char *s1, ...)
- Concatenate multiple "wide char" C strings (Unicode character mode)
- srt_string **s: output string
- const char *s1: input "wide char" C string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- ...: optional input "wide char" C strings
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cat_wn(srt_string **s, const wchar_t *src, size_t src_size)
- Concatenate "wide char" C substring (Unicode character mode)
- srt_string **s: output string
- const wchar_t *src: input "wide char" C string
- size_t src_size: input string size (characters) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_check(srt_string **s)
- Check and fix string (if input string is NULL, replaces it with a empty valid string)
- srt_string **s: output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void ss_clear(srt_string *s)
- Clear string
- srt_string *s: output string
- Return (void): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void ss_clear_errors(srt_string *s)
- Clear allocation/encoding error flags
- srt_string *s: string
- Return (void): -
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_cmp(const srt_string *s1, const srt_string *s2)
- String compare
- const srt_string *s1: string 1
- const srt_string *s2: string 2
- Return (int): 0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_cmpi(const srt_string *s1, const srt_string *s2)
- Case-insensitive string compare
- const srt_string *s1: string 1
- const srt_string *s2: string 2
- Return (int): 0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy(srt_string **s, const srt_string *src)
- Overwrite string with a string copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_c(srt_string **s, ...)
- Overwrite string with multiple C string copy (strict aliasing is assumed)
- srt_string **s: output string
- ...: input strings (one or more C strings)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_char(srt_string **s, int c)
- Overwrite string with a string with just one character
- srt_string **s: output string
- int c: input character
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_cn(srt_string **s, const char *src, size_t src_size)
- Overwrite string with C string copy (strict aliasing is assumed)
- srt_string **s: output string
- const char *src: input string
- size_t src_size: input string bytes
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_b64(srt_string **s, const srt_string *src)
- Overwrite string with input string base64 decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_esc_dquote(srt_string **s, const srt_string *src)
- Overwrite string unescaping "" as "
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_esc_json(srt_string **s, const srt_string *src)
- Overwrite string with input string JSON escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_esc_squote(srt_string **s, const srt_string *src)
- Overwrite string unescaping '' as '
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_esc_url(srt_string **s, const srt_string *src)
- Overwrite string with input string URL escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_esc_xml(srt_string **s, const srt_string *src)
- Overwrite string with input string XML escape decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_hex(srt_string **s, const srt_string *src)
- Overwrite string with input string hexadecimal (lowercase) decoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_dec_lz(srt_string **s, const srt_string *src)
- Overwrite string with input string LZ decoded copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_HEX(srt_string **s, const srt_string *src)
- Overwrite string with input string hexadecimal (uppercase) encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_b64(srt_string **s, const srt_string *src)
- Overwrite string with input string base64 encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_esc_dquote(srt_string **s, const srt_string *src)
- Overwrite string with input string escaping " as ""
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_esc_json(srt_string **s, const srt_string *src)
- Overwrite string with input string JSON escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_esc_squote(srt_string **s, const srt_string *src)
- Overwrite string with input string escaping ' as ''
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_esc_url(srt_string **s, const srt_string *src)
- Overwrite string with input string URL escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_esc_xml(srt_string **s, const srt_string *src)
- Overwrite string with input string XML escape encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_hex(srt_string **s, const srt_string *src)
- Overwrite string with input string hexadecimal (lowercase) encoding copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_lz(srt_string **s, const srt_string *src)
- Overwrite string with input string LZ encoded copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_enc_lzh(srt_string **s, const srt_string *src)
- Overwrite string with input string LZ encoded copy (high compression)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_erase(srt_string **s, const srt_string *src, size_t off, size_t n)
- Overwrite string with input string copy applying a erase operation (byte/UTF-8 mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: input string erase start byte offset
- size_t n: number of bytes to erase
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)
- Overwrite string with input string copy applying a erase operation (character mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t char_off: input string erase start character offset
- size_t n: number of characters to erase
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_int(srt_string **s, int64_t num)
- Overwrite string with integer to string copy
- srt_string **s: output string
- int64_t num: integer (any signed integer size)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_ltrim(srt_string **s, const srt_string *src)
- Overwrite string with input string plus left-trim space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_printf(srt_string **s, size_t size, const char *fmt, ...)
- Overwrite string with printf operation
- srt_string **s: output string
- size_t size: printf output size (bytes)
- const char *fmt: printf format
- ...: printf parameters
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap)
- Overwrite string with printf_va operation
- srt_string **s: output string
- size_t size: printf output size (bytes)
- const char *fmt: printf format
- va_list ap: printf_va parameters
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_read(srt_string **s, FILE *handle, size_t max_bytes)
- Read from file handle
- srt_string **s: output string
- FILE *handle: file handle
- size_t max_bytes: read max size (in bytes)
- Return (srt_string *): output result
- Time complexity: O(n): WARNING: involves external file I/O
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)
- Overwrite string with input string plus replace operation
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: offset for starting the replace operation (0 for the whole input string)
- const srt_string *s1: pattern to be replaced
- const srt_string *s2: patter replacement
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte)
- Overwrite string with input string copy plus resize operation (byte/UTF-8 mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t n: number of bytes of input string
- char fill_byte: byte for refill
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char)
- Overwrite string with input string copy plus resize operation (byte/UTF-8 mode)
- srt_string **s: output string
- srt_string *src: input string
- size_t n: number of bytes of input string
- int fill_char: byte for refill
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_rtrim(srt_string **s, const srt_string *src)
- Overwrite string with input string plus right-trim space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_substr(srt_string **s, const srt_string *src, size_t off, size_t n)
- Overwrite string with a substring copy (byte mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t off: input string start offset (bytes)
- size_t n: number of bytes to be copied
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)
- Overwrite string with a substring copy (character mode)
- srt_string **s: output string
- const srt_string *src: input string
- size_t char_off: input string start offset (characters)
- size_t n: number of characters to be copied
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_tolower(srt_string **s, const srt_string *src)
- Overwrite string with input string lowercase conversion copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_toupper(srt_string **s, const srt_string *src)
- Overwrite string with input string uppercase conversion copy
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_trim(srt_string **s, const srt_string *src)
- Overwrite string with input string plus trim (left and right) space removal operation
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_w(srt_string **s, ...)
- Overwrite string with multiple C "wide char" Unicode string copy (strict aliasing is assumed) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- srt_string **s: output string
- ...: input strings (one or more C "wide char" strings)
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_cpy_wn(srt_string **s, const wchar_t *src, size_t src_size)
- Overwrite string with "wide char" Unicode string copy (strict aliasing is assumed) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- srt_string **s: output string
- const wchar_t *src: input string ("wide char" Unicode)
- size_t src_size: input string number of characters
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_crc32(const srt_string *s)
- String CRC-32 checksum
- const srt_string *s: string
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_crc32r(const srt_string *s, uint32_t crc, size_t off1, size_t off2)
- CRC-32 checksum for substring
- const srt_string *s: string
- uint32_t crc: CRC resulting from previous chained CRC calls (use S_CRC32_INIT for the first call)
- size_t off1: start offset
- size_t off2: end offset
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *ss_cref(srt_string_ref *s_ref, const char *c_str)
- Create a reference from C string. This is intended for avoid duplicating C strings when working with srt_string functions
- srt_string_ref *s_ref: string reference to be built (can be on heap or stack, it is a small structure)
- const char *c_str: input C string (0 terminated ASCII or UTF-8 string)
- Return (const srt_string *): srt_string string derived from srt_string_ref
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *ss_crefa(const char *c_str)
- Create a reference from C string using implicit stack allocation for the reference handling (be cafeful not using this inside a loop -for loops you can e.g. use ss_build_ref() instead of this, using a local variable allocated in the stack for the reference-)
- const char *c_str: input C string (0 terminated ASCII or UTF-8 string)
- Return (const srt_string *): srt_string string derived from srt_string_ref
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_b64(srt_string **s, const srt_string *src)
- Decode from base64
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_esc_dquote(srt_string **s, const srt_string *src)
- Unescape "" as "
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_esc_json(srt_string **s, const srt_string *src)
- Unescape from JSON encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_esc_squote(srt_string **s, const srt_string *src)
- Unescape '' as '
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_esc_url(srt_string **s, const srt_string *src)
- Unescape from URL encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_esc_xml(srt_string **s, const srt_string *src)
- Unescape from XML encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_hex(srt_string **s, const srt_string *src)
- Decode from hexadecimal (lowercase)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dec_lz(srt_string **s, const srt_string *src)
- Decode from LZ
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup(const srt_string *src)
- Duplicate string
- const srt_string *src: string
- Return (srt_string *): Output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_c(const char *src)
- Duplicate from C String (ASCII-z)
- const char *src: C string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_char(int c)
- Duplicate string from character
- int c: Unicode character
- Return (srt_string *): output result
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_cn(const char *src, size_t src_size)
- Duplicate from C string
- const char *src: C string buffer
- size_t src_size: number of bytes
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_b64(const srt_string *src)
- Duplicate string with base64 decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_esc_dquote(const srt_string *src)
- Duplicate string unescaping "" as "
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_esc_json(const srt_string *src)
- Duplicate string with JSON escape decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_esc_squote(const srt_string *src)
- Duplicate string unescaping '' as '
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_esc_url(const srt_string *src)
- Duplicate string with URL escape decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_esc_xml(const srt_string *src)
- Duplicate string with XML escape decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_hex(const srt_string *src)
- Duplicate string with hex decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_dec_lz(const srt_string *src)
- Duplicate string with LZ decoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_HEX(const srt_string *src)
- Duplicate string with hex encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_b64(const srt_string *src)
- Duplicate string with base64 encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_esc_dquote(const srt_string *src)
- Duplicate string escaping " as ""
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_esc_json(const srt_string *src)
- Duplicate string with JSON escape encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_esc_squote(const srt_string *src)
- Duplicate string escaping ' as ''
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_esc_url(const srt_string *src)
- Duplicate string with URL escape encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_esc_xml(const srt_string *src)
- Duplicate string with XML escape encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_hex(const srt_string *src)
- Duplicate string with hex encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_lz(const srt_string *src)
- Duplicate string with LZ encoding
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_enc_lzh(const srt_string *src)
- Duplicate string with LZ encoding (high compession)
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_erase(const srt_string *src, size_t off, size_t n)
- Duplicate from string erasing portion from input
- const srt_string *src: string
- size_t off: byte offset
- size_t n: number of bytes
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_erase_u(const srt_string *src, size_t char_off, size_t n)
- Duplicate from Unicode "wide char" string erasing portion from input
- const srt_string *src: string
- size_t char_off: character offset
- size_t n: number of characters
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_int(int64_t num)
- Duplicate from integer
- int64_t num: integer
- Return (srt_string *): output result
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_ltrim(const srt_string *src)
- Duplicate and apply trim at left side
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_printf(size_t size, const char *fmt, ...)
- Duplicate from printf formatting
- size_t size: printf space (bytes)
- const char *fmt: printf format
- ...: optional printf parameters
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_printf_va(size_t size, const char *fmt, va_list ap)
- Duplicate from printf_va formatting
- size_t size: printf_va space (bytes)
- const char *fmt: printf format
- va_list ap: variable argument reference
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_read(FILE *handle, size_t max_bytes)
- Duplicate from reading from file handle
- FILE *handle: file handle
- size_t max_bytes: read max size (in bytes)
- Return (srt_string *): output result
- Time complexity: O(n): WARNING: involves external file I/O
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_replace(const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)
- Duplicate and apply replace operation after offset
- const srt_string *src: string
- size_t off: offset (bytes)
- const srt_string *s1: needle
- const srt_string *s2: needle replacement
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_resize(const srt_string *src, size_t n, char fill_byte)
- Duplicate and resize (byte addressing)
- const srt_string *src: string
- size_t n: new size (bytes)
- char fill_byte: fill byte
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_resize_u(srt_string *src, size_t n, int fill_char)
- Duplicate and resize (Unicode addressing)
- srt_string *src: string
- size_t n: new size (characters)
- int fill_char: fill character
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_rtrim(const srt_string *src)
- Duplicate and apply trim at right side
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_substr(const srt_string *src, size_t off, size_t n)
- Duplicate from substring
- const srt_string *src: string
- size_t off: byte offset
- size_t n: number of bytes
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_substr_u(const srt_string *src, size_t char_off, size_t n)
- Duplicate from substring
- const srt_string *src: string
- size_t char_off: character offset
- size_t n: number of characters
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_tolower(const srt_string *src)
- Duplicate string with lowercase conversion
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_toupper(const srt_string *src)
- Duplicate string with uppercase conversion
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_trim(const srt_string *src)
- Duplicate and trim string
- const srt_string *src: string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_w(const wchar_t *src)
- Duplicate from "wide char" Unicode string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- const wchar_t *src: "wide char" string
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_dup_wn(const wchar_t *src, size_t src_size)
- Duplicate from Unicode "wide char" string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- const wchar_t *src: "wide char" string
- size_t src_size: number of characters
- Return (srt_string *): output result
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool ss_empty(const srt_string *s)
- Tells if a string is empty (zero elements)
- const srt_string *s: string
- Return (srt_bool): S_TRUE: empty string; S_FALSE: not empty
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_HEX(srt_string **s, const srt_string *src)
- Convert to hexadecimal (uppercase)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_b64(srt_string **s, const srt_string *src)
- Convert to base64
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_esc_dquote(srt_string **s, const srt_string *src)
- Convert/escape escaping " as ""
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_esc_json(srt_string **s, const srt_string *src)
- Convert/escape for JSON encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_esc_squote(srt_string **s, const srt_string *src)
- Convert/escape escaping ' as ''
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_esc_url(srt_string **s, const srt_string *src)
- Convert/escape for URL encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_esc_xml(srt_string **s, const srt_string *src)
- Convert/escape for XML encoding
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_hex(srt_string **s, const srt_string *src)
- Convert to hexadecimal (lowercase)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_lz(srt_string **s, const srt_string *src)
- Convert to LZ
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_enc_lzh(srt_string **s, const srt_string *src)
- Convert to LZ (high compression)
- srt_string **s: output string
- const srt_string *src: input string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool ss_encoding_errors(const srt_string *s)
- Check if string had UTF8 encoding errors
- const srt_string *s: string
- Return (srt_bool): S_TRUE: has errors; S_FALSE: no errors
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_erase(srt_string **s, size_t off, size_t n)
- Erase portion of a string (byte/UTF-8 mode)
- srt_string **s: input/output string
- size_t off: byte offset where to start the cut
- size_t n: number of bytes to be cut
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_erase_u(srt_string **s, size_t char_off, size_t n)
- Erase portion of a string (Unicode character mode)
- srt_string **s: input/output string
- size_t char_off: character offset where to start the cut
- size_t n: number of characters to be cut
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_find(const srt_string *s, size_t off, const srt_string *tgt)
- Find substring into string
- const srt_string *s: input string
- size_t off: search offset start
- const srt_string *tgt: target string
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_find_cn(const srt_string *s, size_t off, const char *t, size_t ts)
- Find n bytes
- const srt_string *s: input string
- size_t off: search offset start
- const char *t: target buffer
- size_t ts: target buffer size (bytes)
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findb(const srt_string *s, size_t off)
- Find blank (9, 10, 13, 32) character into string
- const srt_string *s: input string
- size_t off: search offset start
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findc(const srt_string *s, size_t off, char c)
- Find byte into string
- const srt_string *s: input string
- size_t off: search offset start
- char c: target character
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findcx(const srt_string *s, size_t off, uint8_t c_min, uint8_t c_max)
- Find first byte between a min and a max value
- const srt_string *s: input string
- size_t off: search offset start
- uint8_t c_min: target byte mininum value
- uint8_t c_max: target byte maximum value
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findnb(const srt_string *s, size_t off)
- Find non-blank (9, 10, 13, 32) character into string
- const srt_string *s: input string
- size_t off: search offset start
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findr(const srt_string *s, size_t off, size_t max_off, const srt_string *tgt)
- Find substring into string (in range)
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- const srt_string *tgt: target string
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findr_cn(const srt_string *s, size_t off, size_t max_off, const char *t, size_t ts)
- Find n bytes
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- const char *t: target buffer
- size_t ts: target buffer size (bytes)
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findrb(const srt_string *s, size_t off, size_t max_off)
- Find blank (9, 10, 13, 32) character into string (in range)
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findrc(const srt_string *s, size_t off, size_t max_off, char c)
- Find byte into string (in range)
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- char c: target character
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findrcx(const srt_string *s, size_t off, size_t max_off, uint8_t c_min, uint8_t c_max)
- Find first byte between a min and a max value
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- uint8_t c_min: target byte mininum value
- uint8_t c_max: target byte maximum value
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findrnb(const srt_string *s, size_t off, size_t max_off)
- Find non-blank (9, 10, 13, 32) character into string (in range)
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findru(const srt_string *s, size_t off, size_t max_off, int c)
- Find Unicode character into string (in range)
- const srt_string *s: input string
- size_t off: search offset start
- size_t max_off: max offset (S_NPOS for end of string)
- int c: target character
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_findu(const srt_string *s, size_t off, int c)
- Find Unicode character into string
- const srt_string *s: input string
- size_t off: search offset start
- int c: target character
- Return (size_t): Offset location if found, S_NPOS if not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_fnv1(const srt_string *s)
- String FNV-1 checksum
- const srt_string *s: string
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_fnv1a(const srt_string *s)
- String FNV-1A checksum
- const srt_string *s: string
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_fnv1ar(const srt_string *s, uint32_t fnv, size_t off1, size_t off2)
- FNV-1A checksum for substring
- const srt_string *s: string
- uint32_t fnv: FNV resulting from previous chained FNV-1A calls (use S_FNV1_INIT for the first call)
- size_t off1: start offset
- size_t off2: end offset
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_fnv1r(const srt_string *s, uint32_t fnv, size_t off1, size_t off2)
- FNV-1 checksum for substring
- const srt_string *s: string
- uint32_t fnv: FNV-1 resulting from previous chained FNV-1 calls (use S_FNV1_INIT for the first call)
- size_t off1: start offset
- size_t off2: end offset
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void ss_free(srt_string **s, ...)
- Free one or more strings (heap)
- srt_string **s: string
- ...: more strings (optional)
- Return (void): -
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
char *ss_get_buffer(srt_string *s)
- Get string buffer access
- srt_string *s: string
- Return (char *): pointer to the insternal string buffer (UTF-8 or raw data)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const char *ss_get_buffer_r(const srt_string *s)
- Get string buffer access (read-only)
- const srt_string *s: string
- Return (const char *): pointer to the internal string buffer (UTF-8 or raw data)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_get_buffer_size(const srt_string *v)
- Get string buffer size
- const srt_string *v: string
- Return (size_t): Number of bytes in use for storing all string characters
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_getchar(const srt_string *s, size_t *autoinc_off)
- Get next Unicode character
- const srt_string *s: input string
- size_t *autoinc_off: iterator
- Return (int): Output character, or EOF if no more characters left
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_grow(srt_string **s, size_t extra_elems)
- Reserve space for extra elements (relative to current string size)
- srt_string **s: string
- size_t extra_elems: number of extra elements
- Return (size_t): extra size allocated
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_len(const srt_string *s)
- Equivalent to ss_size
- const srt_string *s: string
- Return (size_t): Number of bytes (UTF-8 string length)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_len_u(const srt_string *s)
- String length (Unicode)
- const srt_string *s: string
- Return (size_t): number of Unicode characters
- Time complexity: O(1) if cached, O(n) if not previously computed
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_ltrim(srt_string **s)
- Remove spaces from left side
- srt_string **s: input/output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_max(const srt_string *s)
- Get the maximum possible string size
- const srt_string *s: string
- Return (size_t): max string size (bytes)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_mh3_32(const srt_string *s)
- String MurmurHash3-32 checksum
- const srt_string *s: string
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t ss_mh3_32r(const srt_string *s, uint32_t acc, size_t off1, size_t off2)
- MurmurHash3-32 checksum for substring
- const srt_string *s: string
- uint32_t acc: MH3-32 accumulator from previous chained MH3-32 calls (use S_MH3_32_INIT for the first call)
- size_t off1: start offset
- size_t off2: end offset
- Return (uint32_t): 32-bit hash
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_ncmp(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n)
- Partial string compare
- const srt_string *s1: string 1
- size_t s1off: string 1 offset (bytes
- const srt_string *s2: string 2
- size_t n: comparison size (bytes)
- Return (int): 0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_ncmpi(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n)
- Partial case insensitive string compare
- const srt_string *s1: string 1
- size_t s1off: string 1 offset (bytes
- const srt_string *s2: string 2
- size_t n: comparison size (bytes)
- Return (int): 0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_popchar(srt_string **s)
- Extract last character from string
- srt_string **s: input/output string
- Return (int): Extracted character if OK, EOF if empty
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_printf(srt_string **s, size_t size, const char *fmt, ...)
- printf operation on string
- srt_string **s: output string
- size_t size: printf max output size -including the 0 terminator- (bytes)
- const char *fmt: printf "format"
- ...: printf "format" parameters
- Return (int): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int ss_putchar(srt_string **s, int c)
- Append Unicode character to string
- srt_string **s: output string
- int c: Unicode character
- Return (int): Echo of the output character or EOF if overflow error
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
ssize_t ss_read(srt_string **s, FILE *handle, size_t max_bytes)
- Read from file handle
- srt_string **s: output string
- FILE *handle: file handle
- size_t max_bytes: read max size (in bytes)
- Return (ssize_t): output result
- Time complexity: O(n): WARNING: involves external file I/O
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *ss_ref(const srt_string_ref *s_ref)
- Get string reference from string reference container
- const srt_string_ref *s_ref: string reference container
- Return (const srt_string *): srt_string string derived from srt_string_ref
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *ss_ref_buf(srt_string_ref *s_ref, const char *buf, size_t buf_size)
- Create a reference from raw data, i.e. not assuming is 0 terminated. WARNING: when using raw references when calling ss_to_c() will return a "" string (safety)), so, if you need a reference to the internal raw buffer use ss_get_buffer_r() instead
- srt_string_ref *s_ref: string reference to be built (can be on heap or stack, it is a small structure)
- const char *buf: input raw data buffer
- size_t buf_size: input buffer size (bytes)
- Return (const srt_string *): srt_string string derived from srt_string_ref
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *ss_refa_buf(const char *buf, size_t buf_size)
- Create a reference from raw data, i.e. not 0 terminated, using implicit stack allocation for the reference handling (be cafeful not using this inside a loop -for loops you can e.g. use ss_build_ref() instead of this, using a local variable allocated in the stack for the reference-). WARNING: when using raw references when calling ss_to_c() will return a "" string (safety), so, if you need a reference to the internal raw buffer use ss_get_buffer_r() instead
- const char *buf: input raw data buffer
- size_t buf_size: input buffer size (bytes)
- Return (const srt_string *): srt_string string derived from srt_string_ref
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_replace(srt_string **s, size_t off, const srt_string *s1, const srt_string *s2)
- Replace into string
- srt_string **s: input/output string
- size_t off: byte offset where to start applying the replace operation
- const srt_string *s1: target pattern
- const srt_string *s2: replacement pattern
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_reserve(srt_string **s, size_t max_elems)
- Reserve space for at least N bytes (absolute reserve)
- srt_string **s: string
- size_t max_elems: absolute element reserve
- Return (size_t): reserved elements
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_resize(srt_string **s, size_t n, char fill_byte)
- Resize string (byte/UTF-8 mode)
- srt_string **s: input/output string
- size_t n: new size in bytes
- char fill_byte: fill byte
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_resize_u(srt_string **s, size_t n, int fill_char)
- Resize string (Unicode character mode)
- srt_string **s: input/output string
- size_t n: new size in characters
- int fill_char: fill character
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_rtrim(srt_string **s)
- Remove spaces from right side
- srt_string **s: input/output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool ss_set_turkish_mode(srt_bool enable_turkish_mode)
- Set Turkish mode locale (related to case conversion)
- srt_bool enable_turkish_mode: S_TRUE: enable turkish mode, S_FALSE: disable
- Return (srt_bool): S_TRUE: conversion functions OK, S_FALSE: error (missing functions)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_shrink(srt_string **s)
- Free unused space
- srt_string **s: string
- Return (srt_string *): same string (optional usage)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_size(const srt_string *s)
- Get string size
- const srt_string *s: string
- Return (size_t): string bytes used in UTF8 format
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t ss_split(const srt_string *src, const srt_string *separator, srt_string_ref out_substrings[], size_t max_refs)
- Split/tokenize: break string by separators
- const srt_string *src: input string
- const srt_string *separator: separator
- srt_string_ref out_substrings[]: output substring references
- size_t max_refs: number of output substrings
- Return (size_t): Number of elements
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const char *ss_to_c(const srt_string *s)
- Give a C-compatible zero-ended string reference (byte/UTF-8 mode)
- const srt_string *s: input string
- Return (const char *): Zero-ended C compatible string reference (UTF-8)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const wchar_t *ss_to_w(const srt_string *s, wchar_t *o, size_t nmax, size_t *n)
- Give a C-compatible zero-ended string reference ("wide char" Unicode mode) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)
- const srt_string *s: input string
- wchar_t *o: output string buffer
- size_t nmax: output string max characters
- size_t *n: output string size
- Return (const wchar_t *): Zero'ended C compatible string reference ("wide char" Unicode mode)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_tolower(srt_string **s)
- Convert string to lowercase
- srt_string **s: output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_toupper(srt_string **s)
- Convert string to uppercase
- srt_string **s: output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_string *ss_trim(srt_string **s)
- Remove spaces from left and right side
- srt_string **s: input/output string
- Return (srt_string *): output string reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
ssize_t ss_write(FILE *handle, const srt_string *s, size_t offset, size_t bytes)
- Write to file
- FILE *handle: output file
- const srt_string *s: string
- size_t offset: string offset
- size_t bytes: bytes to write
- Return (ssize_t): written bytes < 0: error
- Time complexity: O(n): WARNING: involves external file I/O
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)