From ed60ffa6e1b98142cade09813eb377fc8f3d6ab3 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Fri, 3 Jun 2022 18:34:57 +0300 Subject: [PATCH] Update headers --- include/array.h | 4 ++++ include/extra/array.h | 3 --- include/extra/string.h | 38 ++++++++++++++++++++++++++++++++++++++ include/string.h | 27 +++++++++++++-------------- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/include/array.h b/include/array.h index cdf386e..83f993c 100644 --- a/include/array.h +++ b/include/array.h @@ -7,6 +7,8 @@ #ifndef LIBCDSB_ARRAY_H #define LIBCDSB_ARRAY_H +/*#####################################################################################################################*/ + extern void array_init(vtype_array* x, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__; extern _Bool array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__; @@ -25,6 +27,8 @@ extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__; extern void* array_at (const vtype_array* s, ssize_t index); extern ssize_t array_get(vtype_array* s, vtype_value* x, ssize_t index, _Bool cut); +/*#####################################################################################################################*/ + extern void libcdsb_array_push_pointer(vtype_array* x, const void* value) LIBCDSB_nt__ LIBCDSB_nn1__; extern void libcdsb_array_push_cstring(vtype_array* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__; extern void libcdsb_array_push_string (vtype_array* x, const vtype_string* value) LIBCDSB_nt__ LIBCDSB_nn12__; diff --git a/include/extra/array.h b/include/extra/array.h index e72a9b6..69b2bd6 100644 --- a/include/extra/array.h +++ b/include/extra/array.h @@ -6,9 +6,6 @@ #ifndef LIBCDSB_EXTRA_ARRAY_H #define LIBCDSB_EXTRA_ARRAY_H -#ifdef array_find -# undef array_find -#endif #ifdef array_push # undef array_push #endif diff --git a/include/extra/string.h b/include/extra/string.h index bae4168..d654984 100644 --- a/include/extra/string.h +++ b/include/extra/string.h @@ -6,9 +6,13 @@ #ifndef LIBCDSB_EXTRA_STRING_H #define LIBCDSB_EXTRA_STRING_H +/*#####################################################################################################################*/ + #define string_split(x, sep, maxn) _LIBCDSB_GenericS(libcdsb_string, split, sep)(x, sep, maxn) #define string_case_compare string_compare_case_insensitive +#define string_replace_r(x, src, dest, maxn) _LIBCDSB_GenericS2(libcdsb_string, replace_r, src, dest)(x, src, dest, maxn) + extern size_t string_to_lower (vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; extern size_t string_to_upper (vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; extern size_t string_capitalize(vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; @@ -16,12 +20,46 @@ extern size_t string_capitalize(vtype_string* x) LIBCDSB_nt__ LIBCDSB_nn1__; extern int string_compare_case_insensitive(const vtype_string* s0, const vtype_string* s1) LIBCDSB_cmpattr__; +/*#####################################################################################################################*/ + inline vtype_array libcdsb_string_split_string (const vtype_string* x, const vtype_string* sep, size_t maxn) __attribute__((always_inline)); extern vtype_array libcdsb_string_split_cstring(const vtype_string* string, const char* sep, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; extern vtype_array libcdsb_string_split_char (const vtype_string* string, int chr, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_r_string_string (vtype_string*restrict x, const vtype_string*restrict src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); +inline size_t libcdsb_string_replace_r_string_cstring (vtype_string*restrict x, const vtype_string*restrict src, const char*restrict dest, size_t maxn) __attribute__((always_inline)); +inline size_t libcdsb_string_replace_r_string_char (vtype_string*restrict x, const vtype_string*restrict src, int dest, size_t maxn) __attribute__((always_inline)); +inline size_t libcdsb_string_replace_r_cstring_string (vtype_string*restrict x, const char*restrict src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); +extern size_t libcdsb_string_replace_r_cstring_cstring(vtype_string*restrict x, const char*restrict src, const char*restrict dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t libcdsb_string_replace_r_cstring_char (vtype_string*restrict x, const char*restrict src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_r_char_string (vtype_string*restrict x, int src, const vtype_string*restrict dest, size_t maxn) __attribute__((always_inline)); +extern size_t libcdsb_string_replace_r_char_cstring (vtype_string*restrict x, int src, const char*restrict dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t libcdsb_string_replace_r_char_char (vtype_string*restrict x, int src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; + +/*#####################################################################################################################*/ + inline vtype_array libcdsb_string_split_string(const vtype_string* x, const vtype_string* sep, size_t maxn) { return string_split(x, sep->buffer, maxn); } +inline size_t libcdsb_string_replace_r_string_string (vtype_string*restrict x, const vtype_string*restrict src, const vtype_string*restrict dest, size_t maxn) { + return string_replace_r(x, src->buffer, dest->buffer, maxn); +} + +inline size_t libcdsb_string_replace_r_string_cstring(vtype_string*restrict x, const vtype_string*restrict src, const char*restrict dest, size_t maxn) { + return string_replace_r(x, src->buffer, dest, maxn); +} + +inline size_t libcdsb_string_replace_r_cstring_string(vtype_string*restrict x, const char*restrict src, const vtype_string*restrict dest, size_t maxn) { + return string_replace_r(x, src, dest->buffer, maxn); +} + +inline size_t libcdsb_string_replace_r_string_char (vtype_string*restrict x, const vtype_string*restrict src, int dest, size_t maxn) { + return string_replace_r(x, src->buffer, dest, maxn); +} + +inline size_t libcdsb_string_replace_r_char_string (vtype_string*restrict x, int src, const vtype_string*restrict dest, size_t maxn) { + return string_replace_r(x, src, dest->buffer, maxn); +} + #endif /* LIBCDSB_EXTRA_STRING_H */ diff --git a/include/string.h b/include/string.h index 3229279..4c868b3 100644 --- a/include/string.h +++ b/include/string.h @@ -8,6 +8,8 @@ #ifndef LIBCDSB_STRING_H #define LIBCDSB_STRING_H +/*#####################################################################################################################*/ + extern void string_init(vtype_string* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__; extern char* string_at(const vtype_string* s, ssize_t index) LIBCDSB_nt__ LIBCDSB_nn1__; @@ -25,11 +27,7 @@ extern _Bool string_slice(vtype_string* x, vtype_string* s, ssize_t index, size_ #define string_replace(x, src, dest, maxn) _LIBCDSB_GenericS2(libcdsb_string, replace, src, dest)(x, src, dest, maxn) - - - - - +/*#####################################################################################################################*/ inline ssize_t libcdsb_string_indexof_string (const vtype_string* s, const vtype_string* arg) __attribute__((always_inline)); extern ssize_t libcdsb_string_indexof_cstring(const vtype_string* s, const char* arg) LIBCDSB_pure__ LIBCDSB_nn1__; @@ -55,17 +53,17 @@ inline void libcdsb_string_rtrim_string (vtype_string* x, const vtype_string* ar extern void libcdsb_string_rtrim_cstring(vtype_string* x, const char* arg) LIBCDSB_nt__ LIBCDSB_nn1__; extern void libcdsb_string_rtrim_char (vtype_string* x, int arg) LIBCDSB_nt__ LIBCDSB_nn1__; - inline size_t libcdsb_string_replace_string_string (vtype_string* x, const vtype_string* src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_string_cstring (vtype_string* x, const vtype_string* src, const char* dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_string_char (vtype_string* x, const vtype_string* src, int dest, size_t maxn) __attribute__((always_inline)); -inline size_t libcdsb_string_replace_cstring_string (vtype_string* x, const char* src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_cstring_cstring(vtype_string* string, const char* src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t libcdsb_string_replace_cstring_char (vtype_string* string, const char* src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -inline size_t libcdsb_string_replace_char_string (vtype_string* x, int src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); -extern size_t libcdsb_string_replace_char_cstring (vtype_string* string, int src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; -extern size_t libcdsb_string_replace_char_char (vtype_string* string, int src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_string_cstring (vtype_string* x, const vtype_string* src, const char* dest, size_t maxn) __attribute__((always_inline)); +inline size_t libcdsb_string_replace_string_char (vtype_string* x, const vtype_string* src, int dest, size_t maxn) __attribute__((always_inline)); +inline size_t libcdsb_string_replace_cstring_string (vtype_string* x, const char* src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); +extern size_t libcdsb_string_replace_cstring_cstring(vtype_string* x, const char* src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t libcdsb_string_replace_cstring_char (vtype_string* x, const char* src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +inline size_t libcdsb_string_replace_char_string (vtype_string* x, int src, const vtype_string* dest, size_t maxn) __attribute__((always_inline)); +extern size_t libcdsb_string_replace_char_cstring (vtype_string* x, int src, const char* dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +extern size_t libcdsb_string_replace_char_char (vtype_string* x, int src, int dest, size_t maxn) LIBCDSB_nt__ LIBCDSB_nn1__; +/*#####################################################################################################################*/ inline ssize_t libcdsb_string_indexof_string(const vtype_string* s, const vtype_string* arg) { return string_indexof(s, arg->buffer); @@ -111,4 +109,5 @@ inline size_t libcdsb_string_replace_char_string (vtype_string* x, int src, co return string_replace(x, src, dest->buffer, maxn); } + #endif /* LIBCDSB_BASE_STRING_H */