From 169d2db3abae0a23c7a980ec0d8cbad3ff78fcff Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 19 Jun 2020 15:37:16 -0500 Subject: [PATCH] Update: add additional f_fss functions and update documentation Add line counting functions. Remove unnecessary checks against negative values for unsigned numbers. (They are theoretically necessary in that if the type was overwritten to a signed type, but for now just ignore that case.) Finish adding or updating the *_together functions. Review and update the documentation. --- level_0/f_fss/c/fss.c | 87 ++++++++++++++++++------ level_0/f_fss/c/fss.h | 46 +++++++++++++ level_1/fl_string/c/string.c | 30 ++++----- level_2/fll_fss/c/fss.c | 155 ++++++++++++++++++++++++++++++++----------- level_2/fll_fss/c/fss.h | 74 +++++++++++---------- 5 files changed, 281 insertions(+), 111 deletions(-) diff --git a/level_0/f_fss/c/fss.c b/level_0/f_fss/c/fss.c index 27acd7e..9f5cb2e 100644 --- a/level_0/f_fss/c/fss.c +++ b/level_0/f_fss/c/fss.c @@ -4,25 +4,75 @@ extern "C" { #endif +#ifndef _di_f_fss_count_lines_ + f_return_status f_fss_count_lines(const f_string_static buffer, const f_string_length before, f_string_length *line) { + #ifndef _di_level_0_parameter_checking_ + if (buffer.used <= 0) return F_status_set_error(F_parameter); + if (before >= buffer.used) return F_status_set_error(F_parameter); + if (line == 0) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_string_length i = before; + + for (; i > 0; i--) { + if (buffer.string[i] == f_string_eol[0]) { + (*line)++; + } + } // for + + if (buffer.string[0] == f_string_eol[0]) { + (*line)++; + } + + return F_none; + } +#endif // _di_f_fss_count_lines_ + +#ifndef _di_f_fss_count_lines_range_ + f_return_status f_fss_count_lines_range(const f_string_static buffer, const f_string_range range, const f_string_length before, f_string_length *line) { + #ifndef _di_level_0_parameter_checking_ + if (buffer.used <= 0) return F_status_set_error(F_parameter); + if (range.start > range.stop) return F_status_set_error(F_parameter); + if (range.start >= buffer.used) return F_status_set_error(F_parameter); + if (before >= buffer.used) return F_status_set_error(F_parameter); + if (before > range.stop) return F_status_set_error(F_parameter); + if (line == 0) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_string_length i = before; + + for (; i > range.start; i--) { + if (buffer.string[i] == f_string_eol[0]) { + (*line)++; + } + } // for + + if (buffer.string[range.start] == f_string_eol[0]) { + (*line)++; + } + + return F_none; + } +#endif // _di_f_fss_count_lines_range_ + #ifndef _di_f_fss_decrement_buffer_ - f_return_status f_fss_decrement_buffer(const f_string_static buffer, f_string_range *location, const f_string_length step) { + f_return_status f_fss_decrement_buffer(const f_string_static buffer, f_string_range *range, const f_string_length step) { #ifndef _di_level_0_parameter_checking_ if (buffer.used <= 0) return F_status_set_error(F_parameter); - if (location->start < 0) return F_status_set_error(F_parameter); - if (location->stop < location->start) return F_status_set_error(F_parameter); - if (location->start >= buffer.used) return F_status_set_error(F_parameter); + if (range->stop < range->start) return F_status_set_error(F_parameter); + if (range->start >= buffer.used) return F_status_set_error(F_parameter); if (step < 1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (location->start < 1) return F_none_eos; + if (range->start < 1) return F_none_eos; f_string_length i = 0; unsigned short width = 0; do { - width = f_macro_utf_byte_width(buffer.string[location->start - 1]); + width = f_macro_utf_byte_width(buffer.string[range->start - 1]); - if (width > location->start) { + if (width > range->start) { if (width > 1) { return F_status_set_error(F_incomplete_utf_eos); } @@ -31,7 +81,7 @@ extern "C" { } i++; - location->start -= width; + range->start -= width; } while (i < step); return F_none; @@ -39,12 +89,11 @@ extern "C" { #endif // _di_f_fss_decrement_buffer_ #ifndef _di_f_fss_increment_buffer_ - f_return_status f_fss_increment_buffer(const f_string_static buffer, f_string_range *location, const f_string_length step) { + f_return_status f_fss_increment_buffer(const f_string_static buffer, f_string_range *range, const f_string_length step) { #ifndef _di_level_0_parameter_checking_ if (buffer.used <= 0) return F_status_set_error(F_parameter); - if (location->start < 0) return F_status_set_error(F_parameter); - if (location->stop < location->start) return F_status_set_error(F_parameter); - if (location->start >= buffer.used) return F_status_set_error(F_parameter); + if (range->stop < range->start) return F_status_set_error(F_parameter); + if (range->start >= buffer.used) return F_status_set_error(F_parameter); if (step < 1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -52,27 +101,27 @@ extern "C" { unsigned short width = 0; do { - width = f_macro_utf_byte_width(buffer.string[location->start]); + width = f_macro_utf_byte_width(buffer.string[range->start]); - if (location->start + width > location->stop) { + if (range->start + width > range->stop) { if (width > 1) { return F_status_set_error(F_incomplete_utf_stop); } - location->start += width; + range->start += width; return F_none_stop; } - else if (location->start + width >= buffer.used) { + else if (range->start + width >= buffer.used) { if (width > 1) { return F_status_set_error(F_incomplete_utf_eos); } - location->start += width; + range->start += width; return F_none_eos; } i++; - location->start += width; + range->start += width; } while (i < step); return F_none; @@ -184,7 +233,6 @@ extern "C" { #ifndef _di_level_0_parameter_checking_ if (buffer.used <= 0) return F_status_set_error(F_parameter); if (range == 0) return F_status_set_error(F_parameter); - if (range->start < 0) return F_status_set_error(F_parameter); if (range->stop < range->start) return F_status_set_error(F_parameter); if (range->start >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -293,7 +341,6 @@ extern "C" { #ifndef _di_level_0_parameter_checking_ if (buffer.used <= 0) return F_status_set_error(F_parameter); if (range == 0) return F_status_set_error(F_parameter); - if (range->start < 0) return F_status_set_error(F_parameter); if (range->stop < range->start) return F_status_set_error(F_parameter); if (range->start >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_fss/c/fss.h b/level_0/f_fss/c/fss.h index ec51474..0983667 100644 --- a/level_0/f_fss/c/fss.h +++ b/level_0/f_fss/c/fss.h @@ -31,6 +31,52 @@ extern "C" { #endif /** + * Count the number of new lines from the buffer before the given location. + * + * Use this to calculate where a given range exists in relation to a line. + * + * This does not initialize line, instead it only performs addition to line. + * + * @param buffer + * The string to process. + * @param before + * The position in the buffer where to start counting before. + * @param line + * The total lines found leading up to but not including before. + * + * @return + * F_none on success. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_fss_count_lines_ + extern f_return_status f_fss_count_lines(const f_string_static buffer, const f_string_length before, f_string_length *line); +#endif // _di_f_fss_count_lines_ + +/** + * Count the number of new lines from the given range in the buffer before the given location. + * + * Use this to calculate where a given range exists in relation to a line. + * + * This does not initialize line, instead it only performs addition to line. + * + * @param buffer + * The string to process. + * @param range + * The range within the buffer to process. + * @param before + * The position in the buffer where to start counting before. + * @param line + * The total lines found leading up to but not including before. + * + * @return + * F_none on success. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_fss_count_lines_range_ + extern f_return_status f_fss_count_lines_range(const f_string_static buffer, const f_string_range range, const f_string_length before, f_string_length *line); +#endif // _di_f_fss_count_lines_range_ + +/** * Continue to the previous character, based on step and character width. * * The start position must be at the start of a valid UTF-8 block. diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index 846507b..62e4079 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -234,7 +234,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { const f_status status = private_fl_string_append(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -251,7 +251,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { const f_status status = private_fl_string_append_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -268,7 +268,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { const f_status status = private_fl_string_prepend(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -285,7 +285,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { const f_status status = private_fl_string_prepend_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -434,7 +434,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_append(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -453,7 +453,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_append_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -472,7 +472,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_prepend(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -491,7 +491,7 @@ extern "C" { if (source.used == 0) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_prepend_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -1031,7 +1031,7 @@ extern "C" { if (destination->used > destination->size) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (destination->used > 0 && destination->string[destination->used - 1] == 0) return F_none; + if (destination->used && destination->string[destination->used - 1] == 0) return F_none; if (destination->used + 1 > f_string_length_size) return F_status_set_error(F_string_too_large); @@ -1058,8 +1058,8 @@ extern "C" { if (destination->used > destination->size) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (destination->used > 0) { - for (; destination->used > 0; destination->used--) { + if (destination->used) { + for (; destination->used; destination->used--) { if (destination->string[destination->used - 1] == 0) continue; break; } // for @@ -1091,7 +1091,7 @@ extern "C" { if (length == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_append(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -1108,7 +1108,7 @@ extern "C" { if (length == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_append_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -1125,7 +1125,7 @@ extern "C" { if (length == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_prepend(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -1142,7 +1142,7 @@ extern "C" { if (length == 0) return F_data_not_eos; - if (glue_length > 0 && destination->used > 0) { + if (glue_length && destination->used) { f_status status = private_fl_string_prepend_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 1485fde..76d7c6f 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -466,8 +466,8 @@ extern "C" { } #endif // _di_fll_fss_snatch_map_mash_apart_ -#ifndef _di_fll_fss_snatch_mash_ - f_return_status fll_fss_snatch_mash(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]) { +#ifndef _di_fll_fss_snatch_map_together_ + f_return_status fll_fss_snatch_map_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_maps *values[]) { #ifndef _di_level_2_parameter_checking_ if (size == 0) return F_status_set_error(F_parameter); if (objects.used != contents.used) return F_status_set_error(F_parameter); @@ -478,42 +478,109 @@ extern "C" { if (contents.used == 0) return F_data_not; f_status status = F_none; - f_string_length length_object = 0; + f_string_length length_name = 0; + f_string_dynamic name = f_string_dynamic_initialize; f_array_length i = 0; f_array_length j = 0; f_array_length k = 0; - bool matched[size]; + bool matched = F_false; - memset(&matched, 0, sizeof(bool) * size); + f_string_map *map = 0; for (; i < objects.used; i++) { - length_object = (objects.array[i].stop - objects.array[i].start) + 1; + if (!contents.array[i].used) continue; - for (j = 0; j < size; j++) { - if (matched[j]) continue; + length_name = (objects.array[i].stop - objects.array[i].start) + 1; - status = fl_string_compare_trim(buffer.string + objects.array[i].start, names[j], length_object, lengths[j]); + for (j = 0; j < size; j++) { + status = fl_string_compare_trim(buffer.string + objects.array[i].start, names[j], length_name, lengths[j]); if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; - matched[j] = F_true; + status = fl_string_dynamic_partial_append_nulless(buffer, contents.array[i].array[0], &name); + if (F_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(name); + return status; + } - for (k = 0; k < contents.array[i].used; k++) { - status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], values[j]); - if (F_status_is_error(status)) return status; + matched = F_false; + length_name = (contents.array[i].array[0].stop - contents.array[i].array[0].start) + 1; + + for (k = 0; k < values[j]->used; k++) { + status = fl_string_compare_trim(buffer.string + contents.array[i].array[0].start, values[j]->array[k].name.string, length_name, values[j]->array[k].name.used); + + if (F_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(name); + return status; + } + + if (status == F_equal_to) { + matched = F_true; + + f_macro_string_dynamic_delete_simple(name); + break; + } } // for + + if (matched) { + name.used = 0; + + map = &values[j]->array[k]; + } + else { + if (values[j]->used + 1 > values[j]->size) { + if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) { + if (values[j]->used + 1 > f_array_length_size) { + f_macro_string_dynamic_delete_simple(name); + return F_status_set_error(F_buffer_too_large); + } + + f_macro_string_maps_resize(status, (*values[j]), values[j]->used + 1); + if (F_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(name); + return status; + } + } + else { + f_macro_string_maps_resize(status, (*values[j]), values[j]->used + f_fss_default_allocation_step); + if (F_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(name); + return status; + } + } + } + + map = &values[j]->array[values[j]->used]; + + map->name.string = name.string; + map->name.used = name.used; + map->name.size = name.size; + + values[j]->used++; + + f_macro_string_dynamic_clear(name); + } + + if (contents.array[i].used > 1) { + status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[1], &map->value); + if (F_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(name); + return status; + } + } } // for } // for + f_macro_string_dynamic_delete_simple(name); return F_none; } -#endif // _di_fll_fss_snatch_mash_ +#endif // _di_fll_fss_snatch_map_together_ -#ifndef _di_fll_fss_snatch_mash_apart_ - f_return_status fll_fss_snatch_mash_apart(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamics *values[]) { +#ifndef _di_fll_fss_snatch_mash_ + f_return_status fll_fss_snatch_mash(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]) { #ifndef _di_level_2_parameter_checking_ if (size == 0) return F_status_set_error(F_parameter); if (objects.used != contents.used) return F_status_set_error(F_parameter); @@ -530,45 +597,36 @@ extern "C" { f_array_length j = 0; f_array_length k = 0; + bool matched[size]; + + memset(&matched, 0, sizeof(bool) * size); + for (; i < objects.used; i++) { length_object = (objects.array[i].stop - objects.array[i].start) + 1; for (j = 0; j < size; j++) { + if (matched[j]) continue; + status = fl_string_compare_trim(buffer.string + objects.array[i].start, names[j], length_object, lengths[j]); if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; - if (values[j]->used + 1 > values[j]->size) { - if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) { - if (values[j]->used + 1 > f_array_length_size) { - return F_status_set_error(F_buffer_too_large); - } - - f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + 1); - if (F_status_is_error(status)) return status; - } - else { - f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + f_fss_default_allocation_step); - if (F_status_is_error(status)) return status; - } - } + matched[j] = F_true; for (k = 0; k < contents.array[i].used; k++) { - status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], &values[j]->array[values[j]->used]); + status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], values[j]); if (F_status_is_error(status)) return status; } // for - - values[j]->used++; } // for } // for return F_none; } -#endif // _di_fll_fss_snatch_mash_apart_ +#endif // _di_fll_fss_snatch_mash_ -#ifndef _di_fll_fss_snatch_mash_together_ - f_return_status fll_fss_snatch_mash_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]) { +#ifndef _di_fll_fss_snatch_mash_apart_ + f_return_status fll_fss_snatch_mash_apart(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamics *values[]) { #ifndef _di_level_2_parameter_checking_ if (size == 0) return F_status_set_error(F_parameter); if (objects.used != contents.used) return F_status_set_error(F_parameter); @@ -594,19 +652,36 @@ extern "C" { if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; + if (values[j]->used + 1 > values[j]->size) { + if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) { + if (values[j]->used + 1 > f_array_length_size) { + return F_status_set_error(F_buffer_too_large); + } + + f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + 1); + if (F_status_is_error(status)) return status; + } + else { + f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + f_fss_default_allocation_step); + if (F_status_is_error(status)) return status; + } + } + for (k = 0; k < contents.array[i].used; k++) { - status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], values[j]); + status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], &values[j]->array[values[j]->used]); if (F_status_is_error(status)) return status; } // for + + values[j]->used++; } // for } // for return F_none; } -#endif // _di_fll_fss_snatch_mash_together_ +#endif // _di_fll_fss_snatch_mash_apart_ #ifndef _di_fll_fss_snatch_together_ - f_return_status fll_fss_snatch_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, f_string_dynamic *values[]) { + f_return_status fll_fss_snatch_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]) { #ifndef _di_level_2_parameter_checking_ if (size == 0) return F_status_set_error(F_parameter); if (objects.used != contents.used) return F_status_set_error(F_parameter); @@ -633,7 +708,7 @@ extern "C" { if (status == F_equal_to_not) continue; for (k = 0; k < contents.array[i].used; k++) { - status = fl_string_dynamic_partial_append_nulless(buffer, contents.array[i].array[k], values[j]); + status = fl_string_dynamic_partial_mash_nulless(glue, glue_length, buffer, contents.array[i].array[k], values[j]); if (F_status_is_error(status)) return status; } // for } // for diff --git a/level_2/fll_fss/c/fss.h b/level_2/fll_fss/c/fss.h index 7714daa..c3299e1 100644 --- a/level_2/fll_fss/c/fss.h +++ b/level_2/fll_fss/c/fss.h @@ -298,19 +298,22 @@ extern "C" { * Errors from (with error bit): fl_string_dynamic_partial_append_nulless(). * * @see fl_string_compare_trim() - * @see fl_string_dynamic_partial_append_nulless() + * @see fl_string_dynamic_partial_mash_nulless() */ #ifndef _di_fll_fss_snatch_map_mash_apart_ extern f_return_status fll_fss_snatch_map_mash_apart(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_map_multis *values[]); -#endif // _di_fll_fss_snatch_map_mash_apart_ +#endif // _di_fll_fss_snatch_map_mash_apart__ /** - * Perform simple search through all objects against the given set, saving all values when matched. + * Perform simple search through all objects against the given set, saving all values to a map when matched. * - * Only the first match for each distinct object is snatched. - * All content for each object is snatched. + * All matches for each distinct object and map name is snatched. + * All content map values for each distinct object and map name is snatched. * - * Multiple contents for a single object are appended using the provided glue. + * The first content is considered the map name, all other content are considered a map value. + * Multiple contents, after the first, for each distinct object and map names are appended to a single map value string using the provided glue (map names are therefore distinct). + * + * This will ignore any object that has no map name. * * This will trim the object names when comparing (removing leading/trailing whitespace). * This will strip NULL characters when copying. @@ -332,9 +335,9 @@ extern "C" { * @param glue * A string to append between each duplicate name found when "snatching". * @param glue_length - * The length of the glue string. + * The length of the glue string * @param values - * An array of values where "snatched" content is stored. + * An array of map arrays where "snatched" content is stored. * * @return * F_none on success. @@ -342,20 +345,22 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors from (with error bit): fl_string_compare_trim(). - * Errors from (with error bit): fl_string_dynamic_partial_mash_nulless(). + * Errors from (with error bit): fl_string_dynamic_partial_append_nulless(). + * + * @see fl_string_compare_trim() + * @see fl_string_dynamic_partial_mash_nulless() */ -#ifndef _di_fll_fss_snatch_mash_ - extern f_return_status fll_fss_snatch_mash(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]); -#endif // _di_fll_fss_snatch_mash_ +#ifndef _di_fll_fss_snatch_map_together_ + extern f_return_status fll_fss_snatch_map_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_maps *values[]); +#endif // _di_fll_fss_snatch_map_together_ /** * Perform simple search through all objects against the given set, saving all values when matched. * - * All matches for each object is snatched. + * Only the first match for each distinct object is snatched. * All content for each object is snatched. * * Multiple contents for a single object are appended using the provided glue. - * Content for multiple identical objects are added in separate strings from other objects. * * This will trim the object names when comparing (removing leading/trailing whitespace). * This will strip NULL characters when copying. @@ -377,7 +382,7 @@ extern "C" { * @param glue * A string to append between each duplicate name found when "snatching". * @param glue_length - * The length of the glue string + * The length of the glue string. * @param values * An array of values where "snatched" content is stored. * @@ -387,29 +392,26 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors from (with error bit): fl_string_compare_trim(). - * Errors from (with error bit): fl_string_dynamic_partial_append_nulless(). - * - * @see fl_string_compare_trim() - * @see fl_string_dynamic_partial_append_nulless() + * Errors from (with error bit): fl_string_dynamic_partial_mash_nulless(). */ -#ifndef _di_fll_fss_snatch_mash_apart_ - extern f_return_status fll_fss_snatch_mash_apart(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamics *values[]); -#endif // _di_fll_fss_snatch_mash_apart_ +#ifndef _di_fll_fss_snatch_mash_ + extern f_return_status fll_fss_snatch_mash(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]); +#endif // _di_fll_fss_snatch_mash_ /** * Perform simple search through all objects against the given set, saving all values when matched. * * All matches for each object is snatched. + * All content for each object is snatched. + * * Multiple contents for a single object are appended using the provided glue. - * Content for multiple identical objects are appended using the provided glue. + * Content for multiple identical objects are added in separate strings from other objects. * * This will trim the object names when comparing (removing leading/trailing whitespace). * This will strip NULL characters when copying. * * This performs only a simple search algorithm that should be acceptable for small sets where performance is generally not a concern. * - * @fixme redesign to match all based on content column, mash each value by glue for each column, and finally mash each column into the final dynamic value. - * * @param buffer * The buffer to read from. * @param objects @@ -425,7 +427,7 @@ extern "C" { * @param glue * A string to append between each duplicate name found when "snatching". * @param glue_length - * The length of the glue string. + * The length of the glue string * @param values * An array of values where "snatched" content is stored. * @@ -435,26 +437,26 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors from (with error bit): fl_string_compare_trim(). - * Errors from (with error bit): fl_string_dynamic_partial_mash_nulless(). + * Errors from (with error bit): fl_string_dynamic_partial_append_nulless(). + * + * @see fl_string_compare_trim() + * @see fl_string_dynamic_partial_mash_nulless() */ -#ifndef _di_fll_fss_snatch_mash_together_ - extern f_return_status fll_fss_snatch_mash_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]); -#endif // _di_fll_fss_snatch_mash_together_ +#ifndef _di_fll_fss_snatch_mash_apart_ + extern f_return_status fll_fss_snatch_mash_apart(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamics *values[]); +#endif // _di_fll_fss_snatch_mash_apart_ /** * Perform simple search through all objects against the given set, saving all values when matched. * * All matches for each object is snatched. - * Multiple contents for a single object are appended. - * Content for multiple identical objects are appended. + * Multiple contents for all objects are appended using the provided glue. * * This will trim the object names when comparing (removing leading/trailing whitespace). * This will strip NULL characters when copying. * * This performs only a simple search algorithm that should be acceptable for small sets where performance is generally not a concern. * - * @fixme redesign to match all based on content column, mash each value by glue for each column, storing them as separate content string. - * * @param buffer * The buffer to read from. * @param objects @@ -476,13 +478,13 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors from (with error bit): fl_string_compare_trim(). - * Errors from (with error bit): fl_string_dynamic_partial_append_nulless(). + * Errors from (with error bit): fl_string_dynamic_partial_mash_nulless(). * * @see fl_string_compare_trim() * @see fl_string_dynamic_partial_append_nulless() */ #ifndef _di_fll_fss_snatch_together_ - extern f_return_status fll_fss_snatch_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, f_string_dynamic *values[]); + extern f_return_status fll_fss_snatch_together(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, const f_string glue, const f_string_length glue_length, f_string_dynamic *values[]); #endif // _di_fll_fss_snatch_together_ #ifdef __cplusplus -- 1.8.3.1