12.11.2 Class constructors of mbfl_wrong_parameters_number_condition

Constructor on mbfl_wrong_parameters_number_condition_t: mbfl_wrong_parameters_number_condition_make CND FUNCNAME GIVEN_NUMBER EXPECTED_MIN_NUMBER
Constructor on mbfl_wrong_parameters_number_condition_t: mbfl_wrong_parameters_number_condition_make CND FUNCNAME GIVEN_NUMBER EXPECTED_MIN_NUMBER EXPECTED_MAX_NUMBER

Build a new class instance. Exceptional–condition objects built with this constructor are non–continuable.

The parameter FUNCNAME must be the name of the function; it is usually the value of the Bash variable FUNCNAME.

The parameter GIVEN_NUMBER must an integer representing the number of parameters given in a function call.

The parameter EXPECTED_MIN_NUMBER must be an integer representing the minimum number of mandatory parameters.

The optional parameter EXPECTED_MAX_NUMBER must be an integer representing the maximum number of parameters, mandatory plus optional. When not given: it defaults to ‘9999’.

Preprocessor Macro: mbfl_check_mandatory_parameters_number (EXPECTED_MIN_NUMBER)
Preprocessor Macro: mbfl_check_mandatory_parameters_number (EXPECTED_MIN_NUMBER, EXPECTED_MAX_NUMBER)

When used with one parameter, expand as follows:

mbfl_check_mandatory_parameters_number(EXPECTED_NUMBER)
→ if ((EXPECTED_NUMBER > $#))
    then
        mbfl_default_object_declare(CND)

        mbfl_wrong_parameters_number_condition_make _(CND) $FUNCNAME EXPECTED_NUMBER 9999 $#
        mbfl_exception_raise_then_return_failure(_(CND))
    fi

When used with two parameters, expand as follows:

mbfl_check_mandatory_parameters_number(EXPECTED_MIN_NUMBER, EXPECTED_MAX_NUMBER)
→ if (( $# > EXPECTED_MAX_NUMBER || EXPECTED_MIN_NUMBER > $# ))
    then
        mbfl_default_object_declare(CND)

        mbfl_wrong_parameters_number_condition_make _(CND) $FUNCNAME EXPECTED_MIN_NUMBER EXPECTED_MAX_NUMBER $#
        mbfl_exception_raise_then_return_failure(_(CND))
    fi

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.