From 329a1edd5d0fe5e1f1c2eaf4282fd895eca7669e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 10 Nov 2022 22:57:04 -0600 Subject: [PATCH] Cleanup: Improve organization in f_utf, using addtional files. Create more files to better organize structures and their accompanying functions. Structures like f_utf_string_dynamic_t, f_utf_string_dynamics_t, and f_utf_string_dynamicss_t now each have their own files. --- build/level_0/settings | 5 +- build/monolithic/settings | 5 +- level_0/f_utf/c/utf.h | 10 + level_0/f_utf/c/utf/dynamic.c | 275 ------------- level_0/f_utf/c/utf/dynamic.h | 414 -------------------- level_0/f_utf/c/utf/dynamics.c | 134 +++++++ level_0/f_utf/c/utf/dynamics.h | 230 +++++++++++ level_0/f_utf/c/utf/dynamicss.c | 170 +++++++++ level_0/f_utf/c/utf/dynamicss.h | 230 +++++++++++ level_0/f_utf/c/utf/map.c | 294 -------------- level_0/f_utf/c/utf/map.h | 421 -------------------- level_0/f_utf/c/utf/map_multi.c | 295 -------------- level_0/f_utf/c/utf/map_multi.h | 420 -------------------- level_0/f_utf/c/utf/map_multis.c | 154 ++++++++ level_0/f_utf/c/utf/map_multis.h | 233 +++++++++++ level_0/f_utf/c/utf/map_multiss.c | 169 ++++++++ level_0/f_utf/c/utf/map_multiss.h | 233 +++++++++++ level_0/f_utf/c/utf/maps.c | 152 ++++++++ level_0/f_utf/c/utf/maps.h | 233 +++++++++++ level_0/f_utf/c/utf/mapss.c | 166 ++++++++ level_0/f_utf/c/utf/mapss.h | 234 ++++++++++++ level_0/f_utf/c/utf/private-dynamic.c | 160 -------- level_0/f_utf/c/utf/private-dynamic.h | 164 -------- level_0/f_utf/c/utf/private-dynamics.c | 117 ++++++ level_0/f_utf/c/utf/private-dynamics.h | 130 +++++++ level_0/f_utf/c/utf/private-dynamicss.c | 70 ++++ level_0/f_utf/c/utf/private-dynamicss.h | 78 ++++ .../{private-map_multi.c => private-map_multis.c} | 59 +-- .../{private-map_multi.h => private-map_multis.h} | 58 +-- level_0/f_utf/c/utf/private-map_multiss.c | 70 ++++ level_0/f_utf/c/utf/private-map_multiss.h | 74 ++++ .../f_utf/c/utf/{private-map.c => private-maps.c} | 58 +-- .../f_utf/c/utf/{private-map.h => private-maps.h} | 58 +-- level_0/f_utf/c/utf/private-mapss.c | 70 ++++ level_0/f_utf/c/utf/private-mapss.h | 74 ++++ .../c/utf/{private-triple.c => private-triples.c} | 58 +-- .../c/utf/{private-triple.h => private-triples.h} | 58 +-- level_0/f_utf/c/utf/private-tripless.c | 70 ++++ level_0/f_utf/c/utf/private-tripless.h | 74 ++++ level_0/f_utf/c/utf/static.h | 52 --- level_0/f_utf/c/utf/statics.c | 9 + level_0/f_utf/c/utf/statics.h | 49 +++ level_0/f_utf/c/utf/staticss.c | 9 + level_0/f_utf/c/utf/staticss.h | 49 +++ level_0/f_utf/c/utf/strings.c | 370 ++++++++++++++++++ level_0/f_utf/c/utf/strings.h | 425 +++++++++++++++++++++ level_0/f_utf/c/utf/stringss.c | 370 ++++++++++++++++++ level_0/f_utf/c/utf/stringss.h | 425 +++++++++++++++++++++ level_0/f_utf/c/utf/triple.c | 327 ---------------- level_0/f_utf/c/utf/triple.h | 422 -------------------- level_0/f_utf/c/utf/triples.c | 185 +++++++++ level_0/f_utf/c/utf/triples.h | 234 ++++++++++++ level_0/f_utf/c/utf/tripless.c | 166 ++++++++ level_0/f_utf/c/utf/tripless.h | 234 ++++++++++++ level_0/f_utf/data/build/settings | 7 +- 55 files changed, 5722 insertions(+), 3588 deletions(-) create mode 100644 level_0/f_utf/c/utf/dynamics.c create mode 100644 level_0/f_utf/c/utf/dynamics.h create mode 100644 level_0/f_utf/c/utf/dynamicss.c create mode 100644 level_0/f_utf/c/utf/dynamicss.h create mode 100644 level_0/f_utf/c/utf/map_multis.c create mode 100644 level_0/f_utf/c/utf/map_multis.h create mode 100644 level_0/f_utf/c/utf/map_multiss.c create mode 100644 level_0/f_utf/c/utf/map_multiss.h create mode 100644 level_0/f_utf/c/utf/maps.c create mode 100644 level_0/f_utf/c/utf/maps.h create mode 100644 level_0/f_utf/c/utf/mapss.c create mode 100644 level_0/f_utf/c/utf/mapss.h create mode 100644 level_0/f_utf/c/utf/private-dynamics.c create mode 100644 level_0/f_utf/c/utf/private-dynamics.h create mode 100644 level_0/f_utf/c/utf/private-dynamicss.c create mode 100644 level_0/f_utf/c/utf/private-dynamicss.h rename level_0/f_utf/c/utf/{private-map_multi.c => private-map_multis.c} (63%) rename level_0/f_utf/c/utf/{private-map_multi.h => private-map_multis.h} (60%) create mode 100644 level_0/f_utf/c/utf/private-map_multiss.c create mode 100644 level_0/f_utf/c/utf/private-map_multiss.h rename level_0/f_utf/c/utf/{private-map.c => private-maps.c} (64%) rename level_0/f_utf/c/utf/{private-map.h => private-maps.h} (60%) create mode 100644 level_0/f_utf/c/utf/private-mapss.c create mode 100644 level_0/f_utf/c/utf/private-mapss.h rename level_0/f_utf/c/utf/{private-triple.c => private-triples.c} (66%) rename level_0/f_utf/c/utf/{private-triple.h => private-triples.h} (60%) create mode 100644 level_0/f_utf/c/utf/private-tripless.c create mode 100644 level_0/f_utf/c/utf/private-tripless.h create mode 100644 level_0/f_utf/c/utf/statics.c create mode 100644 level_0/f_utf/c/utf/statics.h create mode 100644 level_0/f_utf/c/utf/staticss.c create mode 100644 level_0/f_utf/c/utf/staticss.h create mode 100644 level_0/f_utf/c/utf/strings.c create mode 100644 level_0/f_utf/c/utf/strings.h create mode 100644 level_0/f_utf/c/utf/stringss.c create mode 100644 level_0/f_utf/c/utf/stringss.h create mode 100644 level_0/f_utf/c/utf/triples.c create mode 100644 level_0/f_utf/c/utf/triples.h create mode 100644 level_0/f_utf/c/utf/tripless.c create mode 100644 level_0/f_utf/c/utf/tripless.h diff --git a/build/level_0/settings b/build/level_0/settings index d83c156..dc5c86e 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -45,7 +45,8 @@ build_sources_library string/dynamic.c string/dynamics.c string/dynamicss.c stri build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c type_array/private-uint8.c type_array/private-uint16.c type_array/private-uint32.c type_array/private-uint64.c type_array/private-uint128.c build_sources_library utf.c private-utf.c private-utf_alphabetic.c private-utf_combining.c private-utf_control.c private-utf_digit.c private-utf_emoji.c private-utf_numeric.c private-utf_phonetic.c private-utf_private.c private-utf_punctuation.c private-utf_subscript.c private-utf_superscript.c private-utf_symbol.c private-utf_unassigned.c private-utf_valid.c private-utf_whitespace.c private-utf_wide.c private-utf_word.c private-utf_zero_width.c -build_sources_library utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/private-dynamic.c utf/private-map.c utf/private-map_multi.c utf/private-triple.c utf/private-string.c utf/static.c utf/string.c utf/triple.c +build_sources_library utf/common.c utf/convert.c utf/dynamic.c utf/dynamics.c utf/dynamicss.c utf/is.c utf/is_character.c utf/map.c utf/maps.c utf/mapss.c utf/map_multi.c utf/map_multis.c utf/map_multiss.c utf/static.c utf/statics.c utf/staticss.c utf/string.c utf/triple.c utf/triples.c utf/tripless.c +build_sources_library utf/private-dynamic.c utf/private-dynamics.c utf/private-dynamicss.c utf/private-maps.c utf/private-mapss.c utf/private-map_multis.c utf/private-map_multiss.c utf/private-string.c utf/private-triples.c utf/private-tripless.c build_sources_library-level thread.c private-thread.c thread/attribute.c thread/barrier.c thread/barrier_attribute.c thread/condition.c thread/condition_attribute.c thread/id.c thread/key.c thread/lock.c thread/lock_attribute.c thread/mutex.c thread/mutex_attribute.c thread/once.c thread/semaphore.c thread/set.c thread/spin.c @@ -75,7 +76,7 @@ build_sources_headers string.h string/common.h string/dynamic.h string/dynamics. build_sources_headers type.h type_file.h build_sources_headers type_array.h type_array/common.h build_sources_headers type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h -build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/map_multi.h utf/static.h utf/string.h utf/triple.h +build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/dynamics.h utf/dynamicss.h utf/is.h utf/is_character.h utf/map.h utf/maps.h utf/mapss.h utf/map_multi.h utf/map_multis.h utf/map_multiss.h utf/static.h utf/statics.h utf/staticss.h utf/string.h utf/triple.h utf/triples.h utf/tripless.h build_sources_headers-level thread.h thread/attribute.h thread/barrier.h thread/barrier_attribute.h thread/condition.h thread/condition_attribute.h thread/id.h thread/key.h thread/lock.h thread/lock_attribute.h thread/mutex.h thread/mutex_attribute.h thread/once.h thread/semaphore.h thread/set.h thread/spin.h diff --git a/build/monolithic/settings b/build/monolithic/settings index e8bfd15..42d231b 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -45,7 +45,8 @@ build_sources_library level_0/string/dynamic.c level_0/string/dynamics.c level_0 build_sources_library level_0/type_array/array_length.c level_0/type_array/cell.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/state.c level_0/type_array/status.c level_0/type_array/uint8.c level_0/type_array/uint16.c level_0/type_array/uint32.c level_0/type_array/uint64.c level_0/type_array/uint128.c build_sources_library level_0/type_array/private-array_length.c level_0/type_array/private-cell.c level_0/type_array/private-fll_id.c level_0/type_array/private-int8.c level_0/type_array/private-int16.c level_0/type_array/private-int32.c level_0/type_array/private-int64.c level_0/type_array/private-int128.c level_0/type_array/private-state.c level_0/type_array/private-status.c level_0/type_array/private-uint8.c level_0/type_array/private-uint16.c level_0/type_array/private-uint32.c level_0/type_array/private-uint64.c level_0/type_array/private-uint128.c build_sources_library level_0/utf.c level_0/private-utf.c level_0/private-utf_alphabetic.c level_0/private-utf_combining.c level_0/private-utf_control.c level_0/private-utf_digit.c level_0/private-utf_emoji.c level_0/private-utf_numeric.c level_0/private-utf_phonetic.c level_0/private-utf_private.c level_0/private-utf_punctuation.c level_0/private-utf_subscript.c level_0/private-utf_superscript.c level_0/private-utf_symbol.c level_0/private-utf_unassigned.c level_0/private-utf_valid.c level_0/private-utf_whitespace.c level_0/private-utf_wide.c level_0/private-utf_word.c level_0/private-utf_zero_width.c -build_sources_library level_0/utf/common.c level_0/utf/convert.c level_0/utf/dynamic.c level_0/utf/is.c level_0/utf/is_character.c level_0/utf/map.c level_0/utf/map_multi.c level_0/utf/static.c level_0/utf/string.c level_0/utf/triple.c level_0/utf/private-dynamic.c level_0/utf/private-map.c level_0/utf/private-map_multi.c level_0/utf/private-triple.c level_0/utf/private-string.c +build_sources_library level_0/utf/common.c level_0/utf/convert.c level_0/utf/dynamic.c level_0/utf/dynamics.c level_0/utf/dynamicss.c level_0/utf/is.c level_0/utf/is_character.c level_0/utf/map.c level_0/utf/maps.c level_0/utf/mapss.c level_0/utf/map_multi.c level_0/utf/map_multis.c level_0/utf/map_multiss.c level_0/utf/static.c level_0/utf/statics.c level_0/utf/staticss.c level_0/utf/string.c level_0/utf/triple.c level_0/utf/triples.c level_0/utf/tripless.c +build_sources_library level_0/utf/private-dynamic.c level_0/utf/private-dynamics.c level_0/utf/private-dynamicss.c level_0/utf/private-maps.c level_0/utf/private-mapss.c level_0/utf/private-map_multis.c level_0/utf/private-map_multiss.c level_0/utf/private-string.c level_0/utf/private-triples.c level_0/utf/private-tripless.c build_sources_library level_1/control_group.c build_sources_library level_1/conversion.c level_1/private-conversion.c level_1/conversion/common.c @@ -99,7 +100,7 @@ build_sources_headers level_0/string.h level_0/string/common.h level_0/string/dy build_sources_headers level_0/type.h level_0/type_file.h build_sources_headers level_0/type_array.h level_0/type_array/common.h build_sources_headers level_0/type_array/array_length.h level_0/type_array/cell.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/state.h level_0/type_array/status.h level_0/type_array/uint8.h level_0/type_array/uint16.h level_0/type_array/uint32.h level_0/type_array/uint64.h level_0/type_array/uint128.h -build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/convert.h level_0/utf/dynamic.h level_0/utf/is.h level_0/utf/is_character.h level_0/utf/map.h level_0/utf/map_multi.h level_0/utf/static.h level_0/utf/string.h level_0/utf/triple.h +build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/convert.h level_0/utf/dynamic.h level_0/utf/dynamics.h level_0/utf/dynamicss.h level_0/utf/is.h level_0/utf/is_character.h level_0/utf/map.h level_0/utf/maps.h level_0/utf/mapss.h level_0/utf/map_multi.h level_0/utf/map_multis.h level_0/utf/map_multiss.h level_0/utf/static.h level_0/utf/statics.h level_0/utf/staticss.h level_0/utf/string.h level_0/utf/triple.h level_0/utf/triples.h level_0/utf/tripless.h build_sources_headers level_1/control_group.h build_sources_headers level_1/conversion.h level_1/conversion/common.h diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index 840e546..9b320f5 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -48,14 +48,24 @@ // FLL-0 utf includes. #include #include +#include +#include #include +#include +#include #include #include #include #include +#include +#include #include +#include +#include #include #include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/level_0/f_utf/c/utf/dynamic.c b/level_0/f_utf/c/utf/dynamic.c index c8b485c..c5cdf2d 100644 --- a/level_0/f_utf/c/utf/dynamic.c +++ b/level_0/f_utf/c/utf/dynamic.c @@ -799,281 +799,6 @@ extern "C" { } #endif // _di_f_utf_string_dynamic_terminate_after_ -#ifndef _di_f_utf_string_dynamics_adjust_ - f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_dynamics_adjust(length, dynamics); - } -#endif // _di_f_utf_string_dynamics_adjust_ - -#ifndef _di_f_utf_string_dynamics_append_ - f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_utf_string_dynamics_append(source, destination); - } -#endif // _di_f_utf_string_dynamics_append_ - -#ifndef _di_f_utf_string_dynamics_append_all_ - f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_utf_string_dynamics_append_all(source, destination); - } -#endif // _di_f_utf_string_dynamics_append_all_ - -#ifndef _di_f_utf_string_dynamics_decimate_by_ - f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (dynamics->size > amount) { - return private_f_utf_string_dynamics_adjust(dynamics->size - amount, dynamics); - } - - return private_f_utf_string_dynamics_adjust(0, dynamics); - } -#endif // _di_f_utf_string_dynamics_decimate_by_ - -#ifndef _di_f_utf_string_dynamics_decrease_by_ - f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (dynamics->size > amount) { - return private_f_utf_string_dynamics_resize(dynamics->size - amount, dynamics); - } - - return private_f_utf_string_dynamics_resize(0, dynamics); - } -#endif // _di_f_utf_string_dynamics_decrease_by_ - -#ifndef _di_f_utf_string_dynamics_increase_ - f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!step) return F_data_not; - - if (dynamics->used + 1 > dynamics->size) { - f_array_length_t size = dynamics->used + step; - - if (size > F_array_length_t_size_d) { - if (dynamics->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_dynamics_resize(size, dynamics); - } - - return F_data_not; - } -#endif // _di_f_utf_string_dynamics_increase_ - -#ifndef _di_f_utf_string_dynamics_increase_by_ - f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (dynamics->used + amount > dynamics->size) { - if (dynamics->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_dynamics_resize(dynamics->used + amount, dynamics); - } - - return F_data_not; - } -#endif // _di_f_utf_string_dynamics_increase_by_ - -#ifndef _di_f_utf_string_dynamics_resize_ - f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamics) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_dynamics_resize(length, dynamics); - } -#endif // _di_f_utf_string_dynamics_resize_ - -#ifndef _di_f_utf_string_dynamicss_adjust_ - f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_dynamicss_adjust(length, dynamicss); - } -#endif // _di_f_utf_string_dynamicss_adjust_ - -#ifndef _di_f_utf_string_dynamicss_append_ - f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_dynamicss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_utf_string_dynamics_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_dynamicss_append_ - -#ifndef _di_f_utf_string_dynamicss_append_all_ - f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_dynamicss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_dynamics_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_utf_string_dynamicss_append_all_ - -#ifndef _di_f_utf_string_dynamicss_decimate_by_ - f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (dynamicss->size > amount) { - return private_f_utf_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); - } - - return private_f_utf_string_dynamicss_adjust(0, dynamicss); - } -#endif // _di_f_utf_string_dynamicss_decimate_by_ - -#ifndef _di_f_utf_string_dynamicss_decrease_by_ - f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (dynamicss->size > amount) { - return private_f_utf_string_dynamicss_resize(dynamicss->size - amount, dynamicss); - } - - return private_f_utf_string_dynamicss_resize(0, dynamicss); - } -#endif // _di_f_utf_string_dynamicss_decrease_by_ - -#ifndef _di_f_utf_string_dynamicss_increase_ - f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!step) return F_data_not; - - if (dynamicss->used + 1 > dynamicss->size) { - f_array_length_t size = dynamicss->used + step; - - if (size > F_array_length_t_size_d) { - if (dynamicss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_dynamicss_resize(size, dynamicss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_dynamicss_increase_ - -#ifndef _di_f_utf_string_dynamicss_increase_by_ - f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (dynamicss->used + amount > dynamicss->size) { - if (dynamicss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_dynamicss_resize(dynamicss->used + amount, dynamicss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_dynamicss_increase_by_ - -#ifndef _di_f_utf_string_dynamicss_resize_ - f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { - #ifndef _di_level_0_parameter_checking_ - if (!dynamicss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_dynamicss_resize(length, dynamicss); - } -#endif // _di_f_utf_string_dynamicss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/dynamic.h b/level_0/f_utf/c/utf/dynamic.h index 8a64711..0423879 100644 --- a/level_0/f_utf/c/utf/dynamic.h +++ b/level_0/f_utf/c/utf/dynamic.h @@ -51,64 +51,6 @@ extern "C" { #endif // _di_f_utf_string_dynamic_t_ /** - * An array of dynamic dynamics. - * - * array: The array of dynamic dynamics. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_dynamics_t_ - typedef f_utf_string_statics_t f_utf_string_dynamics_t; - - #define f_utf_string_dynamics_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_dynamics_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_dynamics_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_dynamics_t_clear(dynamics) macro_f_utf_string_statics_t_clear(dynamics) - - #define macro_f_utf_string_dynamics_t_resize(status, dynamics, length) status = f_utf_string_dynamics_resize(length, &dynamics); - #define macro_f_utf_string_dynamics_t_adjust(status, dynamics, length) status = f_utf_string_dynamics_adjust(length, &dynamics); - - #define macro_f_utf_string_dynamics_t_delete_simple(dynamics) f_utf_string_dynamics_resize(0, &dynamics); - #define macro_f_utf_string_dynamics_t_destroy_simple(dynamics) f_utf_string_dynamics_adjust(0, &dynamics); - - #define macro_f_utf_string_dynamics_t_increase(status, step, dynamics) status = f_utf_string_dynamics_increase(step, &dynamics); - #define macro_f_utf_string_dynamics_t_increase_by(status, dynamics, amount) status = f_utf_string_dynamics_increase_by(amount, &dynamics); - #define macro_f_utf_string_dynamics_t_decrease_by(status, dynamics, amount) status = f_utf_string_dynamics_decrease_by(amount, &dynamics); - #define macro_f_utf_string_dynamics_t_decimate_by(status, dynamics, amount) status = f_utf_string_dynamics_decimate_by(amount, &dynamics); -#endif // _di_f_utf_string_dynamics_t_ - -/** - * An array of dynamic dynamicss. - * - * array: The array of dynamic dynamicss. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_dynamicss_t_ - typedef f_utf_string_staticss_t f_utf_string_dynamicss_t; - - #define f_utf_string_dynamicss_t_initialize f_utf_string_staticss_t_initialize - - #define macro_f_utf_string_dynamicss_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_dynamicss_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_dynamicss_t_clear(dynamicss) macro_f_utf_string_staticss_t_clear(dynamicss) - - #define macro_f_utf_string_dynamicss_t_resize(status, dynamicss, length) status = f_utf_string_dynamicss_resize(length, &dynamicss); - #define macro_f_utf_string_dynamicss_t_adjust(status, dynamicss, length) status = f_utf_string_dynamicss_adjust(length, &dynamicss); - - #define macro_f_utf_string_dynamicss_t_delete_simple(dynamicss) f_utf_string_dynamicss_resize(0, &dynamicss); - #define macro_f_utf_string_dynamicss_t_destroy_simple(dynamicss) f_utf_string_dynamicss_adjust(0, &dynamicss); - - #define macro_f_utf_string_dynamicss_t_increase(status, step, dynamicss) status = f_utf_string_dynamicss_increase(step, &dynamicss); - #define macro_f_utf_string_dynamicss_t_increase_by(status, dynamicss, amount) status = f_utf_string_dynamicss_increase_by(amount, &dynamicss); - #define macro_f_utf_string_dynamicss_t_decrease_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decrease_by(amount, &dynamicss); - #define macro_f_utf_string_dynamicss_t_decimate_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decimate_by(amount, &dynamicss); -#endif // _di_f_utf_string_dynamicss_t_ - -/** * Resize the dynamic string. * * @param length @@ -997,362 +939,6 @@ extern "C" { extern f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_terminate_after_ -/** - * Resize the dynamic string array. - * - * @param length - * The new size to use. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_adjust(). - */ -#ifndef _di_f_utf_string_dynamics_adjust_ - extern f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_adjust_ - -/** - * Append the single source string onto the destination. - * - * @param source - * The source string to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_append_ - extern f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination); -#endif // _di_f_utf_string_dynamics_append_ - -/** - * Append the source strings onto the destination. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_append_all_ - extern f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination); -#endif // _di_f_utf_string_dynamics_append_all_ - -/** - * Resize the dynamic string array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_decimate_by_ - extern f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_decimate_by_ - -/** - * Resize the dynamic string array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_decrease_by_ - extern f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_decrease_by_ - -/** - * Increase the size of the dynamic string array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_increase_ - extern f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_increase_ - -/** - * Resize the dynamic string array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_increase_by_ - extern f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_increase_by_ - -/** - * Resize the dynamic string array. - * - * @param length - * The new size to use. - * @param dynamics - * The array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamics_resize_ - extern f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); -#endif // _di_f_utf_string_dynamics_resize_ - -/** - * Resize the dynamics string array. - * - * @param length - * The new size to use. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_adjust(). - */ -#ifndef _di_f_utf_string_dynamicss_adjust_ - extern f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_adjust_ - -/** - * Append the single source string onto the destination. - * - * @param source - * The source string to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_append_ - extern f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination); -#endif // _di_f_utf_string_dynamicss_append_ - -/** - * Append the source strings onto the destination. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_append_all_ - extern f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination); -#endif // _di_f_utf_string_dynamicss_append_all_ - -/** - * Resize the dynamics string array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_decimate_by_ - extern f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_decimate_by_ - -/** - * Resize the dynamics string array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_decrease_by_ - extern f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_decrease_by_ - -/** - * Increase the size of the dynamics string array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_increase_ - extern f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_increase_ - -/** - * Resize the dynamics string array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_increase_by_ - extern f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_increase_by_ - -/** - * Resize the dynamics string array. - * - * @param length - * The new size to use. - * @param dynamicss - * The array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_dynamicss_resize_ - extern f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); -#endif // _di_f_utf_string_dynamicss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/dynamics.c b/level_0/f_utf/c/utf/dynamics.c new file mode 100644 index 0000000..f776ec8 --- /dev/null +++ b/level_0/f_utf/c/utf/dynamics.c @@ -0,0 +1,134 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "static.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_dynamics_adjust_ + f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamics_adjust(length, dynamics); + } +#endif // _di_f_utf_string_dynamics_adjust_ + +#ifndef _di_f_utf_string_dynamics_append_ + f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_dynamics_append(source, destination); + } +#endif // _di_f_utf_string_dynamics_append_ + +#ifndef _di_f_utf_string_dynamics_append_all_ + f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_dynamics_append_all(source, destination); + } +#endif // _di_f_utf_string_dynamics_append_all_ + +#ifndef _di_f_utf_string_dynamics_decimate_by_ + f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamics->size > amount) { + return private_f_utf_string_dynamics_adjust(dynamics->size - amount, dynamics); + } + + return private_f_utf_string_dynamics_adjust(0, dynamics); + } +#endif // _di_f_utf_string_dynamics_decimate_by_ + +#ifndef _di_f_utf_string_dynamics_decrease_by_ + f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamics->size > amount) { + return private_f_utf_string_dynamics_resize(dynamics->size - amount, dynamics); + } + + return private_f_utf_string_dynamics_resize(0, dynamics); + } +#endif // _di_f_utf_string_dynamics_decrease_by_ + +#ifndef _di_f_utf_string_dynamics_increase_ + f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!step) return F_data_not; + + if (dynamics->used + 1 > dynamics->size) { + f_array_length_t size = dynamics->used + step; + + if (size > F_array_length_t_size_d) { + if (dynamics->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_dynamics_resize(size, dynamics); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamics_increase_ + +#ifndef _di_f_utf_string_dynamics_increase_by_ + f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamics->used + amount > dynamics->size) { + if (dynamics->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_dynamics_resize(dynamics->used + amount, dynamics); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamics_increase_by_ + +#ifndef _di_f_utf_string_dynamics_resize_ + f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamics_resize(length, dynamics); + } +#endif // _di_f_utf_string_dynamics_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/dynamics.h b/level_0/f_utf/c/utf/dynamics.h new file mode 100644 index 0000000..09de576 --- /dev/null +++ b/level_0/f_utf/c/utf/dynamics.h @@ -0,0 +1,230 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines dynamic (and static) UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_dynamics_h +#define _F_utf_dynamics_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of dynamic strings. + * + * array: The array of dynamic dynamics. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_dynamics_t_ + typedef f_utf_string_statics_t f_utf_string_dynamics_t; + + #define f_utf_string_dynamics_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_dynamics_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_dynamics_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_dynamics_t_clear(dynamics) macro_f_utf_string_statics_t_clear(dynamics) + + #define macro_f_utf_string_dynamics_t_resize(status, dynamics, length) status = f_utf_string_dynamics_resize(length, &dynamics); + #define macro_f_utf_string_dynamics_t_adjust(status, dynamics, length) status = f_utf_string_dynamics_adjust(length, &dynamics); + + #define macro_f_utf_string_dynamics_t_delete_simple(dynamics) f_utf_string_dynamics_resize(0, &dynamics); + #define macro_f_utf_string_dynamics_t_destroy_simple(dynamics) f_utf_string_dynamics_adjust(0, &dynamics); + + #define macro_f_utf_string_dynamics_t_increase(status, step, dynamics) status = f_utf_string_dynamics_increase(step, &dynamics); + #define macro_f_utf_string_dynamics_t_increase_by(status, dynamics, amount) status = f_utf_string_dynamics_increase_by(amount, &dynamics); + #define macro_f_utf_string_dynamics_t_decrease_by(status, dynamics, amount) status = f_utf_string_dynamics_decrease_by(amount, &dynamics); + #define macro_f_utf_string_dynamics_t_decimate_by(status, dynamics, amount) status = f_utf_string_dynamics_decimate_by(amount, &dynamics); +#endif // _di_f_utf_string_dynamics_t_ + +/** + * Resize the dynamic string array. + * + * @param length + * The new size to use. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_adjust(). + */ +#ifndef _di_f_utf_string_dynamics_adjust_ + extern f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_adjust_ + +/** + * Append the single source string onto the destination. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_append_ + extern f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination); +#endif // _di_f_utf_string_dynamics_append_ + +/** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_append_all_ + extern f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination); +#endif // _di_f_utf_string_dynamics_append_all_ + +/** + * Resize the dynamic string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_decimate_by_ + extern f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_decimate_by_ + +/** + * Resize the dynamic string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_decrease_by_ + extern f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_decrease_by_ + +/** + * Increase the size of the dynamic string array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_increase_ + extern f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_increase_ + +/** + * Resize the dynamic string array to a larger size. + * + * This will resize making the array larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_increase_by_ + extern f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_increase_by_ + +/** + * Resize the dynamic string array. + * + * @param length + * The new size to use. + * @param dynamics + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_resize_ + extern f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); +#endif // _di_f_utf_string_dynamics_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_dynamics_h diff --git a/level_0/f_utf/c/utf/dynamicss.c b/level_0/f_utf/c/utf/dynamicss.c new file mode 100644 index 0000000..79a62c2 --- /dev/null +++ b/level_0/f_utf/c/utf/dynamicss.c @@ -0,0 +1,170 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "static.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-dynamicss.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_dynamicss_adjust_ + f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamicss_adjust(length, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_adjust_ + +#ifndef _di_f_utf_string_dynamicss_append_ + f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_dynamicss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_dynamics_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_dynamicss_append_ + +#ifndef _di_f_utf_string_dynamicss_append_all_ + f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_dynamicss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_dynamics_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_dynamicss_append_all_ + +#ifndef _di_f_utf_string_dynamicss_decimate_by_ + f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->size > amount) { + return private_f_utf_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); + } + + return private_f_utf_string_dynamicss_adjust(0, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_decimate_by_ + +#ifndef _di_f_utf_string_dynamicss_decrease_by_ + f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->size > amount) { + return private_f_utf_string_dynamicss_resize(dynamicss->size - amount, dynamicss); + } + + return private_f_utf_string_dynamicss_resize(0, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_decrease_by_ + +#ifndef _di_f_utf_string_dynamicss_increase_ + f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!step) return F_data_not; + + if (dynamicss->used + 1 > dynamicss->size) { + f_array_length_t size = dynamicss->used + step; + + if (size > F_array_length_t_size_d) { + if (dynamicss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_dynamicss_resize(size, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamicss_increase_ + +#ifndef _di_f_utf_string_dynamicss_increase_by_ + f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->used + amount > dynamicss->size) { + if (dynamicss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamicss_increase_by_ + +#ifndef _di_f_utf_string_dynamicss_resize_ + f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamicss_resize(length, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/dynamicss.h b/level_0/f_utf/c/utf/dynamicss.h new file mode 100644 index 0000000..bebbec4 --- /dev/null +++ b/level_0/f_utf/c/utf/dynamicss.h @@ -0,0 +1,230 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines dynamic (and static) UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_dynamicss_h +#define _F_utf_dynamicss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of dynamic string arrays. + * + * array: The array of dynamic dynamicss. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_dynamicss_t_ + typedef f_utf_string_staticss_t f_utf_string_dynamicss_t; + + #define f_utf_string_dynamicss_t_initialize f_utf_string_staticss_t_initialize + + #define macro_f_utf_string_dynamicss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_dynamicss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_dynamicss_t_clear(dynamicss) macro_f_utf_string_staticss_t_clear(dynamicss) + + #define macro_f_utf_string_dynamicss_t_resize(status, dynamicss, length) status = f_utf_string_dynamicss_resize(length, &dynamicss); + #define macro_f_utf_string_dynamicss_t_adjust(status, dynamicss, length) status = f_utf_string_dynamicss_adjust(length, &dynamicss); + + #define macro_f_utf_string_dynamicss_t_delete_simple(dynamicss) f_utf_string_dynamicss_resize(0, &dynamicss); + #define macro_f_utf_string_dynamicss_t_destroy_simple(dynamicss) f_utf_string_dynamicss_adjust(0, &dynamicss); + + #define macro_f_utf_string_dynamicss_t_increase(status, step, dynamicss) status = f_utf_string_dynamicss_increase(step, &dynamicss); + #define macro_f_utf_string_dynamicss_t_increase_by(status, dynamicss, amount) status = f_utf_string_dynamicss_increase_by(amount, &dynamicss); + #define macro_f_utf_string_dynamicss_t_decrease_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decrease_by(amount, &dynamicss); + #define macro_f_utf_string_dynamicss_t_decimate_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decimate_by(amount, &dynamicss); +#endif // _di_f_utf_string_dynamicss_t_ + +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_adjust(). + */ +#ifndef _di_f_utf_string_dynamicss_adjust_ + extern f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_adjust_ + +/** + * Append the single source string onto the destination. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_append_ + extern f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination); +#endif // _di_f_utf_string_dynamicss_append_ + +/** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_append_all_ + extern f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination); +#endif // _di_f_utf_string_dynamicss_append_all_ + +/** + * Resize the dynamics string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_decimate_by_ + extern f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_decimate_by_ + +/** + * Resize the dynamics string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_decrease_by_ + extern f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_decrease_by_ + +/** + * Increase the size of the dynamics string array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_increase_ + extern f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_increase_ + +/** + * Resize the dynamics string array to a larger size. + * + * This will resize making the array larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_increase_by_ + extern f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_increase_by_ + +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_resize_ + extern f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_dynamicss_h diff --git a/level_0/f_utf/c/utf/map.c b/level_0/f_utf/c/utf/map.c index 6a3133d..707d910 100644 --- a/level_0/f_utf/c/utf/map.c +++ b/level_0/f_utf/c/utf/map.c @@ -1,305 +1,11 @@ #include "../utf.h" #include "../private-utf.h" #include "private-string.h" -#include "private-map.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_utf_string_maps_adjust_ - f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_maps_adjust(length, maps); - } -#endif // _di_f_utf_string_maps_adjust_ - -#ifndef _di_f_utf_string_maps_append_ - f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.name.used) { - status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.value.used) { - status = private_f_utf_string_append(source.value.string, source.value.used, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_maps_append_ - -#ifndef _di_f_utf_string_maps_append_all_ - f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_utf_string_maps_append_all(source, destination); - } -#endif // _di_f_utf_string_maps_append_all_ - -#ifndef _di_f_utf_string_maps_decimate_by_ - f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (maps->size > amount) { - return private_f_utf_string_maps_adjust(maps->size - amount, maps); - } - - return private_f_utf_string_maps_adjust(0, maps); - } -#endif // _di_f_utf_string_maps_decimate_by_ - -#ifndef _di_f_utf_string_maps_decrease_by_ - f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (maps->size > amount) { - return private_f_utf_string_maps_resize(maps->size - amount, maps); - } - - return private_f_utf_string_maps_resize(0, maps); - } -#endif // _di_f_utf_string_maps_decrease_by_ - -#ifndef _di_f_utf_string_maps_increase_ - f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && maps->used + 1 > maps->size) { - f_array_length_t size = maps->used + step; - - if (size > F_array_length_t_size_d) { - if (maps->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_maps_resize(size, maps); - } - - return F_data_not; - } -#endif // _di_f_utf_string_maps_increase_ - -#ifndef _di_f_utf_string_maps_increase_by_ - f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (maps->used + amount > maps->size) { - if (maps->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_maps_resize(maps->used + amount, maps); - } - - return F_data_not; - } -#endif // _di_f_utf_string_maps_increase_by_ - -#ifndef _di_f_utf_string_maps_resize_ - f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_maps_resize(length, maps); - } -#endif // _di_f_utf_string_maps_resize_ - -#ifndef _di_f_utf_string_mapss_adjust_ - f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_mapss_adjust(length, mapss); - } -#endif // _di_f_utf_string_mapss_adjust_ - -#ifndef _di_f_utf_string_mapss_append_ - f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_mapss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_utf_string_maps_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_mapss_append_ - -#ifndef _di_f_utf_string_mapss_append_all_ - f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_mapss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_maps_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_utf_string_mapss_append_all_ - -#ifndef _di_f_utf_string_mapss_decimate_by_ - f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (mapss->size > amount) { - return private_f_utf_string_mapss_adjust(mapss->size - amount, mapss); - } - - return private_f_utf_string_mapss_adjust(0, mapss); - } -#endif // _di_f_utf_string_mapss_decimate_by_ - -#ifndef _di_f_utf_string_mapss_decrease_by_ - f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (mapss->size > amount) { - return private_f_utf_string_mapss_resize(mapss->size - amount, mapss); - } - - return private_f_utf_string_mapss_resize(0, mapss); - } -#endif // _di_f_utf_string_mapss_decrease_by_ - -#ifndef _di_f_utf_string_mapss_increase_ - f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && mapss->used + 1 > mapss->size) { - f_array_length_t size = mapss->used + step; - - if (size > F_array_length_t_size_d) { - if (mapss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_mapss_resize(size, mapss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_mapss_increase_ - -#ifndef _di_f_utf_string_mapss_increase_by_ - f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (mapss->used + amount > mapss->size) { - if (mapss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_mapss_resize(mapss->used + amount, mapss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_mapss_increase_by_ - -#ifndef _di_f_utf_string_mapss_resize_ - f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { - #ifndef _di_level_0_parameter_checking_ - if (!mapss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_mapss_resize(length, mapss); - } -#endif // _di_f_utf_string_mapss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/map.h b/level_0/f_utf/c/utf/map.h index 29df11f..08bfa22 100644 --- a/level_0/f_utf/c/utf/map.h +++ b/level_0/f_utf/c/utf/map.h @@ -45,427 +45,6 @@ extern "C" { macro_f_utf_string_dynamic_t_destroy_simple(map.value) #endif // _di_f_utf_string_map_t_ -/** - * An array of string maps. - * - * array: the array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_maps_t_ - typedef struct { - f_utf_string_map_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_maps_t; - - #define f_utf_string_maps_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_maps_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_maps_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_maps_t_clear(maps) macro_f_memory_structure_clear(maps) - - #define macro_f_utf_string_maps_t_resize(status, maps, length) status = f_utf_string_maps_resize(length, &maps); - #define macro_f_utf_string_maps_t_adjust(status, maps, length) status = f_utf_string_maps_adjust(length, &maps); - - #define macro_f_utf_string_maps_t_delete_simple(maps) f_utf_string_maps_resize(0, &maps); - #define macro_f_utf_string_maps_t_destroy_simple(maps) f_utf_string_maps_adjust(0, &maps); - - #define macro_f_utf_string_maps_t_increase(status, step, maps) status = f_utf_string_maps_increase(step, maps); - #define macro_f_utf_string_maps_t_increase_by(status, maps, amount) status = f_utf_string_maps_increase_by(amount, maps); - #define macro_f_utf_string_maps_t_decrease_by(status, maps, amount) status = f_utf_string_maps_decrease_by(amount, maps); - #define macro_f_utf_string_maps_t_decimate_by(status, maps, amount) status = f_utf_string_maps_decimate_by(amount, maps); -#endif // _di_f_utf_string_maps_t_ - -/** - * An array of string maps. - * - * array: the array of an array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_mapss_t_ - typedef struct { - f_utf_string_maps_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_mapss_t; - - #define f_utf_string_mapss_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_mapss_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_mapss_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) - - #define macro_f_utf_string_mapss_t_resize(status, maps, length) status = f_utf_string_mapss_resize(length, &maps); - #define macro_f_utf_string_mapss_t_adjust(status, maps, length) status = f_utf_string_mapss_adjust(length, &maps); - - #define macro_f_utf_string_mapss_t_delete_simple(maps) f_utf_string_mapss_resize(0, &maps); - #define macro_f_utf_string_mapss_t_destroy_simple(maps) f_utf_string_mapss_adjust(0, &maps); - - #define macro_f_utf_string_mapss_t_increase(status, step, maps) status = f_utf_string_mapss_increase(step, maps); - #define macro_f_utf_string_mapss_t_increase_by(status, maps, amount) status = f_utf_string_mapss_increase_by(amount, maps); - #define macro_f_utf_string_mapss_t_decrease_by(status, maps, amount) status = f_utf_string_mapss_decrease_by(amount, maps); - #define macro_f_utf_string_mapss_t_decimate_by(status, maps, amount) status = f_utf_string_mapss_decimate_by(amount, maps); -#endif // _di_f_utf_string_mapss_t_ - -/** - * Resize the string maps array. - * - * @param length - * The new size to use. - * @param maps - * The string maps array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_adjust_ - extern f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_adjust_ - -/** - * Append a single source map onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_append_ - extern f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination); -#endif // _di_f_utf_string_maps_append_ - -/** - * Append the source maps onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_append_all_ - extern f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination); -#endif // _di_f_utf_string_maps_append_all_ - -/** - * Resize the string maps array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param maps - * The string maps array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_decimate_by_ - extern f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_decimate_by_ - -/** - * Resize the string maps array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param maps - * The string maps array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_decrease_by_ - extern f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_decrease_by_ - -/** - * Increase the size of the string maps array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param maps - * The string maps array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_increase_ - extern f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_increase_ - -/** - * Resize the string maps array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param maps - * The string maps array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_increase_by_ - extern f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_increase_by_ - -/** - * Resize the string maps array. - * - * @param length - * The new size to use. - * @param maps - * The string maps array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_maps_resize_ - extern f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps); -#endif // _di_f_utf_string_maps_resize_ - -/** - * Resize the string mapss array. - * - * @param length - * The new size to use. - * @param mapss - * The string mapss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_adjust_ - extern f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_adjust_ - -/** - * Append a single source maps onto the destination. - * - * @param source - * The source mapss to append. - * @param destination - * The destination mapss the source is appended onto. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_append_ - extern f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination); -#endif // _di_f_utf_string_mapss_append_ - -/** - * Append the source mapss onto the destination. - * - * @param source - * The source mapss to append. - * @param destination - * The destination mapss the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_append_all_ - extern f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination); -#endif // _di_f_utf_string_mapss_append_all_ - -/** - * Resize the string mapss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param mapss - * The string mapss array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_decimate_by_ - extern f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_decimate_by_ - -/** - * Resize the string mapss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param mapss - * The string mapss array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_decrease_by_ - extern f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_decrease_by_ - -/** - * Increase the size of the string mapss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param mapss - * The string mapss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_increase_ - extern f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_increase_ - -/** - * Resize the string mapss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param mapss - * The string mapss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_increase_by_ - extern f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_increase_by_ - -/** - * Resize the string mapss array. - * - * @param length - * The new size to use. - * @param mapss - * The string mapss array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_mapss_resize_ - extern f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss); -#endif // _di_f_utf_string_mapss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/map_multi.c b/level_0/f_utf/c/utf/map_multi.c index 9399f25..707d910 100644 --- a/level_0/f_utf/c/utf/map_multi.c +++ b/level_0/f_utf/c/utf/map_multi.c @@ -1,306 +1,11 @@ #include "../utf.h" #include "../private-utf.h" -#include "private-dynamic.h" -#include "private-map_multi.h" #include "private-string.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_utf_string_map_multis_adjust_ - f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_map_multis_adjust(length, map_multis); - } -#endif // _di_f_utf_string_map_multis_adjust_ - -#ifndef _di_f_utf_string_map_multis_append_ - f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.name.used) { - status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.value.used) { - status = private_f_utf_string_dynamics_append_all(source.value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_map_multis_append_ - -#ifndef _di_f_utf_string_map_multis_append_all_ - f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_utf_string_map_multis_append_all(source, destination); - } -#endif // _di_f_utf_string_map_multis_append_all_ - -#ifndef _di_f_utf_string_map_multis_decimate_by_ - f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multis->size > amount) { - return private_f_utf_string_map_multis_adjust(map_multis->size - amount, map_multis); - } - - return private_f_utf_string_map_multis_adjust(0, map_multis); - } -#endif // _di_f_utf_string_map_multis_decimate_by_ - -#ifndef _di_f_utf_string_map_multis_decrease_by_ - f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multis->size > amount) { - return private_f_utf_string_map_multis_resize(map_multis->size - amount, map_multis); - } - - return private_f_utf_string_map_multis_resize(0, map_multis); - } -#endif // _di_f_utf_string_map_multis_decrease_by_ - -#ifndef _di_f_utf_string_map_multis_increase_ - f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && map_multis->used + 1 > map_multis->size) { - f_array_length_t size = map_multis->used + step; - - if (size > F_array_length_t_size_d) { - if (map_multis->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_map_multis_resize(size, map_multis); - } - - return F_data_not; - } -#endif // _di_f_utf_string_map_multis_increase_ - -#ifndef _di_f_utf_string_map_multis_increase_by_ - f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multis->used + amount > map_multis->size) { - if (map_multis->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); - } - - return F_data_not; - } -#endif // _di_f_utf_string_map_multis_increase_by_ - -#ifndef _di_f_utf_string_map_multis_resize_ - f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_map_multis_resize(length, map_multis); - } -#endif // _di_f_utf_string_map_multis_resize_ - -#ifndef _di_f_utf_string_map_multiss_adjust_ - f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_map_multiss_adjust(length, map_multiss); - } -#endif // _di_f_utf_string_map_multiss_adjust_ - -#ifndef _di_f_utf_string_map_multiss_append_ - f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_utf_string_map_multis_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_map_multiss_append_ - -#ifndef _di_f_utf_string_map_multiss_append_all_ - f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_map_multiss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_map_multis_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_utf_string_map_multiss_append_all_ - -#ifndef _di_f_utf_string_map_multiss_decimate_by_ - f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multiss->size > amount) { - return private_f_utf_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); - } - - return private_f_utf_string_map_multiss_adjust(0, map_multiss); - } -#endif // _di_f_utf_string_map_multiss_decimate_by_ - -#ifndef _di_f_utf_string_map_multiss_decrease_by_ - f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multiss->size > amount) { - return private_f_utf_string_map_multiss_resize(map_multiss->size - amount, map_multiss); - } - - return private_f_utf_string_map_multiss_resize(0, map_multiss); - } -#endif // _di_f_utf_string_map_multiss_decrease_by_ - -#ifndef _di_f_utf_string_map_multiss_increase_ - f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && map_multiss->used + 1 > map_multiss->size) { - f_array_length_t size = map_multiss->used + step; - - if (size > F_array_length_t_size_d) { - if (map_multiss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_map_multiss_resize(size, map_multiss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_map_multiss_increase_ - -#ifndef _di_f_utf_string_map_multiss_increase_by_ - f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (map_multiss->used + amount > map_multiss->size) { - if (map_multiss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_map_multiss_resize(map_multiss->used + amount, map_multiss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_map_multiss_increase_by_ - -#ifndef _di_f_utf_string_map_multiss_resize_ - f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_map_multiss_resize(length, map_multiss); - } -#endif // _di_f_utf_string_map_multiss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/map_multi.h b/level_0/f_utf/c/utf/map_multi.h index 44af0f8..064dd8b 100644 --- a/level_0/f_utf/c/utf/map_multi.h +++ b/level_0/f_utf/c/utf/map_multi.h @@ -45,426 +45,6 @@ extern "C" { macro_f_utf_string_dynamics_t_destroy_simple(map.value) #endif // _di_f_utf_string_map_multi_t_ -/** - * An array of string maps. - * - * array: the array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_map_multis_t_ - typedef struct { - f_utf_string_map_multi_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_map_multis_t; - - #define f_utf_string_map_multis_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_map_multis_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_map_multis_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - - #define macro_f_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); - #define macro_f_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); - - #define macro_f_utf_string_map_multis_t_delete_simple(map_multis) f_utf_string_map_multis_resize(0, &map_multis); - #define macro_f_utf_string_map_multis_t_destroy_simple(map_multis) f_utf_string_map_multis_adjust(0, &map_multis); - - #define macro_f_utf_string_map_multis_t_increase(status, step, map_multis) status = f_utf_string_map_multis_increase(step, &map_multis); - #define macro_f_utf_string_map_multis_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multis_increase_by(amount, &map_multis); - #define macro_f_utf_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multis_decrease_by(amount, &map_multis); - #define macro_f_utf_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multis_decimate_by(amount, &map_multis); -#endif // _di_f_utf_string_map_multis_t_ - -/** - * An array of string maps. - * - * array: the array of an array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_map_multiss_t_ - typedef struct { - f_utf_string_map_multis_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_map_multiss_t; - - #define f_utf_string_map_multiss_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_map_multiss_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_map_multiss_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - - #define macro_f_utf_string_map_multiss_t_resize(status, map_multis, length) status = f_utf_string_map_multiss_resize(length, &map_multis); - #define macro_f_utf_string_map_multiss_t_adjust(status, map_multis, length) status = f_utf_string_map_multiss_adjust(length, &map_multis); - - #define macro_f_utf_string_map_multiss_t_delete_simple(map_multis) f_utf_string_map_multiss_resize(0, &map_multis); - #define macro_f_utf_string_map_multiss_t_destroy_simple(map_multis) f_utf_string_map_multiss_adjust(0, &map_multis); - - #define macro_f_utf_string_map_multiss_t_increase(status, step, map_multis) status = f_utf_string_map_multiss_increase(step, &map_multis); - #define macro_f_utf_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multiss_increase_by(amount, &map_multis); - #define macro_f_utf_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multiss_decrease_by(amount, &map_multis); - #define macro_f_utf_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multiss_decimate_by(amount, &map_multis); -#endif // _di_f_utf_string_map_multiss_t_ - -/** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_adjust_ - extern f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_adjust_ - -/** - * Append a single source map_multi onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_append_ - f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t *destination); -#endif // _di_f_utf_string_map_multis_append_ - -/** - * Append the source map_multis onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_append_all_ - f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination); -#endif // _di_f_utf_string_map_multis_append_all_ - -/** - * Resize the map_multis array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param map_multis - * The map_multis array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_decimate_by_ - extern f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_decimate_by_ - -/** - * Resize the map_multis array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param map_multis - * The map_multis array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_decrease_by_ - extern f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_decrease_by_ - -/** - * Increase the size of the map_multis array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param map_multis - * The map_multis array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_increase_ - extern f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_increase_ - -/** - * Resize the map_multis array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param map_multis - * The map_multis array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_increase_by_ - extern f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_increase_by_ - -/** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multis_resize_ - extern f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); -#endif // _di_f_utf_string_map_multis_resize_ - -/** - * Resize the map_multiss array. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_adjust_ - extern f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_adjust_ - -/** - * Append a single source map_multis onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_append_ - f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t *destination); -#endif // _di_f_utf_string_map_multiss_append_ - -/** - * Append the source map_multiss onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_append_all_ - f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t *destination); -#endif // _di_f_utf_string_map_multiss_append_all_ - -/** - * Resize the map_multiss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param map_multiss - * The map_multiss array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_decimate_by_ - extern f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_decimate_by_ - -/** - * Resize the map_multiss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param map_multiss - * The map_multiss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_decrease_by_ - extern f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_decrease_by_ - -/** - * Increase the size of the map_multiss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param map_multiss - * The map_multiss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_increase_ - extern f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_increase_ - -/** - * Resize the map_multiss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param map_multiss - * The map_multiss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_increase_by_ - extern f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_increase_by_ - -/** - * Resize the map_multiss array. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_map_multiss_resize_ - extern f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); -#endif // _di_f_utf_string_map_multiss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/map_multis.c b/level_0/f_utf/c/utf/map_multis.c new file mode 100644 index 0000000..b881b2f --- /dev/null +++ b/level_0/f_utf/c/utf/map_multis.c @@ -0,0 +1,154 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-map_multis.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_map_multis_adjust_ + f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_adjust(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_adjust_ + +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.name.used) { + status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.value.used) { + status = private_f_utf_string_dynamics_append_all(source.value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_map_multis_append_ + +#ifndef _di_f_utf_string_map_multis_append_all_ + f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_map_multis_append_all(source, destination); + } +#endif // _di_f_utf_string_map_multis_append_all_ + +#ifndef _di_f_utf_string_map_multis_decimate_by_ + f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size > amount) { + return private_f_utf_string_map_multis_adjust(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_adjust(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decimate_by_ + +#ifndef _di_f_utf_string_map_multis_decrease_by_ + f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size > amount) { + return private_f_utf_string_map_multis_resize(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_resize(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decrease_by_ + +#ifndef _di_f_utf_string_map_multis_increase_ + f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multis->used + 1 > map_multis->size) { + f_array_length_t size = map_multis->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multis->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_map_multis_resize(size, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_ + +#ifndef _di_f_utf_string_map_multis_increase_by_ + f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->used + amount > map_multis->size) { + if (map_multis->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_by_ + +#ifndef _di_f_utf_string_map_multis_resize_ + f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_resize(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/map_multis.h b/level_0/f_utf/c/utf/map_multis.h new file mode 100644 index 0000000..2835c9b --- /dev/null +++ b/level_0/f_utf/c/utf/map_multis.h @@ -0,0 +1,233 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines map string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_map_multis_h +#define _F_utf_map_multis_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_map_multis_t_ + typedef struct { + f_utf_string_map_multi_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_map_multis_t; + + #define f_utf_string_map_multis_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_map_multis_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_map_multis_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); + #define macro_f_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); + + #define macro_f_utf_string_map_multis_t_delete_simple(map_multis) f_utf_string_map_multis_resize(0, &map_multis); + #define macro_f_utf_string_map_multis_t_destroy_simple(map_multis) f_utf_string_map_multis_adjust(0, &map_multis); + + #define macro_f_utf_string_map_multis_t_increase(status, step, map_multis) status = f_utf_string_map_multis_increase(step, &map_multis); + #define macro_f_utf_string_map_multis_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multis_increase_by(amount, &map_multis); + #define macro_f_utf_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multis_decrease_by(amount, &map_multis); + #define macro_f_utf_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multis_decimate_by(amount, &map_multis); +#endif // _di_f_utf_string_map_multis_t_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_adjust_ + extern f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_adjust_ + +/** + * Append a single source map_multi onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t *destination); +#endif // _di_f_utf_string_map_multis_append_ + +/** + * Append the source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_append_all_ + f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination); +#endif // _di_f_utf_string_map_multis_append_all_ + +/** + * Resize the map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_decimate_by_ + extern f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_decimate_by_ + +/** + * Resize the map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_decrease_by_ + extern f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_decrease_by_ + +/** + * Increase the size of the map_multis array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_increase_ + extern f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_increase_ + +/** + * Resize the map_multis array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_increase_by_ + extern f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_increase_by_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_resize_ + extern f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_map_multis_h diff --git a/level_0/f_utf/c/utf/map_multiss.c b/level_0/f_utf/c/utf/map_multiss.c new file mode 100644 index 0000000..5fa5eae --- /dev/null +++ b/level_0/f_utf/c/utf/map_multiss.c @@ -0,0 +1,169 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-dynamicss.h" +#include "private-map_multis.h" +#include "private-map_multiss.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_map_multiss_adjust_ + f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multiss_adjust(length, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_adjust_ + +#ifndef _di_f_utf_string_map_multiss_append_ + f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_map_multis_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_map_multiss_append_ + +#ifndef _di_f_utf_string_map_multiss_append_all_ + f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_map_multiss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_map_multis_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_map_multiss_append_all_ + +#ifndef _di_f_utf_string_map_multiss_decimate_by_ + f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size > amount) { + return private_f_utf_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); + } + + return private_f_utf_string_map_multiss_adjust(0, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_decimate_by_ + +#ifndef _di_f_utf_string_map_multiss_decrease_by_ + f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size > amount) { + return private_f_utf_string_map_multiss_resize(map_multiss->size - amount, map_multiss); + } + + return private_f_utf_string_map_multiss_resize(0, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_decrease_by_ + +#ifndef _di_f_utf_string_map_multiss_increase_ + f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multiss->used + 1 > map_multiss->size) { + f_array_length_t size = map_multiss->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multiss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_map_multiss_resize(size, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multiss_increase_ + +#ifndef _di_f_utf_string_map_multiss_increase_by_ + f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->used + amount > map_multiss->size) { + if (map_multiss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multiss_increase_by_ + +#ifndef _di_f_utf_string_map_multiss_resize_ + f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multiss_resize(length, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/map_multiss.h b/level_0/f_utf/c/utf/map_multiss.h new file mode 100644 index 0000000..0b1b211 --- /dev/null +++ b/level_0/f_utf/c/utf/map_multiss.h @@ -0,0 +1,233 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines map string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_map_multiss_h +#define _F_utf_map_multiss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_map_multiss_t_ + typedef struct { + f_utf_string_map_multis_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_map_multiss_t; + + #define f_utf_string_map_multiss_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_map_multiss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_map_multiss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_utf_string_map_multiss_t_resize(status, map_multis, length) status = f_utf_string_map_multiss_resize(length, &map_multis); + #define macro_f_utf_string_map_multiss_t_adjust(status, map_multis, length) status = f_utf_string_map_multiss_adjust(length, &map_multis); + + #define macro_f_utf_string_map_multiss_t_delete_simple(map_multis) f_utf_string_map_multiss_resize(0, &map_multis); + #define macro_f_utf_string_map_multiss_t_destroy_simple(map_multis) f_utf_string_map_multiss_adjust(0, &map_multis); + + #define macro_f_utf_string_map_multiss_t_increase(status, step, map_multis) status = f_utf_string_map_multiss_increase(step, &map_multis); + #define macro_f_utf_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multiss_increase_by(amount, &map_multis); + #define macro_f_utf_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multiss_decrease_by(amount, &map_multis); + #define macro_f_utf_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multiss_decimate_by(amount, &map_multis); +#endif // _di_f_utf_string_map_multiss_t_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_adjust_ + extern f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_adjust_ + +/** + * Append a single source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_append_ + f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t *destination); +#endif // _di_f_utf_string_map_multiss_append_ + +/** + * Append the source map_multiss onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_append_all_ + f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t *destination); +#endif // _di_f_utf_string_map_multiss_append_all_ + +/** + * Resize the map_multiss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_decimate_by_ + extern f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_decimate_by_ + +/** + * Resize the map_multiss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_decrease_by_ + extern f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_decrease_by_ + +/** + * Increase the size of the map_multiss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_increase_ + extern f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_increase_ + +/** + * Resize the map_multiss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_increase_by_ + extern f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_increase_by_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_resize_ + extern f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_map_multiss_h diff --git a/level_0/f_utf/c/utf/maps.c b/level_0/f_utf/c/utf/maps.c new file mode 100644 index 0000000..0435192 --- /dev/null +++ b/level_0/f_utf/c/utf/maps.c @@ -0,0 +1,152 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-string.h" +#include "private-maps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_maps_adjust_ + f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_maps_adjust(length, maps); + } +#endif // _di_f_utf_string_maps_adjust_ + +#ifndef _di_f_utf_string_maps_append_ + f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.name.used) { + status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.value.used) { + status = private_f_utf_string_append(source.value.string, source.value.used, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_maps_append_ + +#ifndef _di_f_utf_string_maps_append_all_ + f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_maps_append_all(source, destination); + } +#endif // _di_f_utf_string_maps_append_all_ + +#ifndef _di_f_utf_string_maps_decimate_by_ + f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (maps->size > amount) { + return private_f_utf_string_maps_adjust(maps->size - amount, maps); + } + + return private_f_utf_string_maps_adjust(0, maps); + } +#endif // _di_f_utf_string_maps_decimate_by_ + +#ifndef _di_f_utf_string_maps_decrease_by_ + f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (maps->size > amount) { + return private_f_utf_string_maps_resize(maps->size - amount, maps); + } + + return private_f_utf_string_maps_resize(0, maps); + } +#endif // _di_f_utf_string_maps_decrease_by_ + +#ifndef _di_f_utf_string_maps_increase_ + f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && maps->used + 1 > maps->size) { + f_array_length_t size = maps->used + step; + + if (size > F_array_length_t_size_d) { + if (maps->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_maps_resize(size, maps); + } + + return F_data_not; + } +#endif // _di_f_utf_string_maps_increase_ + +#ifndef _di_f_utf_string_maps_increase_by_ + f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (maps->used + amount > maps->size) { + if (maps->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_maps_resize(maps->used + amount, maps); + } + + return F_data_not; + } +#endif // _di_f_utf_string_maps_increase_by_ + +#ifndef _di_f_utf_string_maps_resize_ + f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_maps_resize(length, maps); + } +#endif // _di_f_utf_string_maps_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/maps.h b/level_0/f_utf/c/utf/maps.h new file mode 100644 index 0000000..ebe3de7 --- /dev/null +++ b/level_0/f_utf/c/utf/maps.h @@ -0,0 +1,233 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines map UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_maps_h +#define _F_utf_maps_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_maps_t_ + typedef struct { + f_utf_string_map_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_maps_t; + + #define f_utf_string_maps_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_maps_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_maps_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_maps_t_clear(maps) macro_f_memory_structure_clear(maps) + + #define macro_f_utf_string_maps_t_resize(status, maps, length) status = f_utf_string_maps_resize(length, &maps); + #define macro_f_utf_string_maps_t_adjust(status, maps, length) status = f_utf_string_maps_adjust(length, &maps); + + #define macro_f_utf_string_maps_t_delete_simple(maps) f_utf_string_maps_resize(0, &maps); + #define macro_f_utf_string_maps_t_destroy_simple(maps) f_utf_string_maps_adjust(0, &maps); + + #define macro_f_utf_string_maps_t_increase(status, step, maps) status = f_utf_string_maps_increase(step, maps); + #define macro_f_utf_string_maps_t_increase_by(status, maps, amount) status = f_utf_string_maps_increase_by(amount, maps); + #define macro_f_utf_string_maps_t_decrease_by(status, maps, amount) status = f_utf_string_maps_decrease_by(amount, maps); + #define macro_f_utf_string_maps_t_decimate_by(status, maps, amount) status = f_utf_string_maps_decimate_by(amount, maps); +#endif // _di_f_utf_string_maps_t_ + +/** + * Resize the string maps array. + * + * @param length + * The new size to use. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_adjust_ + extern f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_adjust_ + +/** + * Append a single source map onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_append_ + extern f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination); +#endif // _di_f_utf_string_maps_append_ + +/** + * Append the source maps onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_append_all_ + extern f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination); +#endif // _di_f_utf_string_maps_append_all_ + +/** + * Resize the string maps array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_decimate_by_ + extern f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_decimate_by_ + +/** + * Resize the string maps array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_decrease_by_ + extern f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_decrease_by_ + +/** + * Increase the size of the string maps array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_increase_ + extern f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_increase_ + +/** + * Resize the string maps array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_increase_by_ + extern f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_increase_by_ + +/** + * Resize the string maps array. + * + * @param length + * The new size to use. + * @param maps + * The string maps array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_resize_ + extern f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_maps_h diff --git a/level_0/f_utf/c/utf/mapss.c b/level_0/f_utf/c/utf/mapss.c new file mode 100644 index 0000000..43cf24a --- /dev/null +++ b/level_0/f_utf/c/utf/mapss.c @@ -0,0 +1,166 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-string.h" +#include "private-maps.h" +#include "private-mapss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_mapss_adjust_ + f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_mapss_adjust(length, mapss); + } +#endif // _di_f_utf_string_mapss_adjust_ + +#ifndef _di_f_utf_string_mapss_append_ + f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_mapss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_maps_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_mapss_append_ + +#ifndef _di_f_utf_string_mapss_append_all_ + f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_mapss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_maps_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_mapss_append_all_ + +#ifndef _di_f_utf_string_mapss_decimate_by_ + f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (mapss->size > amount) { + return private_f_utf_string_mapss_adjust(mapss->size - amount, mapss); + } + + return private_f_utf_string_mapss_adjust(0, mapss); + } +#endif // _di_f_utf_string_mapss_decimate_by_ + +#ifndef _di_f_utf_string_mapss_decrease_by_ + f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (mapss->size > amount) { + return private_f_utf_string_mapss_resize(mapss->size - amount, mapss); + } + + return private_f_utf_string_mapss_resize(0, mapss); + } +#endif // _di_f_utf_string_mapss_decrease_by_ + +#ifndef _di_f_utf_string_mapss_increase_ + f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && mapss->used + 1 > mapss->size) { + f_array_length_t size = mapss->used + step; + + if (size > F_array_length_t_size_d) { + if (mapss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_mapss_resize(size, mapss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_mapss_increase_ + +#ifndef _di_f_utf_string_mapss_increase_by_ + f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (mapss->used + amount > mapss->size) { + if (mapss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_mapss_resize(mapss->used + amount, mapss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_mapss_increase_by_ + +#ifndef _di_f_utf_string_mapss_resize_ + f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_mapss_resize(length, mapss); + } +#endif // _di_f_utf_string_mapss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/mapss.h b/level_0/f_utf/c/utf/mapss.h new file mode 100644 index 0000000..275a4c4 --- /dev/null +++ b/level_0/f_utf/c/utf/mapss.h @@ -0,0 +1,234 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines map UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_mapss_h +#define _F_utf_mapss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_mapss_t_ + typedef struct { + f_utf_string_maps_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_mapss_t; + + #define f_utf_string_mapss_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_mapss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_mapss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) + + #define macro_f_utf_string_mapss_t_resize(status, maps, length) status = f_utf_string_mapss_resize(length, &maps); + #define macro_f_utf_string_mapss_t_adjust(status, maps, length) status = f_utf_string_mapss_adjust(length, &maps); + + #define macro_f_utf_string_mapss_t_delete_simple(maps) f_utf_string_mapss_resize(0, &maps); + #define macro_f_utf_string_mapss_t_destroy_simple(maps) f_utf_string_mapss_adjust(0, &maps); + + #define macro_f_utf_string_mapss_t_increase(status, step, maps) status = f_utf_string_mapss_increase(step, maps); + #define macro_f_utf_string_mapss_t_increase_by(status, maps, amount) status = f_utf_string_mapss_increase_by(amount, maps); + #define macro_f_utf_string_mapss_t_decrease_by(status, maps, amount) status = f_utf_string_mapss_decrease_by(amount, maps); + #define macro_f_utf_string_mapss_t_decimate_by(status, maps, amount) status = f_utf_string_mapss_decimate_by(amount, maps); +#endif // _di_f_utf_string_mapss_t_ + +/** + * Resize the string mapss array. + * + * @param length + * The new size to use. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_adjust_ + extern f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_adjust_ + +/** + * Append a single source maps onto the destination. + * + * @param source + * The source mapss to append. + * @param destination + * The destination mapss the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_append_ + extern f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination); +#endif // _di_f_utf_string_mapss_append_ + +/** + * Append the source mapss onto the destination. + * + * @param source + * The source mapss to append. + * @param destination + * The destination mapss the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_append_all_ + extern f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination); +#endif // _di_f_utf_string_mapss_append_all_ + +/** + * Resize the string mapss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_decimate_by_ + extern f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_decimate_by_ + +/** + * Resize the string mapss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_decrease_by_ + extern f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_decrease_by_ + +/** + * Increase the size of the string mapss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_increase_ + extern f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_increase_ + +/** + * Resize the string mapss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_increase_by_ + extern f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_increase_by_ + +/** + * Resize the string mapss array. + * + * @param length + * The new size to use. + * @param mapss + * The string mapss array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_resize_ + extern f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_mapss_h diff --git a/level_0/f_utf/c/utf/private-dynamic.c b/level_0/f_utf/c/utf/private-dynamic.c index f2564a7..8c08684 100644 --- a/level_0/f_utf/c/utf/private-dynamic.c +++ b/level_0/f_utf/c/utf/private-dynamic.c @@ -54,166 +54,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - - status = private_f_utf_string_dynamic_adjust(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_dynamics_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_utf_string_append(source.string, source.used, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - - -#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_dynamics_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - -#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) - f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - - status = private_f_utf_string_dynamic_resize(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) - -#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { - - if (dynamicss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamicss->size; ++i) { - - status = private_f_utf_string_dynamics_adjust(0, &dynamicss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); - if (F_status_is_error(status)) return status; - - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) - f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { - - if (dynamicss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamicss->size; ++i) { - - status = private_f_utf_string_dynamics_resize(0, &dynamicss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); - if (F_status_is_error(status)) return status; - - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-dynamic.h b/level_0/f_utf/c/utf/private-dynamic.h index 0e97f17..b172acd 100644 --- a/level_0/f_utf/c/utf/private-dynamic.h +++ b/level_0/f_utf/c/utf/private-dynamic.h @@ -141,170 +141,6 @@ extern "C" { extern f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamics - * The strings to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_dynamics_adjust() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_dynamics_decimate_by() - * @see f_utf_string_map_multis_adjust() - * @see f_utf_string_map_multis_append() - */ -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - extern f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source string to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_map_multis_append() - * @see f_utf_string_map_multis_append_all() - */ -#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - extern f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_dynamics_append_all() - * @see f_utf_string_map_multis_append() - * @see f_utf_string_map_multis_append_all() - */ -#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - extern f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamics - * The strings to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * - * @see f_utf_string_dynamics_decrease_by() - * @see f_utf_string_dynamics_increase() - * @see f_utf_string_dynamics_increase_by() - * @see f_utf_string_map_multis_append() - */ -#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) - extern f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamicss - * The strings to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_dynamicss_adjust() - * @see f_utf_string_dynamicss_append() - * @see f_utf_string_dynamicss_decimate_by() - * @see f_utf_string_map_multis_adjust() - * @see f_utf_string_map_multis_append() - */ -#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - extern f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamicss - * The strings to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_dynamicss_append_all() - * @see f_utf_string_dynamicss_decrease_by() - * @see f_utf_string_dynamicss_increase() - * @see f_utf_string_dynamicss_increase_by() - * @see f_utf_string_map_multis_append_all() - */ -#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) - extern f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-dynamics.c b/level_0/f_utf/c/utf/private-dynamics.c new file mode 100644 index 0000000..612342f --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamics.c @@ -0,0 +1,117 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_dynamics_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_append(source.string, source.used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + + +#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_dynamics_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-dynamics.h b/level_0/f_utf/c/utf/private-dynamics.h new file mode 100644 index 0000000..a660d78 --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamics.h @@ -0,0 +1,130 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_dynamics_h +#define _PRIVATE_F_utf_dynamics_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamics_adjust() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_dynamics_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_append_all() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * + * @see f_utf_string_dynamics_decrease_by() + * @see f_utf_string_dynamics_increase() + * @see f_utf_string_dynamics_increase_by() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(_di_f_utf_string_map_multis_append_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_dynamics_h diff --git a/level_0/f_utf/c/utf/private-dynamicss.c b/level_0/f_utf/c/utf/private-dynamicss.c new file mode 100644 index 0000000..fa33b57 --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamicss.c @@ -0,0 +1,70 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-dynamics.h" +#include "private-dynamicss.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_utf_string_dynamics_adjust(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_utf_string_dynamics_resize(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-dynamicss.h b/level_0/f_utf/c/utf/private-dynamicss.h new file mode 100644 index 0000000..44de6e0 --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamicss.h @@ -0,0 +1,78 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_dynamicss_h +#define _PRIVATE_F_utf_dynamicss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamicss_adjust() + * @see f_utf_string_dynamicss_append() + * @see f_utf_string_dynamicss_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamicss_append_all() + * @see f_utf_string_dynamicss_decrease_by() + * @see f_utf_string_dynamicss_increase() + * @see f_utf_string_dynamicss_increase_by() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_dynamicss_h diff --git a/level_0/f_utf/c/utf/private-map_multi.c b/level_0/f_utf/c/utf/private-map_multis.c similarity index 63% rename from level_0/f_utf/c/utf/private-map_multi.c rename to level_0/f_utf/c/utf/private-map_multis.c index 46f5fda..81c29bf 100644 --- a/level_0/f_utf/c/utf/private-map_multi.c +++ b/level_0/f_utf/c/utf/private-map_multis.c @@ -1,7 +1,8 @@ #include "../utf.h" #include "../private-utf.h" #include "private-dynamic.h" -#include "private-map_multi.h" +#include "private-dynamics.h" +#include "private-map_multis.h" #include "private-string.h" #ifdef __cplusplus @@ -100,62 +101,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) -#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) - f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { - - if (map_multiss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multiss->size; ++i) { - - status = private_f_utf_string_map_multis_adjust(0, &map_multiss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); - if (F_status_is_error(status)) return status; - - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) - -#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) - f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { - - if (map_multiss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multiss->size; ++i) { - - status = private_f_utf_string_map_multis_resize(0, &map_multiss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); - if (F_status_is_error(status)) return status; - - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-map_multi.h b/level_0/f_utf/c/utf/private-map_multis.h similarity index 60% rename from level_0/f_utf/c/utf/private-map_multi.h rename to level_0/f_utf/c/utf/private-map_multis.h index 6b045ad..fcda682 100644 --- a/level_0/f_utf/c/utf/private-map_multi.h +++ b/level_0/f_utf/c/utf/private-map_multis.h @@ -8,8 +8,8 @@ * These are provided for internal reduction in redundant code. * These should not be exposed/used outside of this project. */ -#ifndef _PRIVATE_F_map_multi_h -#define _PRIVATE_F_map_multi_h +#ifndef _PRIVATE_F_map_multis_h +#define _PRIVATE_F_map_multis_h #ifdef __cplusplus extern "C" { @@ -93,60 +93,8 @@ extern "C" { extern f_status_t private_f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_map_multiss_adjust() - */ -#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) - extern f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_utf_string_map_multiss_decrease_by() - * @see f_utf_string_map_multiss_increase() - * @see f_utf_string_map_multiss_increase_by() - * @see f_utf_string_map_multiss_terminate() - * @see f_utf_string_map_multiss_terminate_after() - */ -#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) - extern f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif -#endif // _PRIVATE_F_map_multi_h +#endif // _PRIVATE_F_map_multis_h diff --git a/level_0/f_utf/c/utf/private-map_multiss.c b/level_0/f_utf/c/utf/private-map_multiss.c new file mode 100644 index 0000000..204d47f --- /dev/null +++ b/level_0/f_utf/c/utf/private-map_multiss.c @@ -0,0 +1,70 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-map_multis.h" +#include "private-map_multiss.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_utf_string_map_multis_adjust(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + +#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_utf_string_map_multis_resize(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-map_multiss.h b/level_0/f_utf/c/utf/private-map_multiss.h new file mode 100644 index 0000000..69ef1df --- /dev/null +++ b/level_0/f_utf/c/utf/private-map_multiss.h @@ -0,0 +1,74 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_map_multiss_h +#define _PRIVATE_F_map_multiss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multiss_adjust() + */ +#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + extern f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multiss_decrease_by() + * @see f_utf_string_map_multiss_increase() + * @see f_utf_string_map_multiss_increase_by() + * @see f_utf_string_map_multiss_terminate() + * @see f_utf_string_map_multiss_terminate_after() + */ +#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + extern f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_map_multiss_h diff --git a/level_0/f_utf/c/utf/private-map.c b/level_0/f_utf/c/utf/private-maps.c similarity index 64% rename from level_0/f_utf/c/utf/private-map.c rename to level_0/f_utf/c/utf/private-maps.c index 16b159a..d3b9e38 100644 --- a/level_0/f_utf/c/utf/private-map.c +++ b/level_0/f_utf/c/utf/private-maps.c @@ -1,7 +1,7 @@ #include "../utf.h" #include "../private-utf.h" #include "private-dynamic.h" -#include "private-map.h" +#include "private-maps.h" #include "private-string.h" #ifdef __cplusplus @@ -100,62 +100,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) -#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) - f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { - - if (mapss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < mapss->size; ++i) { - - status = private_f_utf_string_maps_adjust(0, &mapss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); - if (F_status_is_error(status)) return status; - - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) - -#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) - f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { - - if (mapss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < mapss->size; ++i) { - - status = private_f_utf_string_maps_resize(0, &mapss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); - if (F_status_is_error(status)) return status; - - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-map.h b/level_0/f_utf/c/utf/private-maps.h similarity index 60% rename from level_0/f_utf/c/utf/private-map.h rename to level_0/f_utf/c/utf/private-maps.h index fec3893..4d2f106 100644 --- a/level_0/f_utf/c/utf/private-map.h +++ b/level_0/f_utf/c/utf/private-maps.h @@ -8,8 +8,8 @@ * These are provided for internal reduction in redundant code. * These should not be exposed/used outside of this project. */ -#ifndef _PRIVATE_F_utf_map_h -#define _PRIVATE_F_utf_map_h +#ifndef _PRIVATE_F_utf_maps_h +#define _PRIVATE_F_utf_maps_h #ifdef __cplusplus extern "C" { @@ -93,60 +93,8 @@ extern "C" { extern f_status_t private_f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param mapss - * The mapss to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_mapss_adjust() - */ -#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) - extern f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param mapss - * The mapss to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_utf_string_mapss_decrease_by() - * @see f_utf_string_mapss_increase() - * @see f_utf_string_mapss_increase_by() - * @see f_utf_string_mapss_terminate() - * @see f_utf_string_mapss_terminate_after() - */ -#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) - extern f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif -#endif // _PRIVATE_F_utf_map_h +#endif // _PRIVATE_F_utf_maps_h diff --git a/level_0/f_utf/c/utf/private-mapss.c b/level_0/f_utf/c/utf/private-mapss.c new file mode 100644 index 0000000..a3a2840 --- /dev/null +++ b/level_0/f_utf/c/utf/private-mapss.c @@ -0,0 +1,70 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-maps.h" +#include "private-mapss.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_utf_string_maps_adjust(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + +#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_utf_string_maps_resize(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-mapss.h b/level_0/f_utf/c/utf/private-mapss.h new file mode 100644 index 0000000..a55b723 --- /dev/null +++ b/level_0/f_utf/c/utf/private-mapss.h @@ -0,0 +1,74 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_mapss_h +#define _PRIVATE_F_utf_mapss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_mapss_adjust() + */ +#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + extern f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_mapss_decrease_by() + * @see f_utf_string_mapss_increase() + * @see f_utf_string_mapss_increase_by() + * @see f_utf_string_mapss_terminate() + * @see f_utf_string_mapss_terminate_after() + */ +#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + extern f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_mapss_h diff --git a/level_0/f_utf/c/utf/private-triple.c b/level_0/f_utf/c/utf/private-triples.c similarity index 66% rename from level_0/f_utf/c/utf/private-triple.c rename to level_0/f_utf/c/utf/private-triples.c index 28e3524..e94b8c2 100644 --- a/level_0/f_utf/c/utf/private-triple.c +++ b/level_0/f_utf/c/utf/private-triples.c @@ -1,7 +1,7 @@ #include "../utf.h" #include "../private-utf.h" #include "private-dynamic.h" -#include "private-triple.h" +#include "private-triples.h" #include "private-string.h" #ifdef __cplusplus @@ -112,62 +112,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) -#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) - f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { - - if (tripless->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < tripless->size; ++i) { - - status = private_f_utf_string_triples_adjust(0, &tripless->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); - if (F_status_is_error(status)) return status; - - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) - -#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) - f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { - - if (tripless->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < tripless->size; ++i) { - - status = private_f_utf_string_triples_resize(0, &tripless->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); - if (F_status_is_error(status)) return status; - - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-triple.h b/level_0/f_utf/c/utf/private-triples.h similarity index 60% rename from level_0/f_utf/c/utf/private-triple.h rename to level_0/f_utf/c/utf/private-triples.h index b08abd8..4dc0560 100644 --- a/level_0/f_utf/c/utf/private-triple.h +++ b/level_0/f_utf/c/utf/private-triples.h @@ -8,8 +8,8 @@ * These are provided for internal reduction in redundant code. * These should not be exposed/used outside of this project. */ -#ifndef _PRIVATE_F_utf_triple_h -#define _PRIVATE_F_utf_triple_h +#ifndef _PRIVATE_F_utf_triples_h +#define _PRIVATE_F_utf_triples_h #ifdef __cplusplus extern "C" { @@ -93,60 +93,8 @@ extern "C" { extern f_status_t private_f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param tripless - * The tripless to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_tripless_adjust() - */ -#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) - extern f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param tripless - * The tripless to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_utf_string_tripless_decrease_by() - * @see f_utf_string_tripless_increase() - * @see f_utf_string_tripless_increase_by() - * @see f_utf_string_tripless_terminate() - * @see f_utf_string_tripless_terminate_after() - */ -#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) - extern f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif -#endif // _PRIVATE_F_utf_triple_h +#endif // _PRIVATE_F_utf_triples_h diff --git a/level_0/f_utf/c/utf/private-tripless.c b/level_0/f_utf/c/utf/private-tripless.c new file mode 100644 index 0000000..bc4e013 --- /dev/null +++ b/level_0/f_utf/c/utf/private-tripless.c @@ -0,0 +1,70 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-triples.h" +#include "private-tripless.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_utf_string_triples_adjust(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + +#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_utf_string_triples_resize(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-tripless.h b/level_0/f_utf/c/utf/private-tripless.h new file mode 100644 index 0000000..e0d45d1 --- /dev/null +++ b/level_0/f_utf/c/utf/private-tripless.h @@ -0,0 +1,74 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_tripless_h +#define _PRIVATE_F_utf_tripless_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_tripless_adjust() + */ +#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + extern f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_tripless_decrease_by() + * @see f_utf_string_tripless_increase() + * @see f_utf_string_tripless_increase_by() + * @see f_utf_string_tripless_terminate() + * @see f_utf_string_tripless_terminate_after() + */ +#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + extern f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_tripless_h diff --git a/level_0/f_utf/c/utf/static.h b/level_0/f_utf/c/utf/static.h index 5d4930c..12c4cae 100644 --- a/level_0/f_utf/c/utf/static.h +++ b/level_0/f_utf/c/utf/static.h @@ -48,58 +48,6 @@ extern "C" { #endif // _di_f_utf_string_static_t_ /** - * An array of static strings. - * - * array: The array of static strings. - * size: Total amount of space available. - * used: Total number of space used. - */ -#ifndef _di_f_utf_string_statics_t_ - typedef struct { - f_utf_string_static_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_statics_t; - - #define f_utf_string_statics_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_statics_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_statics_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_statics_t_clear(statics) \ - statics.array = 0; \ - statics.size = 0; \ - statics.used = 0; -#endif // _di_f_utf_string_statics_t_ - -/** - * An array of static strings. - * - * array: The array of static strings. - * size: Total amount of space available. - * used: Total number of space used. - */ -#ifndef _di_f_utf_string_staticss_t_ - typedef struct { - f_utf_string_statics_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_staticss_t; - - #define f_utf_string_staticss_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_staticss_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_staticss_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_staticss_t_clear(staticss) \ - staticss.array = 0; \ - staticss.size = 0; \ - staticss.used = 0; -#endif // _di_f_utf_string_staticss_t_ - -/** * Provide a static empty string. * * This is intended to represent an empty string. diff --git a/level_0/f_utf/c/utf/statics.c b/level_0/f_utf/c/utf/statics.c new file mode 100644 index 0000000..9934acb --- /dev/null +++ b/level_0/f_utf/c/utf/statics.c @@ -0,0 +1,9 @@ +#include "../utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/statics.h b/level_0/f_utf/c/utf/statics.h new file mode 100644 index 0000000..a3ed07d --- /dev/null +++ b/level_0/f_utf/c/utf/statics.h @@ -0,0 +1,49 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines static string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_statics_h +#define _F_utf_statics_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of static strings. + * + * array: The array of static strings. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_utf_string_statics_t_ + typedef struct { + f_utf_string_static_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_statics_t; + + #define f_utf_string_statics_t_initialize { 0, 0, 0 } + + #define macro_f_utf_string_statics_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_statics_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_statics_t_clear(statics) \ + statics.array = 0; \ + statics.size = 0; \ + statics.used = 0; +#endif // _di_f_utf_string_statics_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_statics_h diff --git a/level_0/f_utf/c/utf/staticss.c b/level_0/f_utf/c/utf/staticss.c new file mode 100644 index 0000000..9934acb --- /dev/null +++ b/level_0/f_utf/c/utf/staticss.c @@ -0,0 +1,9 @@ +#include "../utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/staticss.h b/level_0/f_utf/c/utf/staticss.h new file mode 100644 index 0000000..359ec36 --- /dev/null +++ b/level_0/f_utf/c/utf/staticss.h @@ -0,0 +1,49 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines static string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_staticss_h +#define _F_utf_staticss_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of static strings. + * + * array: The array of static strings. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_utf_string_staticss_t_ + typedef struct { + f_utf_string_statics_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_staticss_t; + + #define f_utf_string_staticss_t_initialize { 0, 0, 0 } + + #define macro_f_utf_string_staticss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_staticss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_staticss_t_clear(staticss) \ + staticss.array = 0; \ + staticss.size = 0; \ + staticss.used = 0; +#endif // _di_f_utf_string_staticss_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_staticss_h diff --git a/level_0/f_utf/c/utf/strings.c b/level_0/f_utf/c/utf/strings.c new file mode 100644 index 0000000..cb40e7b --- /dev/null +++ b/level_0/f_utf/c/utf/strings.c @@ -0,0 +1,370 @@ +#include "../utf.h" +#include "private-dynamic.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_append_ + f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_append_ + +#ifndef _di_f_utf_string_append_assure_ + f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (destination->used < length) { + return private_f_utf_string_append(source, length, destination); + } + + f_array_length_t i = 1; + f_array_length_t j = 1; + + while (i <= length && j <= destination->used) { + + if (!source[length - i]) { + ++i; + + continue; + } + + if (!destination->string[destination->used - j]) { + ++j; + + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_ + +#ifndef _di_f_utf_string_append_assure_nulless_ + f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (!destination->used) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + f_array_length_t i = 1; + f_array_length_t j = 1; + + while (i <= length && j <= destination->used) { + + if (!source[length - i]) { + ++i; + + continue; + } + + if (!destination->string[destination->used - j]) { + ++j; + + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_nulless_ + +#ifndef _di_f_utf_string_append_nulless_ + f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_append_nulless_ + +#ifndef _di_f_utf_string_mash_ + f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) { + return F_data_not; + } + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_mash_ + +#ifndef _di_f_utf_string_mash_nulless_ + f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mash_nulless_ + +#ifndef _di_f_utf_string_mish_ + f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_mish_ + +#ifndef _di_f_utf_string_mish_nulless_ + f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mish_nulless_ + +#ifndef _di_f_utf_string_prepend_ + f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_prepend_ + +#ifndef _di_f_utf_string_prepend_assure_ + f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (destination->used < length) { + return private_f_utf_string_prepend(source, length, destination); + } + + f_array_length_t i = 0; + f_array_length_t j = 0; + + while (i < length && j < destination->used) { + + if (!source[i]) { + ++i; + + continue; + } + + if (!destination->string[j]) { + ++j; + + continue; + } + + if (source[i] != destination->string[j]) { + return private_f_utf_string_prepend(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_ + +#ifndef _di_f_utf_string_prepend_assure_nulless_ + f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (!destination->used) { + return private_f_utf_string_prepend_nulless(source, length, destination); + } + + f_array_length_t i = 0; + f_array_length_t j = 0; + + while (i < length && j < destination->used) { + + if (!source[i]) { + ++i; + + continue; + } + + if (!destination->string[j]) { + ++j; + + continue; + } + + if (source[i] != destination->string[j]) { + return private_f_utf_string_prepend_nulless(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_nulless_ + +#ifndef _di_f_utf_string_prepend_nulless_ + f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_prepend_nulless_ + +#ifndef _di_f_utf_string_seek_line_ + f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t *range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != f_utf_char_t_eol_s) { + + if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf_fragment); + } + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_line_ + +#ifndef _di_f_utf_string_seek_line_to_ + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != seek_to) { + + if (string[range->start] == f_utf_char_t_eol_s) { + return F_none_eol; + } + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_line_to_ + +#ifndef _di_f_utf_string_seek_to_ + f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != seek_to) { + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_to_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/strings.h b/level_0/f_utf/c/utf/strings.h new file mode 100644 index 0000000..82fce63 --- /dev/null +++ b/level_0/f_utf/c/utf/strings.h @@ -0,0 +1,425 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgplv2.1 + * + * Defines UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_h +#define _F_utf_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Append the source string onto the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_f_utf_string_append_ + extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_ + +/** + * Append the source string onto the destination only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_f_utf_string_append_assure_ + extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_assure_ + +/** + * Append the source string onto the destination only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_append_assure_nulless_ + extern f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_assure_nulless_ + +/** + * Append the source string onto the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_append_nulless_ + extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_nulless_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mash_ + extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mash_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mash_nulless_ + extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mash_nulless_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mish_ + extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mish_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mish_nulless_ + extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mish_nulless_ + +/** + * Prepend the source string onto the destination. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_ + extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_ + +/** + * Prepend the source string onto the destination only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_assure_ + extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_assure_ + +/** + * Prepend the source string onto the destination only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_assure_nulless_ + extern f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_assure_nulless_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_nulless_ + extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_nulless_ + +/** + * Seek the string location forward until EOL is reached. + * + * @param string + * The string to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at end of range. + * F_data_not_stop on success, but the range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_seek_line_ + extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_line_ + +/** + * Seek the string location forward until the character (1-byte wide) or EOL is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_stop on success, but stopped at the stop location. + * F_data_not_stop if range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_seek_line_to_ + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_line_to_ + +/** + * Seek the string location forward until the character (1-byte wide) is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at the stop location. + * F_data_not_stop if range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. + */ +#ifndef _di_f_utf_string_seek_to_ + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_to_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_h diff --git a/level_0/f_utf/c/utf/stringss.c b/level_0/f_utf/c/utf/stringss.c new file mode 100644 index 0000000..cb40e7b --- /dev/null +++ b/level_0/f_utf/c/utf/stringss.c @@ -0,0 +1,370 @@ +#include "../utf.h" +#include "private-dynamic.h" +#include "private-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_append_ + f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_append_ + +#ifndef _di_f_utf_string_append_assure_ + f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (destination->used < length) { + return private_f_utf_string_append(source, length, destination); + } + + f_array_length_t i = 1; + f_array_length_t j = 1; + + while (i <= length && j <= destination->used) { + + if (!source[length - i]) { + ++i; + + continue; + } + + if (!destination->string[destination->used - j]) { + ++j; + + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_ + +#ifndef _di_f_utf_string_append_assure_nulless_ + f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (!destination->used) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + f_array_length_t i = 1; + f_array_length_t j = 1; + + while (i <= length && j <= destination->used) { + + if (!source[length - i]) { + ++i; + + continue; + } + + if (!destination->string[destination->used - j]) { + ++j; + + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_nulless_ + +#ifndef _di_f_utf_string_append_nulless_ + f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_append_nulless_ + +#ifndef _di_f_utf_string_mash_ + f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) { + return F_data_not; + } + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_mash_ + +#ifndef _di_f_utf_string_mash_nulless_ + f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mash_nulless_ + +#ifndef _di_f_utf_string_mish_ + f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_mish_ + +#ifndef _di_f_utf_string_mish_nulless_ + f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mish_nulless_ + +#ifndef _di_f_utf_string_prepend_ + f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_prepend_ + +#ifndef _di_f_utf_string_prepend_assure_ + f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (destination->used < length) { + return private_f_utf_string_prepend(source, length, destination); + } + + f_array_length_t i = 0; + f_array_length_t j = 0; + + while (i < length && j < destination->used) { + + if (!source[i]) { + ++i; + + continue; + } + + if (!destination->string[j]) { + ++j; + + continue; + } + + if (source[i] != destination->string[j]) { + return private_f_utf_string_prepend(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_ + +#ifndef _di_f_utf_string_prepend_assure_nulless_ + f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + if (!destination->used) { + return private_f_utf_string_prepend_nulless(source, length, destination); + } + + f_array_length_t i = 0; + f_array_length_t j = 0; + + while (i < length && j < destination->used) { + + if (!source[i]) { + ++i; + + continue; + } + + if (!destination->string[j]) { + ++j; + + continue; + } + + if (source[i] != destination->string[j]) { + return private_f_utf_string_prepend_nulless(source, length, destination); + } + + ++i; + ++j; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_nulless_ + +#ifndef _di_f_utf_string_prepend_nulless_ + f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not; + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_prepend_nulless_ + +#ifndef _di_f_utf_string_seek_line_ + f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t *range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != f_utf_char_t_eol_s) { + + if (macro_f_utf_char_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf_fragment); + } + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_line_ + +#ifndef _di_f_utf_string_seek_line_to_ + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != seek_to) { + + if (string[range->start] == f_utf_char_t_eol_s) { + return F_none_eol; + } + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_line_to_ + +#ifndef _di_f_utf_string_seek_to_ + f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) { + return F_data_not_stop; + } + + while (string[range->start] != seek_to) { + + ++range->start; + + if (range->start > range->stop) { + return F_none_stop; + } + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_to_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/stringss.h b/level_0/f_utf/c/utf/stringss.h new file mode 100644 index 0000000..82fce63 --- /dev/null +++ b/level_0/f_utf/c/utf/stringss.h @@ -0,0 +1,425 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgplv2.1 + * + * Defines UTF-8 string data. + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_h +#define _F_utf_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Append the source string onto the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_f_utf_string_append_ + extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_ + +/** + * Append the source string onto the destination only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_f_utf_string_append_assure_ + extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_assure_ + +/** + * Append the source string onto the destination only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_append_assure_nulless_ + extern f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_assure_nulless_ + +/** + * Append the source string onto the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_append_nulless_ + extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_append_nulless_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mash_ + extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mash_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mash_nulless_ + extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mash_nulless_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mish_ + extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mish_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mish_nulless_ + extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_mish_nulless_ + +/** + * Prepend the source string onto the destination. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_ + extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_ + +/** + * Prepend the source string onto the destination only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_assure_ + extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_assure_ + +/** + * Prepend the source string onto the destination only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_assure_nulless_ + extern f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_assure_nulless_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_prepend_nulless_ + extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); +#endif // _di_f_utf_string_prepend_nulless_ + +/** + * Seek the string location forward until EOL is reached. + * + * @param string + * The string to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at end of range. + * F_data_not_stop on success, but the range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_seek_line_ + extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_line_ + +/** + * Seek the string location forward until the character (1-byte wide) or EOL is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_stop on success, but stopped at the stop location. + * F_data_not_stop if range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_seek_line_to_ + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_line_to_ + +/** + * Seek the string location forward until the character (1-byte wide) is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at the stop location. + * F_data_not_stop if range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_utf_fragment (with error bit) if character is a UTF-8 fragment. + * F_utf_not (with error bit) if unicode is an invalid Unicode character. + */ +#ifndef _di_f_utf_string_seek_to_ + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_utf_char_t seek_to, f_string_range_t * const range); +#endif // _di_f_utf_string_seek_to_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_h diff --git a/level_0/f_utf/c/utf/triple.c b/level_0/f_utf/c/utf/triple.c index bb79331..707d910 100644 --- a/level_0/f_utf/c/utf/triple.c +++ b/level_0/f_utf/c/utf/triple.c @@ -1,338 +1,11 @@ #include "../utf.h" #include "../private-utf.h" #include "private-string.h" -#include "private-triple.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_utf_string_triples_adjust_ - f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_triples_adjust(length, triples); - } -#endif // _di_f_utf_string_triples_adjust_ - -#ifndef _di_f_utf_string_triples_append_ - f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_triples_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].a.used = 0; - destination->array[destination->used].b.used = 0; - destination->array[destination->used].c.used = 0; - - if (source.a.used) { - status = private_f_utf_string_append(source.a.string, source.a.used, &destination->array[destination->used].a); - if (F_status_is_error(status)) return status; - } - - if (source.b.used) { - status = private_f_utf_string_append(source.b.string, source.b.used, &destination->array[destination->used].b); - if (F_status_is_error(status)) return status; - } - - if (source.c.used) { - status = private_f_utf_string_append(source.c.string, source.c.used, &destination->array[destination->used].c); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_triples_append_ - -#ifndef _di_f_utf_string_triples_append_all_ - f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_triples_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].a.used = 0; - destination->array[destination->used].b.used = 0; - destination->array[destination->used].c.used = 0; - - if (source.array[i].a.used) { - status = private_f_utf_string_append(source.array[i].a.string, source.array[i].a.used, &destination->array[destination->used].a); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].b.used) { - status = private_f_utf_string_append(source.array[i].b.string, source.array[i].b.used, &destination->array[destination->used].b); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].c.used) { - status = private_f_utf_string_append(source.array[i].c.string, source.array[i].c.used, &destination->array[destination->used].c); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_utf_string_triples_append_all_ - -#ifndef _di_f_utf_string_triples_decimate_by_ - f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (triples->size > amount) { - return private_f_utf_string_triples_adjust(triples->size - amount, triples); - } - - return private_f_utf_string_triples_adjust(0, triples); - } -#endif // _di_f_utf_string_triples_decimate_by_ - -#ifndef _di_f_utf_string_triples_decrease_by_ - f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (triples->size > amount) { - return private_f_utf_string_triples_resize(triples->size - amount, triples); - } - - return private_f_utf_string_triples_resize(0, triples); - } -#endif // _di_f_utf_string_triples_decrease_by_ - -#ifndef _di_f_utf_string_triples_increase_ - f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && triples->used + 1 > triples->size) { - f_array_length_t size = triples->used + F_memory_default_allocation_small_d; - - if (size > F_array_length_t_size_d) { - if (triples->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_triples_resize(size, triples); - } - - return F_data_not; - } -#endif // _di_f_utf_string_triples_increase_ - -#ifndef _di_f_utf_string_triples_increase_by_ - f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (triples->used + amount > triples->size) { - if (triples->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_triples_resize(triples->used + amount, triples); - } - - return F_data_not; - } -#endif // _di_f_utf_string_triples_increase_by_ - -#ifndef _di_f_utf_string_triples_resize_ - f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) { - #ifndef _di_level_0_parameter_checking_ - if (!triples) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_triples_resize(length, triples); - } -#endif // _di_f_utf_string_triples_resize_ - -#ifndef _di_f_utf_string_tripless_append_ - f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_utf_string_tripless_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_utf_string_triples_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_utf_string_tripless_append_ - -#ifndef _di_f_utf_string_tripless_append_all_ - f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_tripless_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_triples_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_utf_string_tripless_append_all_ - -#ifndef _di_f_utf_string_tripless_adjust_ - f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_tripless_adjust(length, tripless); - } -#endif // _di_f_utf_string_tripless_adjust_ - -#ifndef _di_f_utf_string_tripless_decimate_by_ - f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (tripless->size > amount) { - return private_f_utf_string_tripless_adjust(tripless->size - amount, tripless); - } - - return private_f_utf_string_tripless_adjust(0, tripless); - } -#endif // _di_f_utf_string_tripless_decimate_by_ - -#ifndef _di_f_utf_string_tripless_decrease_by_ - f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (tripless->size > amount) { - return private_f_utf_string_tripless_resize(tripless->size - amount, tripless); - } - - return private_f_utf_string_tripless_resize(0, tripless); - } -#endif // _di_f_utf_string_tripless_decrease_by_ - -#ifndef _di_f_utf_string_tripless_increase_ - f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && tripless->used + 1 > tripless->size) { - f_array_length_t size = tripless->used + step; - - if (size > F_array_length_t_size_d) { - if (tripless->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_utf_string_tripless_resize(size, tripless); - } - - return F_data_not; - } -#endif // _di_f_utf_string_tripless_increase_ - -#ifndef _di_f_utf_string_tripless_increase_by_ - f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - if (tripless->used + amount > tripless->size) { - if (tripless->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_tripless_resize(tripless->used + amount, tripless); - } - - return F_data_not; - } -#endif // _di_f_utf_string_tripless_increase_by_ - -#ifndef _di_f_utf_string_tripless_resize_ - f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { - #ifndef _di_level_0_parameter_checking_ - if (!tripless) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_tripless_resize(length, tripless); - } -#endif // _di_f_utf_string_tripless_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/triple.h b/level_0/f_utf/c/utf/triple.h index cd5ef86..4ac9751 100644 --- a/level_0/f_utf/c/utf/triple.h +++ b/level_0/f_utf/c/utf/triple.h @@ -56,428 +56,6 @@ extern "C" { macro_f_utf_string_dynamic_t_destroy_simple(triple.c) #endif // _di_f_utf_string_triple_t_ -/** - * An array of string triples. - * - * array: The array of string triples. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_triples_t_ - typedef struct { - f_utf_string_triple_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_triples_t; - - #define f_utf_string_triples_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_triples_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_triples_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_triples_t_clear(triples) macro_f_memory_structure_clear(triples) - - #define macro_f_utf_string_triples_t_resize(status, triples, length) status = f_utf_string_triples_resize(length, &triples); - #define macro_f_utf_string_triples_t_adjust(status, triples, length) status = f_utf_string_triples_adjust(length, &triples); - - #define macro_f_utf_string_triples_t_delete_simple(triples) f_utf_string_triples_resize(0, &triples); - #define macro_f_utf_string_triples_t_destroy_simple(triples) f_utf_string_triples_adjust(0, &triples); - - #define macro_f_utf_string_triples_t_increase(status, step, triples) status = f_utf_string_triples_increase(step, triples); - #define macro_f_utf_string_triples_t_increase_by(status, triples, amount) status = f_utf_string_triples_increase_by(amount, triples); - #define macro_f_utf_string_triples_t_decrease_by(status, triples, amount) status = f_utf_string_triples_decrease_by(amount, triples); - #define macro_f_utf_string_triples_t_decimate_by(status, triples, amount) status = f_utf_string_triples_decimate_by(amount, triples); -#endif // _di_f_utf_string_triples_t_ - -/** - * An array of string tripless. - * - * array: The array of string triples. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_tripless_t_ - typedef struct { - f_utf_string_triples_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_tripless_t; - - #define f_utf_string_tripless_t_initialize f_utf_string_statics_t_initialize - - #define macro_f_utf_string_tripless_t_initialize(array, size, used) { array, size, used } - #define macro_f_utf_string_tripless_t_initialize2(array, length) { array, length, length } - - #define macro_f_utf_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) - - #define macro_f_utf_string_tripless_t_resize(status, tripless, length) status = f_utf_string_tripless_resize(length, &tripless); - #define macro_f_utf_string_tripless_t_adjust(status, tripless, length) status = f_utf_string_tripless_adjust(length, &tripless); - - #define macro_f_utf_string_tripless_t_delete_simple(tripless) f_utf_string_tripless_resize(0, &tripless); - #define macro_f_utf_string_tripless_t_destroy_simple(tripless) f_utf_string_tripless_adjust(0, &tripless); - - #define macro_f_utf_string_tripless_t_increase(status, step, tripless) status = f_utf_string_tripless_increase(step, tripless); - #define macro_f_utf_string_tripless_t_increase_by(status, tripless, amount) status = f_utf_string_tripless_increase_by(amount, tripless); - #define macro_f_utf_string_tripless_t_decrease_by(status, tripless, amount) status = f_utf_string_tripless_decrease_by(amount, tripless); - #define macro_f_utf_string_tripless_t_decimate_by(status, tripless, amount) status = f_utf_string_tripless_decimate_by(amount, tripless); -#endif // _di_f_utf_string_tripless_t_ - -/** - * Resize the string triples array. - * - * @param length - * The new size to use. - * @param triples - * The string triples array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_utf_string_triples_adjust_ - extern f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_adjust_ - -/** - * Append the single source triples onto the destination. - * - * @param source - * The source triple to append. - * @param destination - * The destination triples the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_append_ - extern f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination); -#endif // _di_f_utf_string_triples_append_ - -/** - * Append the source triples onto the destination. - * - * @param source - * The source triples to append. - * @param destination - * The destination triples the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_append_all_ - extern f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination); -#endif // _di_f_utf_string_triples_append_all_ - -/** - * Resize the string triples array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param triples - * The string triples array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_decimate_by_ - extern f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_decimate_by_ - -/** - * Resize the string triples array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param triples - * The string triples array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_decrease_by_ - extern f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_decrease_by_ - -/** - * Increase the size of the string triples array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param triples - * The string triples array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_increase_ - extern f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_increase_ - -/** - * Resize the string triples array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param triples - * The string triples array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_increase_by_ - extern f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_increase_by_ - -/** - * Resize the string triples array. - * - * @param length - * The new size to use. - * @param triples - * The string triples array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_triples_resize_ - extern f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples); -#endif // _di_f_utf_string_triples_resize_ - -/** - * Resize the string tripless array. - * - * @param length - * The new size to use. - * @param tripless - * The string tripless array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_utf_string_tripless_adjust_ - extern f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_adjust_ - -/** - * Append the single source triples onto the destination. - * - * @param source - * The source triples to append. - * @param destination - * The destination tripless the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_append_ - extern f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination); -#endif // _di_f_utf_string_tripless_append_ - -/** - * Append the source tripless onto the destination. - * - * @param source - * The source tripless to append. - * @param destination - * The destination tripless the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_append_all_ - extern f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination); -#endif // _di_f_utf_string_tripless_append_all_ - -/** - * Resize the string tripless array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param tripless - * The string tripless array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_decimate_by_ - extern f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_decimate_by_ - -/** - * Resize the string tripless array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param tripless - * The string tripless array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_decrease_by_ - extern f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_decrease_by_ - -/** - * Increase the size of the string tripless array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param tripless - * The string tripless array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_increase_ - extern f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_increase_ - -/** - * Resize the string tripless array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param tripless - * The string tripless array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_increase_by_ - extern f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_increase_by_ - -/** - * Resize the string tripless array. - * - * @param length - * The new size to use. - * @param tripless - * The string tripless array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_tripless_resize_ - extern f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless); -#endif // _di_f_utf_string_tripless_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/triples.c b/level_0/f_utf/c/utf/triples.c new file mode 100644 index 0000000..946307e --- /dev/null +++ b/level_0/f_utf/c/utf/triples.c @@ -0,0 +1,185 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-string.h" +#include "private-triples.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_triples_adjust_ + f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_triples_adjust(length, triples); + } +#endif // _di_f_utf_string_triples_adjust_ + +#ifndef _di_f_utf_string_triples_append_ + f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_triples_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.a.used) { + status = private_f_utf_string_append(source.a.string, source.a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.b.used) { + status = private_f_utf_string_append(source.b.string, source.b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.c.used) { + status = private_f_utf_string_append(source.c.string, source.c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_triples_append_ + +#ifndef _di_f_utf_string_triples_append_all_ + f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_triples_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.array[i].a.used) { + status = private_f_utf_string_append(source.array[i].a.string, source.array[i].a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].b.used) { + status = private_f_utf_string_append(source.array[i].b.string, source.array[i].b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].c.used) { + status = private_f_utf_string_append(source.array[i].c.string, source.array[i].c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_triples_append_all_ + +#ifndef _di_f_utf_string_triples_decimate_by_ + f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (triples->size > amount) { + return private_f_utf_string_triples_adjust(triples->size - amount, triples); + } + + return private_f_utf_string_triples_adjust(0, triples); + } +#endif // _di_f_utf_string_triples_decimate_by_ + +#ifndef _di_f_utf_string_triples_decrease_by_ + f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (triples->size > amount) { + return private_f_utf_string_triples_resize(triples->size - amount, triples); + } + + return private_f_utf_string_triples_resize(0, triples); + } +#endif // _di_f_utf_string_triples_decrease_by_ + +#ifndef _di_f_utf_string_triples_increase_ + f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && triples->used + 1 > triples->size) { + f_array_length_t size = triples->used + F_memory_default_allocation_small_d; + + if (size > F_array_length_t_size_d) { + if (triples->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_triples_resize(size, triples); + } + + return F_data_not; + } +#endif // _di_f_utf_string_triples_increase_ + +#ifndef _di_f_utf_string_triples_increase_by_ + f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (triples->used + amount > triples->size) { + if (triples->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_triples_resize(triples->used + amount, triples); + } + + return F_data_not; + } +#endif // _di_f_utf_string_triples_increase_by_ + +#ifndef _di_f_utf_string_triples_resize_ + f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_triples_resize(length, triples); + } +#endif // _di_f_utf_string_triples_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/triples.h b/level_0/f_utf/c/utf/triples.h new file mode 100644 index 0000000..ad116a1 --- /dev/null +++ b/level_0/f_utf/c/utf/triples.h @@ -0,0 +1,234 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines 3-tuple of UTF-8 string data called a triple (which is an ordered list of 3 strings). + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_triples_h +#define _F_utf_triples_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string triples. + * + * array: The array of string triples. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_triples_t_ + typedef struct { + f_utf_string_triple_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_triples_t; + + #define f_utf_string_triples_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_triples_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_triples_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_triples_t_clear(triples) macro_f_memory_structure_clear(triples) + + #define macro_f_utf_string_triples_t_resize(status, triples, length) status = f_utf_string_triples_resize(length, &triples); + #define macro_f_utf_string_triples_t_adjust(status, triples, length) status = f_utf_string_triples_adjust(length, &triples); + + #define macro_f_utf_string_triples_t_delete_simple(triples) f_utf_string_triples_resize(0, &triples); + #define macro_f_utf_string_triples_t_destroy_simple(triples) f_utf_string_triples_adjust(0, &triples); + + #define macro_f_utf_string_triples_t_increase(status, step, triples) status = f_utf_string_triples_increase(step, triples); + #define macro_f_utf_string_triples_t_increase_by(status, triples, amount) status = f_utf_string_triples_increase_by(amount, triples); + #define macro_f_utf_string_triples_t_decrease_by(status, triples, amount) status = f_utf_string_triples_decrease_by(amount, triples); + #define macro_f_utf_string_triples_t_decimate_by(status, triples, amount) status = f_utf_string_triples_decimate_by(amount, triples); +#endif // _di_f_utf_string_triples_t_ + +/** + * Resize the string triples array. + * + * @param length + * The new size to use. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_adjust_ + extern f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_adjust_ + +/** + * Append the single source triples onto the destination. + * + * @param source + * The source triple to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_append_ + extern f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination); +#endif // _di_f_utf_string_triples_append_ + +/** + * Append the source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_append_all_ + extern f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination); +#endif // _di_f_utf_string_triples_append_all_ + +/** + * Resize the string triples array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_decimate_by_ + extern f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_decimate_by_ + +/** + * Resize the string triples array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_decrease_by_ + extern f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_decrease_by_ + +/** + * Increase the size of the string triples array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_increase_ + extern f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_increase_ + +/** + * Resize the string triples array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_increase_by_ + extern f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_increase_by_ + +/** + * Resize the string triples array. + * + * @param length + * The new size to use. + * @param triples + * The string triples array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_resize_ + extern f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples); +#endif // _di_f_utf_string_triples_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_triples_h diff --git a/level_0/f_utf/c/utf/tripless.c b/level_0/f_utf/c/utf/tripless.c new file mode 100644 index 0000000..9d0b475 --- /dev/null +++ b/level_0/f_utf/c/utf/tripless.c @@ -0,0 +1,166 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-string.h" +#include "private-triples.h" +#include "private-tripless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_tripless_append_ + f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_tripless_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_triples_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_tripless_append_ + +#ifndef _di_f_utf_string_tripless_append_all_ + f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_tripless_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_triples_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_tripless_append_all_ + +#ifndef _di_f_utf_string_tripless_adjust_ + f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_tripless_adjust(length, tripless); + } +#endif // _di_f_utf_string_tripless_adjust_ + +#ifndef _di_f_utf_string_tripless_decimate_by_ + f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->size > amount) { + return private_f_utf_string_tripless_adjust(tripless->size - amount, tripless); + } + + return private_f_utf_string_tripless_adjust(0, tripless); + } +#endif // _di_f_utf_string_tripless_decimate_by_ + +#ifndef _di_f_utf_string_tripless_decrease_by_ + f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->size > amount) { + return private_f_utf_string_tripless_resize(tripless->size - amount, tripless); + } + + return private_f_utf_string_tripless_resize(0, tripless); + } +#endif // _di_f_utf_string_tripless_decrease_by_ + +#ifndef _di_f_utf_string_tripless_increase_ + f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && tripless->used + 1 > tripless->size) { + f_array_length_t size = tripless->used + step; + + if (size > F_array_length_t_size_d) { + if (tripless->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_tripless_resize(size, tripless); + } + + return F_data_not; + } +#endif // _di_f_utf_string_tripless_increase_ + +#ifndef _di_f_utf_string_tripless_increase_by_ + f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->used + amount > tripless->size) { + if (tripless->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_tripless_resize(tripless->used + amount, tripless); + } + + return F_data_not; + } +#endif // _di_f_utf_string_tripless_increase_by_ + +#ifndef _di_f_utf_string_tripless_resize_ + f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_tripless_resize(length, tripless); + } +#endif // _di_f_utf_string_tripless_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/tripless.h b/level_0/f_utf/c/utf/tripless.h new file mode 100644 index 0000000..45cf155 --- /dev/null +++ b/level_0/f_utf/c/utf/tripless.h @@ -0,0 +1,234 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines 3-tuple of UTF-8 string data called a triple (which is an ordered list of 3 strings). + * + * This is auto-included by utf.h and should not need to be explicitly included. + */ +#ifndef _F_utf_tripless_h +#define _F_utf_tripless_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An array of string tripless. + * + * array: The array of string triples. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_tripless_t_ + typedef struct { + f_utf_string_triples_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_tripless_t; + + #define f_utf_string_tripless_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_tripless_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_tripless_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) + + #define macro_f_utf_string_tripless_t_resize(status, tripless, length) status = f_utf_string_tripless_resize(length, &tripless); + #define macro_f_utf_string_tripless_t_adjust(status, tripless, length) status = f_utf_string_tripless_adjust(length, &tripless); + + #define macro_f_utf_string_tripless_t_delete_simple(tripless) f_utf_string_tripless_resize(0, &tripless); + #define macro_f_utf_string_tripless_t_destroy_simple(tripless) f_utf_string_tripless_adjust(0, &tripless); + + #define macro_f_utf_string_tripless_t_increase(status, step, tripless) status = f_utf_string_tripless_increase(step, tripless); + #define macro_f_utf_string_tripless_t_increase_by(status, tripless, amount) status = f_utf_string_tripless_increase_by(amount, tripless); + #define macro_f_utf_string_tripless_t_decrease_by(status, tripless, amount) status = f_utf_string_tripless_decrease_by(amount, tripless); + #define macro_f_utf_string_tripless_t_decimate_by(status, tripless, amount) status = f_utf_string_tripless_decimate_by(amount, tripless); +#endif // _di_f_utf_string_tripless_t_ + +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_tripless_adjust_ + extern f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_adjust_ + +/** + * Append the single source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_append_ + extern f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination); +#endif // _di_f_utf_string_tripless_append_ + +/** + * Append the source tripless onto the destination. + * + * @param source + * The source tripless to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_append_all_ + extern f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination); +#endif // _di_f_utf_string_tripless_append_all_ + +/** + * Resize the string tripless array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_decimate_by_ + extern f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_decimate_by_ + +/** + * Resize the string tripless array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_decrease_by_ + extern f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_decrease_by_ + +/** + * Increase the size of the string tripless array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_increase_ + extern f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_increase_ + +/** + * Resize the string tripless array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_increase_by_ + extern f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_increase_by_ + +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_resize_ + extern f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_tripless_h diff --git a/level_0/f_utf/data/build/settings b/level_0/f_utf/data/build/settings index 46f0406..a330297 100644 --- a/level_0/f_utf/data/build/settings +++ b/level_0/f_utf/data/build/settings @@ -21,11 +21,10 @@ build_libraries -lc build_libraries-individual -lf_memory -lf_string build_sources_library utf.c private-utf.c private-utf_alphabetic.c private-utf_combining.c private-utf_control.c private-utf_digit.c private-utf_emoji.c private-utf_numeric.c private-utf_phonetic.c private-utf_private.c private-utf_punctuation.c private-utf_subscript.c private-utf_superscript.c private-utf_symbol.c private-utf_unassigned.c private-utf_valid.c private-utf_whitespace.c private-utf_wide.c private-utf_word.c private-utf_zero_width.c -build_sources_library utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/map_multi.c utf/static.c utf/string.c utf/triple.c -build_sources_library utf/private-dynamic.c utf/private-map.c utf/private-map_multi.c utf/private-string.c utf/private-triple.c +build_sources_library utf/common.c utf/convert.c utf/dynamic.c utf/dynamics.c utf/dynamicss.c utf/is.c utf/is_character.c utf/map.c utf/maps.c utf/mapss.c utf/map_multi.c utf/map_multis.c utf/map_multiss.c utf/static.c utf/statics.c utf/staticss.c utf/string.c utf/triple.c utf/triples.c utf/tripless.c +build_sources_library utf/private-dynamic.c utf/private-dynamics.c utf/private-dynamicss.c utf/private-maps.c utf/private-mapss.c utf/private-map_multis.c utf/private-map_multiss.c utf/private-string.c utf/private-triples.c utf/private-tripless.c -build_sources_headers utf.h -build_sources_headers utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/map_multi.h utf/static.h utf/string.h utf/triple.h +build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/dynamics.h utf/dynamicss.h utf/is.h utf/is_character.h utf/map.h utf/maps.h utf/mapss.h utf/map_multi.h utf/map_multis.h utf/map_multiss.h utf/static.h utf/statics.h utf/staticss.h utf/string.h utf/triple.h utf/triples.h utf/tripless.h build_script yes build_shared yes -- 1.8.3.1