From 47ac80e82f63afb87c9078c5f03f6b9f067caee9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 13 Jul 2023 22:49:22 -0500 Subject: [PATCH] Feature: Add fll_program_print_error_parameter_integer_less_than() and fll_program_print_error_parameter_integer_more_than(). The less than and more than (greater than) are likely a common enough check to create standard functions for. --- build/disable/level_2/fll_program.h | 2 ++ build/stand_alone/fake.config.h | 2 ++ level_2/fll_program/c/program/print.c | 48 +++++++++++++++++++++++++ level_2/fll_program/c/program/print.h | 68 +++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) diff --git a/build/disable/level_2/fll_program.h b/build/disable/level_2/fll_program.h index c44e231..55235d1 100644 --- a/build/disable/level_2/fll_program.h +++ b/build/disable/level_2/fll_program.h @@ -24,6 +24,8 @@ #define _di_fll_program_print_error_parameter_cannot_use_with_without_ #define _di_fll_program_print_error_parameter_cannot_use_with_xor_ #define _di_fll_program_print_error_parameter_empty_value_ +#define _di_fll_program_print_error_parameter_integer_less_than_ +#define _di_fll_program_print_error_parameter_integer_more_than_ #define _di_fll_program_print_error_parameter_integer_not_ #define _di_fll_program_print_error_parameter_integer_not_negative_ #define _di_fll_program_print_error_parameter_integer_not_positive_ diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 1b978f1..ecc942a 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -1087,6 +1087,8 @@ #define _di_fll_program_print_error_parameter_cannot_use_with_without_ #define _di_fll_program_print_error_parameter_cannot_use_with_xor_ #define _di_fll_program_print_error_parameter_empty_value_ +#define _di_fll_program_print_error_parameter_integer_less_than_ +#define _di_fll_program_print_error_parameter_integer_more_than_ #define _di_fll_program_print_error_parameter_integer_not_ #define _di_fll_program_print_error_parameter_integer_not_negative_ #define _di_fll_program_print_error_parameter_integer_not_positive_ diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index 1205bf3..c851e70 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -230,6 +230,54 @@ extern "C" { } #endif // _di_fll_program_print_error_parameter_empty_value_ +#ifndef _di_fll_program_print_error_parameter_integer_less_than_ + f_status_t fll_program_print_error_parameter_integer_less_than(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value, const f_string_static_t than) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe value '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, value, print->set->notable); + fl_print_format("%[' for the parameter '%]", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, symbol, name, print->set->notable); + fl_print_format("%[' must not be less than %]", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, than, print->set->notable); + fl_print_format("%[.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_integer_less_than_ + +#ifndef _di_fll_program_print_error_parameter_integer_more_than_ + f_status_t fll_program_print_error_parameter_integer_more_than(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value, const f_string_static_t than) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe value '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, value, print->set->notable); + fl_print_format("%[' for the parameter '%]", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, symbol, name, print->set->notable); + fl_print_format("%[' must not be more than %]", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, than, print->set->notable); + fl_print_format("%[.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_integer_more_than_ + #ifndef _di_fll_program_print_error_parameter_integer_not_ f_status_t fll_program_print_error_parameter_integer_not(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index f0ac8a4..9790b5c 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -335,6 +335,74 @@ extern "C" { #endif // _di_fll_program_print_error_parameter_empty_value_ /** + * Print message about parameter not being less than the given number. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_normal_s. + * @param name + * The parameter name. + * @param value + * The value. + * @param than + * The string representing the number to not be less than. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fll_program_print_error_parameter_integer_less_than_ + extern f_status_t fll_program_print_error_parameter_integer_less_than(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value, const f_string_static_t than); +#endif // _di_fll_program_print_error_parameter_integer_less_than_ + +/** + * Print message about parameter not being less than the given number. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_normal_s. + * @param name + * The parameter name. + * @param value + * The value. + * @param than + * The string representing the number to not be less than. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fll_program_print_error_parameter_integer_more_than_ + extern f_status_t fll_program_print_error_parameter_integer_more_than(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value, const f_string_static_t than); +#endif // _di_fll_program_print_error_parameter_integer_more_than_ + +/** * Print message about parameter not being a valid integer. * * This is only printed when verbosity is not set to quiet. -- 1.8.3.1