Add parameter validation utility
This patch adds a utility to help component classes validate the
parameters they receive (either for component initialization or query).
The definition of what constitutes valid parameters for a component
class is done by filling C structures describing each expected value
(see included test for examples).
Since this is made for parameter validation, and not general-purpose
value validation, the entry point bt_param_validation_validate assumes
that the root value is a map (and is therefore validated as a map, as
described below).
For parameters that have simple validation rules, it is enough to fill
the `type` field of bt_param_validation_value_descr, and perhaps the
additional fields associated to the type.
For array values, the description includes the minimum and maximum sizes
the array can have (use BT_PARAM_VALIDATION_INFINITE if there's no max).
It also includes a pointer to the description of its element values.
For map values, the description includes a list of possible map entries.
For each entry, we have the key, whether the entry is mandatory and the
description of the value.
For string values, the description may include a list of choices. If it
does, the string value must be in this list.
For parameters that have more complex validation rules, for example
parameters whose value can be of different types, it is possible to set
the `validation_func` field. If it is set, this function will be called
and is responsible for validating the value.
If the validation fails, an error message is produced, which includes
the full scope where the error occured (again, see the test for an
example).
Change-Id: If729415fdd8ce97fa94b79e8bf79461e46ebf2bc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2119
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.026229 seconds and 4 git commands to generate.