From: Kevin Day Date: Sat, 8 May 2021 01:11:19 +0000 (-0500) Subject: Feature: Add support for determining columns in FSS Read programs. X-Git-Tag: 0.5.4~37 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f7056262023d02ebb6dc2091f66ec0b8279336ee;p=fll Feature: Add support for determining columns in FSS Read programs. Implement a new feature for determining how many columns total are available for some Content. Update the specifications accordingly. The term "columns" has been added to designate this concept of the now of column sets within some Content. Previously, this was weakly named. The select functionality "--select" allows for selecting these columns but there has been no way to know how many columns exist. This is not a good design for scripting and similar usage. By providing a total number of columns, the select function becomes more complete and useful. When columns is specified without any particular Object specified, then the maximum columns length for all Content is printed. --- diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index d3b2cf3..f5299f3 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -25,6 +25,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_basic_list_read_short_at, fss_basic_list_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); fll_program_print_help_option(output, context, fss_basic_list_read_short_content, fss_basic_list_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(output, context, fss_basic_list_read_short_columns, fss_basic_list_read_long_columns, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); fll_program_print_help_option(output, context, fss_basic_list_read_short_delimit, fss_basic_list_read_long_delimit, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); fll_program_print_help_option(output, context, fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); fll_program_print_help_option(output, context, fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); @@ -81,8 +82,7 @@ extern "C" { fprintf(output.stream, " The parameter "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_read_long_select); - fprintf(output.stream, " selects a Content index at a given depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " (This parameter is not synonymous with the depth parameter and does not relate to nested Content).%c", f_string_eol_s[0]); + fprintf(output.stream, " selects a Content column.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -177,6 +177,16 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); + fprintf(output.stream, " The parameters "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_read_long_columns); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_read_long_select); + fprintf(output.stream, " refer to a Content column.%c", f_string_eol_s[0]); + fprintf(output.stream, " The word \"column\" is being loosely defined to refer to a specific Content.%c", f_string_eol_s[0]); + fprintf(output.stream, " This is not to be confused with a depth.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + return F_none; } #endif // _di_fss_basic_list_read_print_help_ @@ -311,6 +321,46 @@ extern "C" { } // for } + if (F_status_is_error_not(status) && main->parameters[fss_basic_list_read_parameter_columns].result == f_console_result_found) { + const f_array_length_t parameter_code[] = { + fss_basic_list_read_parameter_depth, + fss_basic_list_read_parameter_line, + fss_basic_list_read_parameter_pipe, + fss_basic_list_read_parameter_select, + fss_basic_list_read_parameter_total, + }; + + const f_string_t parameter_name[] = { + fss_basic_list_read_long_depth, + fss_basic_list_read_long_line, + fss_basic_list_read_long_pipe, + fss_basic_list_read_long_select, + fss_basic_list_read_long_total, + }; + + const uint8_t parameter_match[] = { + f_console_result_additional, + f_console_result_additional, + f_console_result_found, + f_console_result_additional, + f_console_result_found, + }; + + for (f_array_length_t i = 0; i < 5; ++i) { + + if (main->parameters[parameter_code[i]].result == parameter_match[i]) { + f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_read_long_columns); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, parameter_name[i]); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + + status = F_status_set_error(F_parameter); + break; + } + } // for + } + if (F_status_is_error_not(status) && main->parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) { if (main->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); @@ -321,7 +371,7 @@ extern "C" { status = F_status_set_error(F_parameter); } - else if (main->parameters[fss_basic_list_read_parameter_line].result == f_console_result_found) { + else if (main->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_read_long_pipe); f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index f89640e..7880e5f 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -68,6 +68,7 @@ extern "C" { #define fss_basic_list_read_short_at "a" #define fss_basic_list_read_short_content "c" + #define fss_basic_list_read_short_columns "C" #define fss_basic_list_read_short_delimit "D" #define fss_basic_list_read_short_depth "d" #define fss_basic_list_read_short_empty "e" @@ -81,6 +82,7 @@ extern "C" { #define fss_basic_list_read_long_at "at" #define fss_basic_list_read_long_content "content" + #define fss_basic_list_read_long_columns "columns" #define fss_basic_list_read_long_delimit "delimit" #define fss_basic_list_read_long_depth "depth" #define fss_basic_list_read_long_empty "empty" @@ -105,6 +107,7 @@ extern "C" { fss_basic_list_read_parameter_at, fss_basic_list_read_parameter_content, + fss_basic_list_read_parameter_columns, fss_basic_list_read_parameter_delimit, fss_basic_list_read_parameter_depth, fss_basic_list_read_parameter_empty, @@ -130,6 +133,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_list_read_short_at, fss_basic_list_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_content, fss_basic_list_read_long_content, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_columns, fss_basic_list_read_long_columns, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_delimit, fss_basic_list_read_long_delimit, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, 0, 0, f_console_type_normal), \ @@ -142,7 +146,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_basic_list_read_total_parameters 21 + #define fss_basic_list_read_total_parameters 22 #endif // _di_fss_basic_list_read_defines_ /** diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h index 692ae8a..ad90a27 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -117,6 +117,7 @@ extern "C" { * * fss_basic_list_read_data_option_*: * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. * - content: The Content is to be printed. * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). @@ -141,14 +142,15 @@ extern "C" { */ #ifndef _di_fss_basic_list_read_data_t_ #define fss_basic_list_read_data_option_at 0x1 - #define fss_basic_list_read_data_option_content 0x2 - #define fss_basic_list_read_data_option_empty 0x4 - #define fss_basic_list_read_data_option_line 0x8 - #define fss_basic_list_read_data_option_name 0x10 - #define fss_basic_list_read_data_option_object 0x20 - #define fss_basic_list_read_data_option_select 0x40 - #define fss_basic_list_read_data_option_total 0x80 - #define fss_basic_list_read_data_option_trim 0x100 + #define fss_basic_list_read_data_option_columns 0x2 + #define fss_basic_list_read_data_option_content 0x4 + #define fss_basic_list_read_data_option_empty 0x8 + #define fss_basic_list_read_data_option_line 0x10 + #define fss_basic_list_read_data_option_name 0x20 + #define fss_basic_list_read_data_option_object 0x40 + #define fss_basic_list_read_data_option_select 0x80 + #define fss_basic_list_read_data_option_total 0x100 + #define fss_basic_list_read_data_option_trim 0x200 typedef struct { uint16_t option; diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 336cdea..54e0908 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -399,6 +399,10 @@ extern "C" { return fss_basic_list_read_process_at(main, data, names); } + if (data->option & fss_basic_list_read_data_option_columns) { + return fss_basic_list_read_process_columns(main, data, names); + } + if (data->option & fss_basic_list_read_data_option_total) { return fss_basic_list_read_process_total(main, data, names); } @@ -426,10 +430,7 @@ extern "C" { f_status_t fss_basic_list_read_process_at(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (!data->objects.used) { - fss_extended_list_read_print_zero(main); - } - else if (names[data->depths.array[0].value_at] && (data->option & fss_basic_list_read_data_option_total)) { + if (data->option & (fss_basic_list_read_data_option_columns | fss_basic_list_read_data_option_total)) { fss_basic_list_read_print_zero(main); } @@ -454,6 +455,9 @@ extern "C" { status = fss_basic_list_read_process_at_line(at, *delimits_object, *delimits_content, main, data, &line); if (status == F_success) return F_none; } + else if (data->option & fss_basic_list_read_data_option_columns) { + fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + } else if (data->option & fss_basic_list_read_data_option_total) { if (data->contents.array[i].used) { fss_basic_list_read_print_one(main); @@ -480,6 +484,32 @@ extern "C" { } #endif // _di_fss_basic_list_read_process_at_ +#ifndef _di_fss_basic_list_read_process_columns_ + f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) { + + if (!(data->option & fss_basic_list_read_data_option_content)) { + fss_basic_list_read_print_zero(main); + + return F_none; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_basic_list_read_process_columns_ + #ifndef _di_fss_basic_list_read_process_at_line_ f_status_t fss_basic_list_read_process_at_line(const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, f_array_length_t *line) { @@ -620,6 +650,10 @@ extern "C" { data->option |= fss_basic_list_read_data_option_at; } + if (main->parameters[fss_basic_list_read_parameter_columns].result == f_console_result_found) { + data->option |= fss_basic_list_read_data_option_columns; + } + if (main->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) { data->option |= fss_basic_list_read_data_option_content; } diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h index 33e75d7..84b7040 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h @@ -283,6 +283,24 @@ extern "C" { #endif // _di_fss_basic_list_read_process_at_ /** + * Process based on columns parameter. + * + * @param main + * The main data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_list_read_process_columns_ + extern f_status_t fss_basic_list_read_process_columns(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data, bool names[]) f_attribute_visibility_internal; +#endif // _di_fss_basic_list_read_process_columns_ + +/** * Process based on at parameter for some line. * * @param main diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index eb0a331..0d3a8f2 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -25,6 +25,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); fll_program_print_help_option(output, context, fss_basic_read_short_content, fss_basic_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(output, context, fss_basic_read_short_columns, fss_basic_read_long_columns, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); fll_program_print_help_option(output, context, fss_basic_read_short_delimit, fss_basic_read_long_delimit, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); fll_program_print_help_option(output, context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); fll_program_print_help_option(output, context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); @@ -81,8 +82,7 @@ extern "C" { fprintf(output.stream, " The parameter "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_select); - fprintf(output.stream, " selects a Content index at a given depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " (This parameter is not synonymous with the depth parameter and does not relate to nested Content).%c", f_string_eol_s[0]); + fprintf(output.stream, " selects a Content column.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -177,6 +177,16 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); + fprintf(output.stream, " The parameters "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_columns); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_select); + fprintf(output.stream, " refer to a Content column.%c", f_string_eol_s[0]); + fprintf(output.stream, " The word \"column\" is being loosely defined to refer to a specific Content.%c", f_string_eol_s[0]); + fprintf(output.stream, " This is not to be confused with a depth.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + return F_none; } #endif // _di_fss_basic_read_print_help_ @@ -311,6 +321,46 @@ extern "C" { } // for } + if (F_status_is_error_not(status) && main->parameters[fss_basic_read_parameter_columns].result == f_console_result_found) { + const f_array_length_t parameter_code[] = { + fss_basic_read_parameter_depth, + fss_basic_read_parameter_line, + fss_basic_read_parameter_pipe, + fss_basic_read_parameter_select, + fss_basic_read_parameter_total, + }; + + const f_string_t parameter_name[] = { + fss_basic_read_long_depth, + fss_basic_read_long_line, + fss_basic_read_long_pipe, + fss_basic_read_long_select, + fss_basic_read_long_total, + }; + + const uint8_t parameter_match[] = { + f_console_result_additional, + f_console_result_additional, + f_console_result_found, + f_console_result_additional, + f_console_result_found, + }; + + for (f_array_length_t i = 0; i < 5; ++i) { + + if (main->parameters[parameter_code[i]].result == parameter_match[i]) { + f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_columns); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, parameter_name[i]); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + + status = F_status_set_error(F_parameter); + break; + } + } // for + } + if (F_status_is_error_not(status) && main->parameters[fss_basic_read_parameter_pipe].result == f_console_result_found) { if (main->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index 1f65a66..c809741 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -68,6 +68,7 @@ extern "C" { #define fss_basic_read_short_at "a" #define fss_basic_read_short_content "c" + #define fss_basic_read_short_columns "C" #define fss_basic_read_short_delimit "D" #define fss_basic_read_short_depth "d" #define fss_basic_read_short_empty "e" @@ -81,6 +82,7 @@ extern "C" { #define fss_basic_read_long_at "at" #define fss_basic_read_long_content "content" + #define fss_basic_read_long_columns "columns" #define fss_basic_read_long_delimit "delimit" #define fss_basic_read_long_depth "depth" #define fss_basic_read_long_empty "empty" @@ -105,6 +107,7 @@ extern "C" { fss_basic_read_parameter_at, fss_basic_read_parameter_content, + fss_basic_read_parameter_columns, fss_basic_read_parameter_delimit, fss_basic_read_parameter_depth, fss_basic_read_parameter_empty, @@ -130,6 +133,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_read_short_at, fss_basic_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_content, fss_basic_read_long_content, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_read_short_columns, fss_basic_read_long_columns, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_delimit, fss_basic_read_long_delimit, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_depth, fss_basic_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_empty, fss_basic_read_long_empty, 0, 0, f_console_type_normal), \ @@ -142,7 +146,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_read_short_trim, fss_basic_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_basic_read_total_parameters 21 + #define fss_basic_read_total_parameters 22 #endif // _di_fss_basic_read_defines_ /** diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index 6dd3dfd..4d3934d 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -117,6 +117,7 @@ extern "C" { * * fss_basic_read_data_option_*: * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. * - content: The Content is to be printed. * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). @@ -140,14 +141,15 @@ extern "C" { */ #ifndef _di_fss_basic_read_data_t_ #define fss_basic_read_data_option_at 0x1 - #define fss_basic_read_data_option_content 0x2 - #define fss_basic_read_data_option_empty 0x4 - #define fss_basic_read_data_option_line 0x8 - #define fss_basic_read_data_option_name 0x10 - #define fss_basic_read_data_option_object 0x20 - #define fss_basic_read_data_option_select 0x40 - #define fss_basic_read_data_option_total 0x80 - #define fss_basic_read_data_option_trim 0x100 + #define fss_basic_read_data_option_columns 0x2 + #define fss_basic_read_data_option_content 0x4 + #define fss_basic_read_data_option_empty 0x8 + #define fss_basic_read_data_option_line 0x10 + #define fss_basic_read_data_option_name 0x20 + #define fss_basic_read_data_option_object 0x40 + #define fss_basic_read_data_option_select 0x80 + #define fss_basic_read_data_option_total 0x100 + #define fss_basic_read_data_option_trim 0x200 typedef struct { uint16_t option; diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 514a482..7131b3c 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -344,6 +344,10 @@ extern "C" { return fss_basic_read_process_at(main, data, names); } + if (data->option & fss_basic_read_data_option_columns) { + return fss_basic_read_process_columns(main, data, names); + } + if (data->option & fss_basic_read_data_option_total) { return fss_basic_read_process_total(main, data, names); } @@ -370,10 +374,7 @@ extern "C" { f_status_t fss_basic_read_process_at(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (!data->objects.used) { - fss_extended_list_read_print_zero(main); - } - else if (names[data->depths.array[0].value_at] && (data->option & fss_basic_read_data_option_total)) { + if (data->option & (fss_basic_read_data_option_columns | fss_basic_read_data_option_total)) { fss_basic_read_print_zero(main); } @@ -413,6 +414,9 @@ extern "C" { fss_basic_read_print_at(i, *delimits, except_none, main, data); } } + else if (data->option & fss_basic_read_data_option_columns) { + fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + } else if (data->option & fss_basic_read_data_option_total) { if (data->contents.array[i].used) { fss_basic_read_print_one(main); @@ -439,6 +443,32 @@ extern "C" { } #endif // _di_fss_basic_read_process_at_ +#ifndef _di_fss_basic_read_process_columns_ + f_status_t fss_basic_read_process_columns(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { + + if (!(data->option & fss_basic_read_data_option_content)) { + fss_basic_read_print_zero(main); + + return F_none; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_basic_read_process_columns_ + #ifndef _di_fss_basic_read_process_line_ f_status_t fss_basic_read_process_line(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { @@ -524,6 +554,10 @@ extern "C" { data->option |= fss_basic_read_data_option_at; } + if (main->parameters[fss_basic_read_parameter_columns].result == f_console_result_found) { + data->option |= fss_basic_read_data_option_columns; + } + if (main->parameters[fss_basic_read_parameter_content].result == f_console_result_found) { data->option |= fss_basic_read_data_option_content; } diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.h b/level_3/fss_basic_read/c/private-fss_basic_read.h index 8d5d941..b2d3b88 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.h +++ b/level_3/fss_basic_read/c/private-fss_basic_read.h @@ -237,6 +237,24 @@ extern "C" { #endif // _di_fss_basic_read_process_at_ /** + * Process based on columns parameter. + * + * @param main + * The main data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_read_process_columns_ + extern f_status_t fss_basic_read_process_columns(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) f_attribute_visibility_internal; +#endif // _di_fss_basic_read_process_columns_ + +/** * Process based on line parameter. * * @param main diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 4f7a63b..b60473a 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -25,6 +25,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_extended_list_read_short_at, fss_extended_list_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); fll_program_print_help_option(output, context, fss_extended_list_read_short_content, fss_extended_list_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(output, context, fss_extended_list_read_short_columns, fss_extended_list_read_long_columns, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); fll_program_print_help_option(output, context, fss_extended_list_read_short_delimit, fss_extended_list_read_long_delimit, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); fll_program_print_help_option(output, context, fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); fll_program_print_help_option(output, context, fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); @@ -81,8 +82,7 @@ extern "C" { fprintf(output.stream, " The parameter "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_read_long_select); - fprintf(output.stream, " selects a Content index at a given depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " (This parameter is not synonymous with the depth parameter and does not relate to nested Content).%c", f_string_eol_s[0]); + fprintf(output.stream, " selects a Content column.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -177,6 +177,16 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); + fprintf(output.stream, " The parameters "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_read_long_columns); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_read_long_select); + fprintf(output.stream, " refer to a Content column.%c", f_string_eol_s[0]); + fprintf(output.stream, " The word \"column\" is being loosely defined to refer to a specific Content.%c", f_string_eol_s[0]); + fprintf(output.stream, " This is not to be confused with a depth.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + return F_none; } #endif // _di_fss_extended_list_read_print_help_ @@ -309,6 +319,46 @@ extern "C" { } // for } + if (F_status_is_error_not(status) && main->parameters[fss_extended_list_read_parameter_columns].result == f_console_result_found) { + const f_array_length_t parameter_code[] = { + fss_extended_list_read_parameter_depth, + fss_extended_list_read_parameter_line, + fss_extended_list_read_parameter_pipe, + fss_extended_list_read_parameter_select, + fss_extended_list_read_parameter_total, + }; + + const f_string_t parameter_name[] = { + fss_extended_list_read_long_depth, + fss_extended_list_read_long_line, + fss_extended_list_read_long_pipe, + fss_extended_list_read_long_select, + fss_extended_list_read_long_total, + }; + + const uint8_t parameter_match[] = { + f_console_result_additional, + f_console_result_additional, + f_console_result_found, + f_console_result_additional, + f_console_result_found, + }; + + for (f_array_length_t i = 0; i < 5; ++i) { + + if (main->parameters[parameter_code[i]].result == parameter_match[i]) { + f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_read_long_columns); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, parameter_name[i]); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + + status = F_status_set_error(F_parameter); + break; + } + } // for + } + if (F_status_is_error_not(status) && main->parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) { if (main->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); @@ -319,7 +369,7 @@ extern "C" { status = F_status_set_error(F_parameter); } - else if (main->parameters[fss_extended_list_read_parameter_line].result == f_console_result_found) { + else if (main->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_read_long_pipe); f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index 327208f..82161ad 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -68,6 +68,7 @@ extern "C" { #define fss_extended_list_read_short_at "a" #define fss_extended_list_read_short_content "c" + #define fss_extended_list_read_short_columns "C" #define fss_extended_list_read_short_delimit "D" #define fss_extended_list_read_short_depth "d" #define fss_extended_list_read_short_empty "e" @@ -81,6 +82,7 @@ extern "C" { #define fss_extended_list_read_long_at "at" #define fss_extended_list_read_long_content "content" + #define fss_extended_list_read_long_columns "columns" #define fss_extended_list_read_long_delimit "delimit" #define fss_extended_list_read_long_depth "depth" #define fss_extended_list_read_long_empty "empty" @@ -105,6 +107,7 @@ extern "C" { fss_extended_list_read_parameter_at, fss_extended_list_read_parameter_content, + fss_extended_list_read_parameter_columns, fss_extended_list_read_parameter_delimit, fss_extended_list_read_parameter_depth, fss_extended_list_read_parameter_empty, @@ -130,6 +133,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_list_read_short_at, fss_extended_list_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_content, fss_extended_list_read_long_content, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_list_read_short_columns, fss_extended_list_read_long_columns, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_delimit, fss_extended_list_read_long_delimit, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, 0, 0, f_console_type_normal), \ @@ -142,7 +146,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_extended_list_read_total_parameters 21 + #define fss_extended_list_read_total_parameters 22 #endif // _di_fss_extended_list_read_defines_ /** diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index b364f7f..b0bb8de 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -117,6 +117,7 @@ extern "C" { * * fss_extended_list_read_data_option_*: * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. * - content: The Content is to be printed. * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). @@ -141,14 +142,15 @@ extern "C" { */ #ifndef _di_fss_extended_list_read_data_t_ #define fss_extended_list_read_data_option_at 0x1 - #define fss_extended_list_read_data_option_content 0x2 - #define fss_extended_list_read_data_option_empty 0x4 - #define fss_extended_list_read_data_option_line 0x8 - #define fss_extended_list_read_data_option_name 0x10 - #define fss_extended_list_read_data_option_object 0x20 - #define fss_extended_list_read_data_option_select 0x40 - #define fss_extended_list_read_data_option_total 0x80 - #define fss_extended_list_read_data_option_trim 0x100 + #define fss_extended_list_read_data_option_columns 0x2 + #define fss_extended_list_read_data_option_content 0x4 + #define fss_extended_list_read_data_option_empty 0x8 + #define fss_extended_list_read_data_option_line 0x10 + #define fss_extended_list_read_data_option_name 0x20 + #define fss_extended_list_read_data_option_object 0x40 + #define fss_extended_list_read_data_option_select 0x80 + #define fss_extended_list_read_data_option_total 0x100 + #define fss_extended_list_read_data_option_trim 0x200 typedef struct { uint16_t option; diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 1a81b5e..e1f4beb 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -406,6 +406,10 @@ extern "C" { return fss_extended_list_read_process_at(main, data, names); } + if (data->option & fss_extended_list_read_data_option_columns) { + return fss_extended_list_read_process_columns(main, data, names); + } + if (data->option & fss_extended_list_read_data_option_total) { return fss_extended_list_read_process_total(main, data, names); } @@ -433,10 +437,7 @@ extern "C" { f_status_t fss_extended_list_read_process_at(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (!data->objects.used) { - fss_extended_list_read_print_zero(main); - } - else if (names[data->depths.array[0].value_at] && (data->option & fss_extended_list_read_data_option_total)) { + if (data->option & (fss_extended_list_read_data_option_columns | fss_extended_list_read_data_option_total)) { fss_extended_list_read_print_zero(main); } @@ -461,6 +462,9 @@ extern "C" { status = fss_extended_list_read_process_at_line(at, *delimits_object, *delimits_content, main, data, &line); if (status == F_success) return F_none; } + else if (data->option & fss_extended_list_read_data_option_columns) { + fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + } else if (data->option & fss_extended_list_read_data_option_total) { if ((data->option & fss_extended_list_read_data_option_object) && !(data->option & fss_extended_list_read_data_option_content)) { if (data->contents.array[i].used) { @@ -531,6 +535,32 @@ extern "C" { } #endif // _di_fss_extended_list_read_process_at_ +#ifndef _di_fss_extended_list_read_process_columns_ + f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + + if (!(data->option & fss_extended_list_read_data_option_content)) { + fss_extended_list_read_print_zero(main); + + return F_none; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_extended_list_read_process_columns_ + #ifndef _di_fss_extended_list_read_process_at_line_ f_status_t fss_extended_list_read_process_at_line(const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, f_array_length_t *line) { @@ -551,8 +581,6 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_extended_list_read_data_option_content) { - - // @fixme empty content is it closed with '}' or is there no empty Content at all? if (!data->contents.array[at].used) { return F_none; } @@ -673,6 +701,10 @@ extern "C" { data->option |= fss_extended_list_read_data_option_at; } + if (main->parameters[fss_extended_list_read_parameter_columns].result == f_console_result_found) { + data->option |= fss_extended_list_read_data_option_columns; + } + if (main->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) { data->option |= fss_extended_list_read_data_option_content; } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h index 9c66f01..a531331 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h @@ -287,6 +287,24 @@ extern "C" { #endif // _di_fss_extended_list_read_process_at_ /** + * Process based on columns parameter. + * + * @param main + * The main data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_list_read_process_columns_ + extern f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) f_attribute_visibility_internal; +#endif // _di_fss_extended_list_read_process_columns_ + +/** * Process based on at parameter for some line. * * @param main diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index b07db75..610b176 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -25,6 +25,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_extended_read_short_at, fss_extended_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); fll_program_print_help_option(output, context, fss_extended_read_short_content, fss_extended_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(output, context, fss_extended_read_short_columns, fss_extended_read_long_columns, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); fll_program_print_help_option(output, context, fss_extended_read_short_delimit, fss_extended_read_long_delimit, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); fll_program_print_help_option(output, context, fss_extended_read_short_depth, fss_extended_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); fll_program_print_help_option(output, context, fss_extended_read_short_empty, fss_extended_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); @@ -81,8 +82,7 @@ extern "C" { fprintf(output.stream, " The parameter "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_read_long_select); - fprintf(output.stream, " selects a Content index at a given depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " (This parameter is not synonymous with the depth parameter and does not relate to nested Content).%c", f_string_eol_s[0]); + fprintf(output.stream, " selects a Content column.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -177,6 +177,16 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); + fprintf(output.stream, " The parameters "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_read_long_columns); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_read_long_select); + fprintf(output.stream, " refer to a Content column.%c", f_string_eol_s[0]); + fprintf(output.stream, " The word \"column\" is being loosely defined to refer to a specific Content.%c", f_string_eol_s[0]); + fprintf(output.stream, " This is not to be confused with a depth.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + return F_none; } #endif // _di_fss_extended_read_print_help_ @@ -310,6 +320,46 @@ extern "C" { } // for } + if (F_status_is_error_not(status) && main->parameters[fss_extended_read_parameter_columns].result == f_console_result_found) { + const f_array_length_t parameter_code[] = { + fss_extended_read_parameter_depth, + fss_extended_read_parameter_line, + fss_extended_read_parameter_pipe, + fss_extended_read_parameter_select, + fss_extended_read_parameter_total, + }; + + const f_string_t parameter_name[] = { + fss_extended_read_long_depth, + fss_extended_read_long_line, + fss_extended_read_long_pipe, + fss_extended_read_long_select, + fss_extended_read_long_total, + }; + + const uint8_t parameter_match[] = { + f_console_result_additional, + f_console_result_additional, + f_console_result_found, + f_console_result_additional, + f_console_result_found, + }; + + for (f_array_length_t i = 0; i < 5; ++i) { + + if (main->parameters[parameter_code[i]].result == parameter_match[i]) { + f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_read_long_columns); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, parameter_name[i]); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + + status = F_status_set_error(F_parameter); + break; + } + } // for + } + if (F_status_is_error_not(status) && main->parameters[fss_extended_read_parameter_pipe].result == f_console_result_found) { if (main->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); @@ -320,7 +370,7 @@ extern "C" { status = F_status_set_error(F_parameter); } - else if (main->parameters[fss_extended_read_parameter_line].result == f_console_result_found) { + else if (main->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_read_long_pipe); f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index c8e8e83..c4d9020 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -68,6 +68,7 @@ extern "C" { #define fss_extended_read_short_at "a" #define fss_extended_read_short_content "c" + #define fss_extended_read_short_columns "C" #define fss_extended_read_short_delimit "D" #define fss_extended_read_short_depth "d" #define fss_extended_read_short_empty "e" @@ -81,6 +82,7 @@ extern "C" { #define fss_extended_read_long_at "at" #define fss_extended_read_long_content "content" + #define fss_extended_read_long_columns "columns" #define fss_extended_read_long_delimit "delimit" #define fss_extended_read_long_depth "depth" #define fss_extended_read_long_empty "empty" @@ -105,6 +107,7 @@ extern "C" { fss_extended_read_parameter_at, fss_extended_read_parameter_content, + fss_extended_read_parameter_columns, fss_extended_read_parameter_delimit, fss_extended_read_parameter_depth, fss_extended_read_parameter_empty, @@ -130,6 +133,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_read_short_at, fss_extended_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_content, fss_extended_read_long_content, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_read_short_columns, fss_extended_read_long_columns, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_delimit, fss_extended_read_long_delimit, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_depth, fss_extended_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_empty, fss_extended_read_long_empty, 0, 0, f_console_type_normal), \ @@ -142,7 +146,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_read_short_trim, fss_extended_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_extended_read_total_parameters 21 + #define fss_extended_read_total_parameters 22 #endif // _di_fss_extended_read_defines_ /** diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index f6130de..f05a58d 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -117,6 +117,7 @@ extern "C" { * * fss_extended_read_data_option_*: * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. * - content: The Content is to be printed. * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). @@ -141,14 +142,15 @@ extern "C" { */ #ifndef _di_fss_extended_read_data_t_ #define fss_extended_read_data_option_at 0x1 - #define fss_extended_read_data_option_content 0x2 - #define fss_extended_read_data_option_empty 0x4 - #define fss_extended_read_data_option_line 0x8 - #define fss_extended_read_data_option_name 0x10 - #define fss_extended_read_data_option_object 0x20 - #define fss_extended_read_data_option_select 0x40 - #define fss_extended_read_data_option_total 0x80 - #define fss_extended_read_data_option_trim 0x100 + #define fss_extended_read_data_option_columns 0x2 + #define fss_extended_read_data_option_content 0x4 + #define fss_extended_read_data_option_empty 0x8 + #define fss_extended_read_data_option_line 0x10 + #define fss_extended_read_data_option_name 0x20 + #define fss_extended_read_data_option_object 0x40 + #define fss_extended_read_data_option_select 0x80 + #define fss_extended_read_data_option_total 0x100 + #define fss_extended_read_data_option_trim 0x200 typedef struct { uint16_t option; diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index c7c46ee..44abbd8 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -439,6 +439,10 @@ extern "C" { return fss_extended_read_process_at(main, data, names); } + if (data->option & fss_extended_read_data_option_columns) { + return fss_extended_read_process_columns(main, data, names); + } + if (data->option & fss_extended_read_data_option_total) { return fss_extended_read_process_total(main, data, names); } @@ -466,10 +470,7 @@ extern "C" { f_status_t fss_extended_read_process_at(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { - if (!data->objects.used) { - fss_extended_list_read_print_zero(main); - } - else if (names[data->depths.array[0].value_at] && (data->option & fss_extended_read_data_option_total)) { + if (data->option & (fss_extended_read_data_option_columns | fss_extended_read_data_option_total)) { fss_extended_read_print_zero(main); } @@ -512,6 +513,9 @@ extern "C" { fss_extended_read_print_at(i, *delimits_object, *delimits_content, main, data); } } + else if (data->option & fss_extended_read_data_option_columns) { + fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + } else if (data->option & fss_extended_read_data_option_total) { if (fss_extended_read_print_at_total(i, main, data) == F_none) { break; @@ -535,6 +539,32 @@ extern "C" { } #endif // _di_fss_extended_read_process_at_ +#ifndef _di_fss_extended_read_process_columns_ + f_status_t fss_extended_read_process_columns(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { + + if (!(data->option & fss_extended_read_data_option_content)) { + fss_extended_read_print_zero(main); + + return F_none; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (data->contents.array[at].used > max) { + max = data->contents.array[at].used; + } + } // for + + fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + + return F_none; + } +#endif // _di_fss_extended_read_process_columns_ + #ifndef _di_fss_extended_read_process_line_ f_status_t fss_extended_read_process_line(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { @@ -621,6 +651,10 @@ extern "C" { data->option |= fss_extended_read_data_option_at; } + if (main->parameters[fss_extended_read_parameter_columns].result == f_console_result_found) { + data->option |= fss_extended_read_data_option_columns; + } + if (main->parameters[fss_extended_read_parameter_content].result == f_console_result_found) { data->option |= fss_extended_read_data_option_content; } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.h b/level_3/fss_extended_read/c/private-fss_extended_read.h index 6effcb7..057a698 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.h +++ b/level_3/fss_extended_read/c/private-fss_extended_read.h @@ -281,6 +281,24 @@ extern "C" { #endif // _di_fss_extended_read_process_at_ /** + * Process based on columns parameter. + * + * @param main + * The main data. + * @param data + * The program data. + * @param names + * An array of booleans representing whether or not some Object name is to be used. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_read_process_columns_ + extern f_status_t fss_extended_read_process_columns(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) f_attribute_visibility_internal; +#endif // _di_fss_extended_read_process_columns_ + +/** * Process based on line parameter. * * @param main diff --git a/specifications/fss-0000.txt b/specifications/fss-0000.txt index d176803..d6e69cc 100644 --- a/specifications/fss-0000.txt +++ b/specifications/fss-0000.txt @@ -6,9 +6,10 @@ Featureless Settings Specification: 0000 - Basic: An Object may be followed by a newline, in which case means that the Object has no Content. Content exists on the same line as the Object. - Content consists of everything following the first non-whitespace character until the newline. - Content includes trailing whitespace before newline is reached. - Content does not include any of the leading whitespace. + Content is represented as a single Content column terminated by a newline. + Content column consists of everything following the first non-whitespace character until the newline. + Content column includes trailing whitespace before newline is reached. + Content column does not include any of the leading whitespace. No delimits are supported in the content. If only printing whitespace follows a valid Object, that Object is considered to have no Content. diff --git a/specifications/fss-0001.txt b/specifications/fss-0001.txt index c81e048..7dafc96 100644 --- a/specifications/fss-0001.txt +++ b/specifications/fss-0001.txt @@ -6,8 +6,9 @@ Featureless Settings Specification: 0001 - Extended: An Object may be followed by a newline, in which case means that the Object has no Content. Content exists on the same line as the Object. - Content of whitespace separated sets until the newline. - Any number of sets may exist in the Content until the newline is reached. + Content is represented as multiple Content columns. + Content columns are whitespace separated parts within the Content and terminated by a newline. + Any number of Content columns may exist in the Content until the newline is reached. Key\: \s = whitespace, except newline. diff --git a/specifications/fss-0002.txt b/specifications/fss-0002.txt index d986185..bc5df3a 100644 --- a/specifications/fss-0002.txt +++ b/specifications/fss-0002.txt @@ -7,7 +7,7 @@ Featureless Settings Specification: 0002 - Basic List: A colon followed by any whitespace until a newline terminates a valid Object. Non-whitespace may not follow the colon of a valid Object. - Content exists on every line following a valid object until the end of file (or string) or until the next valid Object is found. + Content is represented as a single Content column of every line following a valid object until the end of file (or string) or until the next valid Object is found. Any content that could be interpreted as a valid Object must have the colon delimited. There is no single-quote or double-quote delimitation in this specification. diff --git a/specifications/fss-0003.txt b/specifications/fss-0003.txt index 8e9ab28..eedb7de 100644 --- a/specifications/fss-0003.txt +++ b/specifications/fss-0003.txt @@ -6,9 +6,9 @@ Featureless Settings Specification: 0003 - Extended List: An Object is not considered fully valid until a valid close-brace (}) is found, designating the end of the Content. Non-whitespace may not follow the open-brace of a valid Object. - Content exists on every line following a valid object until the end of file (or string) or until a non-delimited close-brace (}). - Any Content that could be interpreted as an end of content must be delimited if it should be part of the content. - Whitespace may follow a valid close-brace but a terminating newline must be present to designate a valid end of content. + Content is represented as a single Content column of every line following a valid object until the end of file (or string) or until a non-delimited close-brace (}). + Any Content column that could be interpreted as an end of content must be delimited if it should be part of the Content. + Whitespace may follow a valid close-brace but a terminating newline must be present to designate a valid end of Content. There is no single-quote or double-quote delimitation in this specification. Only the open-brace that would result in a valid Object or the close-brace that would terminate valid Content can be delimited. diff --git a/specifications/fss-000C.txt b/specifications/fss-000C.txt index 15d734a..8359b56 100644 --- a/specifications/fss-000C.txt +++ b/specifications/fss-000C.txt @@ -2,10 +2,11 @@ Featureless Settings Specification: 000C - Iki Text: IKI is an unstructured WIKI-like syntax meant to be simpler than WIKI syntax. - This fss specification represents a plain text file not following any special FSS structure but instead supports the IKI syntax. + This FSS specification represents a plain text file not following any special FSS structure but instead supports the IKI syntax. The IKI syntax may be used in any FSS specification and the specific vocabulary is defined by appending For compatibility with the FSS terminology, the Vocabulary Name is to be considered the Object and the Vocabulary value is to be considered the Content. + The Content column, therefore, exists as a single Column (which is the entire Vocabulary value). There is no requirement for any specific IKI vocabulary by this standard only that the given syntax is supported. To specify the IKI vocabulary being used append the IKI vocabulary header immediately after the fss header like such: "# fss-000c iki-0001". diff --git a/specifications/fss.txt b/specifications/fss.txt index ea6f8e0..25c674d 100644 --- a/specifications/fss.txt +++ b/specifications/fss.txt @@ -20,6 +20,13 @@ Featureless Settings Specifications: The specification may choose how a given Object or Content are represented and parsed. For example, in FSS-0000 (Basic), Content is treated as a single item whereas in FSS-0001 (Extended), Content is broken apart in multiple sub parts. + Contents may be broken up into zero or more discrete sets of Content. + Each of these discrete sets of Content are referred to as a column. + These columns do not need to be setup in a column structure, the word "column" is simply used as a grouping terminology. + While a Content refers to the entire set, a column (more specifically, a Content column) refers to the individual discrete sets within the Content. + For example, in FSS-000 (Basic) the entire Content may be further represented as a single column. + For example, in FSS-001 (Extended) the entire Content may be further represented as multiple columns. + In all cases, specifications that separate Objects from Contents using whitespace, the first whitespace separating the Object and Content must not be considered part of the Object nor part of the Content. All spaces after the first separating whitespace is generally ignored until the first non-whitespace character is found, unless otherwise specified.