File syn_str.c¶
FileList > src > syntropic > util > syn_str.c
Go to the source code of this file
Zero-allocation string parsing, trimming, and tokenization utilities.
#include "syn_str.h"#include "syn_assert.h"#include <ctype.h>#include <stdlib.h>#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| size_t | syn_str_split (char * str, char delimiter, char * tokens, size_t max_tokens) Split a string in-place by a delimiter character into a token array. |
| bool | syn_str_to_i32 (const char * str, int32_t * out_val) Parse a signed 32-bit integer from a string safely. |
| bool | syn_str_to_u32 (const char * str, uint32_t * out_val) Parse an unsigned 32-bit integer from a string safely. |
| char * | syn_str_trim (char * str) Trim leading and trailing whitespace characters in-place. |
Public Functions Documentation¶
function syn_str_split¶
Split a string in-place by a delimiter character into a token array.
Replaces occurrences of delimiter with '\0' and populates the tokens array. Zero-allocation. Modifies the input string.
Parameters:
strNull-terminated input string (modified in-place).delimiterCharacter to split on (e.g. ',' or ' ').tokensArray of char pointers to store token starts.max_tokensMaximum capacity of tokens array.
Returns:
Number of tokens stored in tokens array.
function syn_str_to_i32¶
Parse a signed 32-bit integer from a string safely.
Parameters:
strInput string to parse.out_valPointer to store parsed int32_t result.
Returns:
true if successfully parsed, false on error or empty string.
function syn_str_to_u32¶
Parse an unsigned 32-bit integer from a string safely.
Parameters:
strInput string to parse.out_valPointer to store parsed uint32_t result.
Returns:
true if successfully parsed, false on error or empty string.
function syn_str_trim¶
Trim leading and trailing whitespace characters in-place.
Parameters:
strNull-terminated input string (modified in-place).
Returns:
Pointer to the first non-whitespace character in str.
The documentation for this class was generated from the following file src/syntropic/util/syn_str.c