Mercurial > hg > th-libs
diff th_string.h @ 680:39c82d877251
Add new th_strelems_t structure for and join/split functions using them to
make certain operations nicer.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 04 Mar 2020 19:47:11 +0200 |
parents | 83a48de05fe9 |
children | 527a4d29d384 |
line wrap: on
line diff
--- a/th_string.h Wed Mar 04 19:45:26 2020 +0200 +++ b/th_string.h Wed Mar 04 19:47:11 2020 +0200 @@ -50,6 +50,13 @@ }; +typedef struct +{ + size_t nelems; + th_char_t **elems; +} th_strelems_t; + + /** @brief * Internal *printf() implementation flags */ @@ -162,8 +169,11 @@ int th_pstr_cpy(th_char_t **pdst, const th_char_t *src); int th_pstr_cat(th_char_t **pdst, const th_char_t *src); -int th_split_string(const char *str, char ***elems, size_t *nelems, const char *sep); -int th_join_string(char **str, char **elems, const size_t nelems, const char *sep); +int th_split_string_elems(const th_char_t *str, th_strelems_t *ctx, const th_char_t *sep); +int th_split_string(const th_char_t *str, th_char_t ***elems, size_t *nelems, const th_char_t *sep); +int th_join_string_elems(th_char_t **str, const th_strelems_t *ctx, const th_char_t *sep); +int th_join_string(th_char_t **str, th_char_t **elems, const size_t nelems, const th_char_t *sep); +void th_strlems_free(th_strelems_t *ctx); /* Internal printf() implementation. NOTICE! This API may be unstable.