43 #define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
45 #define PRINTFATTR(f, a)
51 EXPORT int wstrcmp_n(
const wchar_t *str1,
const wchar_t *str2,
size_t n);
64 static inline void dstr_init(
struct dstr *dst);
65 static inline void dstr_init_move(
struct dstr *dst,
struct dstr *src);
66 static inline void dstr_init_move_array(
struct dstr *dst,
char *str);
67 static inline void dstr_init_copy(
struct dstr *dst,
const char *src);
68 static inline void dstr_init_copy_dstr(
struct dstr *dst,
69 const struct dstr *src);
72 static inline void dstr_free(
struct dstr *dst);
73 static inline void dstr_array_free(
struct dstr *array,
const size_t count);
75 static inline void dstr_move(
struct dstr *dst,
struct dstr *src);
76 static inline void dstr_move_array(
struct dstr *dst,
char *str);
79 static inline void dstr_copy_dstr(
struct dstr *dst,
const struct dstr *src);
87 static inline void dstr_resize(
struct dstr *dst,
const size_t num);
88 static inline void dstr_reserve(
struct dstr *dst,
const size_t num);
90 static inline bool dstr_is_empty(
const struct dstr *str);
92 static inline void dstr_cat(
struct dstr *dst,
const char *array);
96 static inline void dstr_cat_ch(
struct dstr *dst,
char ch);
105 const struct dstr *str);
120 const
char *val1, const
char *val2, const
char *val3,
123 static inline const
char *dstr_find_i(const struct
dstr *str,
125 static inline const
char *dstr_find(const struct
dstr *str,
129 const
char *replace);
131 static inline
int dstr_cmp(const struct
dstr *str1, const
char *str2);
132 static inline
int dstr_cmpi(const struct
dstr *str1, const
char *str2);
133 static inline
int dstr_ncmp(const struct
dstr *str1, const
char *str2,
135 static inline
int dstr_ncmpi(const struct
dstr *str1, const
char *str2,
143 const
size_t start, const
size_t count);
147 static inline
char dstr_end(const struct
dstr *str);
161 static inline void dstr_init(
struct dstr *dst)
168 static inline void dstr_init_move_array(
struct dstr *dst,
char *str)
171 dst->
len = (!str) ? 0 : strlen(str);
175 static inline void dstr_init_move(
struct dstr *dst,
struct dstr *src)
181 static inline void dstr_init_copy(
struct dstr *dst,
const char *str)
187 static inline void dstr_init_copy_dstr(
struct dstr *dst,
const struct dstr *src)
190 dstr_copy_dstr(dst, src);
193 static inline void dstr_free(
struct dstr *dst)
201 static inline void dstr_array_free(
struct dstr *array,
const size_t count)
204 for (i = 0; i < count; i++)
208 static inline void dstr_move_array(
struct dstr *dst,
char *str)
212 dst->
len = (!str) ? 0 : strlen(str);
216 static inline void dstr_move(
struct dstr *dst,
struct dstr *src)
219 dstr_init_move(dst, src);
222 static inline void dstr_ensure_capacity(
struct dstr *dst,
const size_t new_size)
225 if (new_size <= dst->capacity)
229 if (new_size > new_cap)
235 static inline void dstr_copy_dstr(
struct dstr *dst,
const struct dstr *src)
241 dstr_ensure_capacity(dst, src->
len + 1);
247 static inline void dstr_reserve(
struct dstr *dst,
const size_t capacity)
249 if (capacity == 0 || capacity <= dst->len)
256 static inline void dstr_resize(
struct dstr *dst,
const size_t num)
263 dstr_ensure_capacity(dst, num + 1);
268 static inline bool dstr_is_empty(
const struct dstr *str)
278 static inline void dstr_cat(
struct dstr *dst,
const char *array)
281 if (!array || !*array)
288 static inline void dstr_cat_ch(
struct dstr *dst,
char ch)
290 dstr_ensure_capacity(dst, ++dst->
len + 1);
295 static inline const char *dstr_find_i(
const struct dstr *str,
const char *find)
300 static inline const char *dstr_find(
const struct dstr *str,
const char *find)
302 return strstr(str->
array, find);
305 static inline int dstr_cmp(
const struct dstr *str1,
const char *str2)
307 return strcmp(str1->
array, str2);
310 static inline int dstr_cmpi(
const struct dstr *str1,
const char *str2)
315 static inline int dstr_ncmp(
const struct dstr *str1,
const char *str2,
321 static inline int dstr_ncmpi(
const struct dstr *str1,
const char *str2,
327 static inline char dstr_end(
const struct dstr *str)
329 if (dstr_is_empty(str))
EXPORT void dstr_ncopy_dstr(struct dstr *dst, const struct dstr *src, const size_t len)
EXPORT int wstrcmpi(const wchar_t *str1, const wchar_t *str2)
EXPORT int astrcmpi(const char *str1, const char *str2)
EXPORT void dstr_depad(struct dstr *dst)
EXPORT void dstr_ncopy(struct dstr *dst, const char *array, const size_t len)
EXPORT void dstr_mid(struct dstr *dst, const struct dstr *str, const size_t start, const size_t count)
EXPORT void dstr_to_upper(struct dstr *str)
EXPORT int astrcmp_n(const char *str1, const char *str2, size_t n)
EXPORT void dstr_replace(struct dstr *str, const char *find, const char *replace)
EXPORT void * brealloc(void *ptr, size_t size)
EXPORT char * dstr_to_mbs(const struct dstr *str)
EXPORT wchar_t * dstr_to_wcs(const struct dstr *str)
EXPORT void dstr_copy_strref(struct dstr *dst, const struct strref *src)
EXPORT wchar_t * wcsdepad(wchar_t *str)
EXPORT char ** strlist_split(const char *str, char split_ch, bool include_empty)
EXPORT int wstrcmp_n(const wchar_t *str1, const wchar_t *str2, size_t n)
EXPORT void dstr_ncat(struct dstr *dst, const char *array, const size_t len)
EXPORT void dstr_vcatf(struct dstr *dst, const char *format, va_list args)
EXPORT void dstr_init_copy_strref(struct dstr *dst, const struct strref *src)
EXPORT void dstr_insert_ch(struct dstr *dst, const size_t idx, const char ch)
EXPORT void dstr_insert(struct dstr *dst, const size_t idx, const char *array)
EXPORT void dstr_cat_dstr(struct dstr *dst, const struct dstr *str)
#define EXPORT
Definition: c99defs.h:49
EXPORT wchar_t * wstrstri(const wchar_t *str, const wchar_t *find)
EXPORT void dstr_copy(struct dstr *dst, const char *array)
EXPORT void dstr_to_lower(struct dstr *str)
EXPORT void dstr_safe_printf(struct dstr *dst, const char *format, const char *val1, const char *val2, const char *val3, const char *val4)
char * array
Definition: dstr.h:37
EXPORT void dstr_insert_dstr(struct dstr *dst, const size_t idx, const struct dstr *str)
EXPORT void dstr_vprintf(struct dstr *dst, const char *format, va_list args)
EXPORT char * astrstri(const char *str, const char *find)
EXPORT void dstr_cat_strref(struct dstr *dst, const struct strref *str)
EXPORT void dstr_printf(struct dstr *dst, const char *format,...)
size_t capacity
Definition: dstr.h:39
EXPORT int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n)
EXPORT void dstr_remove(struct dstr *dst, const size_t idx, const size_t count)
EXPORT void dstr_catf(struct dstr *dst, const char *format,...)
EXPORT void dstr_from_wcs(struct dstr *dst, const wchar_t *wstr)
EXPORT void dstr_right(struct dstr *dst, const struct dstr *str, const size_t pos)
#define PRINTFATTR(f, a)
Definition: dstr.h:43
EXPORT void strlist_free(char **strlist)
EXPORT void dstr_from_mbs(struct dstr *dst, const char *mbstr)
EXPORT int astrcmpi_n(const char *str1, const char *str2, size_t n)
size_t len
Definition: dstr.h:38
EXPORT char * strdepad(char *str)
EXPORT void bfree(void *ptr)
EXPORT void dstr_ncat_dstr(struct dstr *dst, const struct dstr *str, const size_t len)
EXPORT void dstr_left(struct dstr *dst, const struct dstr *str, const size_t pos)