--- a/src/cx/string.h Mon Feb 10 21:30:51 2025 +0100 +++ b/src/cx/string.h Mon Feb 10 20:59:02 2025 +0100 @@ -42,6 +42,7 @@ /** * The maximum length of the "needle" in cx_strstr() that can use SBO. */ +cx_attr_export extern const unsigned cx_strstr_sbo_size; /** @@ -175,6 +176,7 @@ cx_attr_nonnull cx_attr_nodiscard cx_attr_cstr_arg(1) +cx_attr_export cxmutstr cx_mutstr(char *cstring); /** @@ -195,6 +197,7 @@ */ cx_attr_nodiscard cx_attr_access_rw(1, 2) +cx_attr_export cxmutstr cx_mutstrn( char *cstring, size_t length @@ -218,6 +221,7 @@ cx_attr_nonnull cx_attr_nodiscard cx_attr_cstr_arg(1) +cx_attr_export cxstring cx_str(const char *cstring); @@ -239,6 +243,7 @@ */ cx_attr_nodiscard cx_attr_access_r(1, 2) +cx_attr_export cxstring cx_strn( const char *cstring, size_t length @@ -307,6 +312,7 @@ * * @param str the string to free */ +cx_attr_export void cx_strfree(cxmutstr *str); /** @@ -323,6 +329,7 @@ * @param str the string to free */ cx_attr_nonnull_arg(1) +cx_attr_export void cx_strfree_a( const CxAllocator *alloc, cxmutstr *str @@ -341,6 +348,7 @@ * @return the accumulated length of all strings */ cx_attr_nodiscard +cx_attr_export size_t cx_strlen( size_t count, ... @@ -370,6 +378,7 @@ */ cx_attr_nodiscard cx_attr_nonnull +cx_attr_export cxmutstr cx_strcat_ma( const CxAllocator *alloc, cxmutstr str, @@ -458,6 +467,7 @@ * @see cx_strsubsl_m() */ cx_attr_nodiscard +cx_attr_export cxstring cx_strsubs( cxstring string, size_t start @@ -483,6 +493,7 @@ * @see cx_strsubsl_m() */ cx_attr_nodiscard +cx_attr_export cxstring cx_strsubsl( cxstring string, size_t start, @@ -505,6 +516,7 @@ * @see cx_strsubsl() */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strsubs_m( cxmutstr string, size_t start @@ -530,6 +542,7 @@ * @see cx_strsubsl() */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strsubsl_m( cxmutstr string, size_t start, @@ -549,6 +562,7 @@ * @see cx_strchr_m() */ cx_attr_nodiscard +cx_attr_export cxstring cx_strchr( cxstring string, int chr @@ -567,6 +581,7 @@ * @see cx_strchr() */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strchr_m( cxmutstr string, int chr @@ -585,6 +600,7 @@ * @see cx_strrchr_m() */ cx_attr_nodiscard +cx_attr_export cxstring cx_strrchr( cxstring string, int chr @@ -603,6 +619,7 @@ * @see cx_strrchr() */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strrchr_m( cxmutstr string, int chr @@ -625,6 +642,7 @@ * @see cx_strstr_m() */ cx_attr_nodiscard +cx_attr_export cxstring cx_strstr( cxstring haystack, cxstring needle @@ -647,6 +665,7 @@ * @see cx_strstr() */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strstr_m( cxmutstr haystack, cxstring needle @@ -667,6 +686,7 @@ cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) +cx_attr_export size_t cx_strsplit( cxstring string, cxstring delim, @@ -696,6 +716,7 @@ cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) +cx_attr_export size_t cx_strsplit_a( const CxAllocator *allocator, cxstring string, @@ -720,6 +741,7 @@ cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) +cx_attr_export size_t cx_strsplit_m( cxmutstr string, cxstring delim, @@ -749,6 +771,7 @@ cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) +cx_attr_export size_t cx_strsplit_ma( const CxAllocator *allocator, cxmutstr string, @@ -766,6 +789,7 @@ * than @p s2, zero if both strings equal */ cx_attr_nodiscard +cx_attr_export int cx_strcmp( cxstring s1, cxstring s2 @@ -780,6 +804,7 @@ * than @p s2, zero if both strings equal ignoring case */ cx_attr_nodiscard +cx_attr_export int cx_strcasecmp( cxstring s1, cxstring s2 @@ -797,6 +822,7 @@ */ cx_attr_nodiscard cx_attr_nonnull +cx_attr_export int cx_strcmp_p( const void *s1, const void *s2 @@ -814,6 +840,7 @@ */ cx_attr_nodiscard cx_attr_nonnull +cx_attr_export int cx_strcasecmp_p( const void *s1, const void *s2 @@ -834,6 +861,7 @@ */ cx_attr_nodiscard cx_attr_nonnull +cx_attr_export cxmutstr cx_strdup_a_( const CxAllocator *allocator, cxstring string @@ -880,6 +908,7 @@ * @return the trimmed string */ cx_attr_nodiscard +cx_attr_export cxstring cx_strtrim(cxstring string); /** @@ -892,6 +921,7 @@ * @return the trimmed string */ cx_attr_nodiscard +cx_attr_export cxmutstr cx_strtrim_m(cxmutstr string); /** @@ -903,6 +933,7 @@ * @c false otherwise */ cx_attr_nodiscard +cx_attr_export bool cx_strprefix( cxstring string, cxstring prefix @@ -917,6 +948,7 @@ * @c false otherwise */ cx_attr_nodiscard +cx_attr_export bool cx_strsuffix( cxstring string, cxstring suffix @@ -931,6 +963,7 @@ * @c false otherwise */ cx_attr_nodiscard +cx_attr_export bool cx_strcaseprefix( cxstring string, cxstring prefix @@ -945,6 +978,7 @@ * @c false otherwise */ cx_attr_nodiscard +cx_attr_export bool cx_strcasesuffix( cxstring string, cxstring suffix @@ -971,6 +1005,7 @@ */ cx_attr_nodiscard cx_attr_nonnull +cx_attr_export cxmutstr cx_strreplacen_a( const CxAllocator *allocator, cxstring str, @@ -1049,6 +1084,7 @@ * @return a new string tokenization context */ cx_attr_nodiscard +cx_attr_export CxStrtokCtx cx_strtok_( cxstring str, cxstring delim, @@ -1079,6 +1115,7 @@ cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(2) +cx_attr_export bool cx_strtok_next( CxStrtokCtx *ctx, cxstring *token @@ -1101,6 +1138,7 @@ cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(2) +cx_attr_export bool cx_strtok_next_m( CxStrtokCtx *ctx, cxmutstr *token @@ -1115,6 +1153,7 @@ */ cx_attr_nonnull cx_attr_access_r(2, 3) +cx_attr_export void cx_strtok_delim( CxStrtokCtx *ctx, const cxstring *delim, @@ -1139,7 +1178,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); /** @@ -1156,7 +1195,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); /** @@ -1173,7 +1212,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); /** @@ -1190,7 +1229,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); /** @@ -1207,7 +1246,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); /** @@ -1224,7 +1263,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); /** @@ -1241,7 +1280,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); /** @@ -1258,7 +1297,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); /** @@ -1275,7 +1314,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); /** @@ -1292,7 +1331,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); /** @@ -1309,7 +1348,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); /** @@ -1326,7 +1365,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); /** @@ -1343,7 +1382,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); /** @@ -1360,7 +1399,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); /** @@ -1377,7 +1416,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); /** @@ -1394,7 +1433,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); /** @@ -1411,7 +1450,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); /** @@ -1428,7 +1467,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); /** @@ -1445,7 +1484,7 @@ * @retval zero success * @retval non-zero conversion was not possible */ -cx_attr_access_w(2) cx_attr_nonnull_arg(2) +cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); /**