Typedefs | |
| typedef enum _cpl_parameter_class_ | cpl_parameter_class |
| The parameter class data type. More... | |
| typedef _cpl_parameter_ | cpl_parameter |
| The opaque parameter data type. More... | |
Enumerations | |
| enum | _cpl_parameter_class_ { CPL_PARAMETER_CLASS_INVALID, CPL_PARAMETER_CLASS_VALUE, CPL_PARAMETER_CLASS_RANGE, CPL_PARAMETER_CLASS_ENUM } |
| Supported parameter classes. More... | |
Functions | |
| cpl_parameter * | cpl_parameter_value_new (const char *name, cpl_type type, const char *description, const char *context,...) |
| Create a new value parameter. More... | |
| cpl_parameter * | cpl_parameter_range_new (const char *name, cpl_type type, const char *description, const char *context,...) |
| Create a new range parameter. More... | |
| cpl_parameter * | cpl_parameter_enum_new (const char *name, cpl_type type, const char *description, const char *context,...) |
| Create a new enumeration parameter. More... | |
| void | cpl_parameter_delete (cpl_parameter *self) |
| Delete a parameter. More... | |
| int | cpl_parameter_set_bool (cpl_parameter *self, int value) |
| Assign a boolean value to a parameter. More... | |
| int | cpl_parameter_set_int (cpl_parameter *self, int value) |
| Assign an integer value to a parameter. More... | |
| int | cpl_parameter_set_double (cpl_parameter *self, double value) |
| Assign a double value to a parameter. More... | |
| int | cpl_parameter_set_string (cpl_parameter *self, const char *value) |
| Assign a string value to a parameter. More... | |
| const char * | cpl_parameter_get_name (const cpl_parameter *self) |
| Get the name of a parameter. More... | |
| const char * | cpl_parameter_get_context (const cpl_parameter *self) |
| Get the context of a parameter. More... | |
| const char * | cpl_parameter_get_help (const cpl_parameter *self) |
| Get the description of a parameter. More... | |
| const char * | cpl_parameter_get_tag (const cpl_parameter *self) |
| Get the parameter's user tag. More... | |
| cpl_type | cpl_parameter_get_type (const cpl_parameter *self) |
| Get the parameter's value type. More... | |
| cpl_parameter_class | cpl_parameter_get_class (const cpl_parameter *self) |
| Get the parameter's class. More... | |
| int | cpl_parameter_get_bool (const cpl_parameter *self) |
| Get the value of the given boolean parameter. More... | |
| int | cpl_parameter_get_int (const cpl_parameter *self) |
| Get the value of the given integer parameter. More... | |
| double | cpl_parameter_get_double (const cpl_parameter *self) |
| Get the value of the given double parameter. More... | |
| char * | cpl_parameter_get_string (const cpl_parameter *self) |
| Get the value of the given string parameter. More... | |
| int | cpl_parameter_preset_get_bool (const cpl_parameter *self) |
| Get the default value of the given boolean parameter. More... | |
| int | cpl_parameter_preset_get_int (const cpl_parameter *self) |
| Get the default value of the given integer parameter. More... | |
| double | cpl_parameter_preset_get_double (const cpl_parameter *self) |
| Get the default value of the given double parameter. More... | |
| char * | cpl_parameter_preset_get_string (const cpl_parameter *self) |
| Get the default value of the given string parameter. More... | |
| int | cpl_parameter_set_alias (cpl_parameter *parameter, const char *cmd, const char *env, const char *file) |
| Set alias names for the given parameter. More... | |
| int | cpl_parameter_set_mode (cpl_parameter *parameter, int cflag, int eflag, int fflag) |
| Enables or disables the parameter for different contexts. More... | |
| int | cpl_parameter_enum_get_size (const cpl_parameter *parameter) |
| Get the number of alternatives of an enumeration parameter. More... | |
| int | cpl_parameter_enum_get_int (const cpl_parameter *parameter, int index) |
| Get the possible values for an integer enumeration. More... | |
| double | cpl_parameter_enum_get_double (const cpl_parameter *parameter, int index) |
| Get the possible values for a double enumeration. More... | |
| char * | cpl_parameter_enum_get_string (const cpl_parameter *parameter, int index) |
| Get the possible values for a string enumeration. More... | |
| int | cpl_parameter_range_get_min_int (const cpl_parameter *parameter) |
| Get the minimum value of an integer range parameter. More... | |
| double | cpl_parameter_range_get_min_double (const cpl_parameter *parameter) |
| Get the minimum value of a double range parameter. More... | |
| int | cpl_parameter_range_get_max_int (const cpl_parameter *parameter) |
| Get the maximum value of an integer range parameter. More... | |
| double | cpl_parameter_range_get_max_double (const cpl_parameter *parameter) |
| Get the maximum value of a double range parameter. More... | |
| int | cpl_parameter_get_present (const cpl_parameter *parameter) |
| Get the presence status flag of the given parameter. More... | |
| void | cpl_parameter_set_present (cpl_parameter *parameter, int status) |
| Change the presence status flag of the given parameter. More... | |
| int | cpl_parameter_get_id (const cpl_parameter *parameter) |
| Get the numerical identifier of the given parameter. More... | |
| void | cpl_parameter_set_id (cpl_parameter *parameter, int id) |
| Set the numerical identifier of the given parameter. More... | |
| char * | cpl_parameter_get_cmdl_keyword (const cpl_parameter *parameter) |
| Get the command line alias name of the given parameter. More... | |
| void | cpl_parameter_set_cmdl_keyword (cpl_parameter *parameter, char *alias) |
| Set the command line alias name of the given parameter. More... | |
| int | cpl_parameter_get_cmdl_active (const cpl_parameter *parameter) |
| Get the parameter's activity status for the command line context. More... | |
| void | cpl_parameter_set_cmdl_active (cpl_parameter *parameter, int active) |
| Set the parameter's activity status for the command line context. More... | |
| char * | cpl_parameter_get_env_keyword (const cpl_parameter *parameter) |
| Get the environment alias name of the given parameter. More... | |
| void | cpl_parameter_set_env_keyword (cpl_parameter *parameter, char *alias) |
| Set the environment alias name of the given parameter. More... | |
| int | cpl_parameter_get_env_active (const cpl_parameter *parameter) |
| Get the parameter's activity status for the environment context. More... | |
| void | cpl_parameter_set_env_active (cpl_parameter *parameter, int active) |
| Set the parameter's activity status for the environment context. More... | |
| char * | cpl_parameter_get_file_keyword (const cpl_parameter *parameter) |
| Get the configuration file alias name of the given parameter. More... | |
| void | cpl_parameter_set_file_keyword (cpl_parameter *parameter, char *alias) |
| Set the configuration file alias name of the given parameter. More... | |
| int | cpl_parameter_get_file_active (const cpl_parameter *parameter) |
| Get the parameter's activity status for the configuration file context. More... | |
| void | cpl_parameter_set_file_active (cpl_parameter *parameter, int active) |
| Set the parameter's activity status for the configuration file context. More... | |
| void | cpl_parameter_print (const cpl_parameter *parameter) |
| Prints the given parameter. More... | |
The fundamental parts of a parameter are its name, a context to which it belongs (a specific component of an application for instance), its current value and a default value.
The implementation supports three classes of parameters:
CPL_TYPE_BOOLCPL_TYPE_INTCPL_TYPE_DOUBLECPL_TYPE_STRING
The constructor of a plain value expects a single value, the parameter's default value, which must be of the appropriate type, as argument while the constructor for a range expects the default value, the minimum and the maximum value. The constructor for an enumeration expects as arguments the default value, the number of alternatives following and the list of alternatives. Note that the default value must be a member of the list of alternative enumeration values.
An example of how parameters of the different classes are created and destroyed is shown below:
cpl_parameter *value;
cpl_parameter *range;
cpl_parameter *enumeration;
...
value = cpl_parameter_value_new("Value", CPL_TYPE_INT,
"This is a plain value of type integer",
"Example",
-1);
range = cpl_parameter_range_new("Range", CPL_TYPE_DOUBLE,
"This is a value range of type double",
"Example",
0.5, 0.0, 1.0);
enumeration = cpl_parameter_enum_new("Enum", CPL_TYPE_STRING,
"This is an enumeration of type "
"string",
"Example",
"first", 3, "first", "second",
"third");
...
cpl_parameter_delete(value);
cpl_parameter_delete(range);
cpl_parameter_delete(enumeration);
After the parameter has been created and initialised the parameters current value equals its default value. The initialisation values are copied into the parameter, i.e. if an initialiser value resides in dynamically allocated memory, it can be deallocated after the parameter has been initialised without affecting the created parameter.
#include <cpl_parameter.h>
|
|
The opaque parameter data type.
|
|
|
The parameter class data type.
|
|
|
Supported parameter classes.
|
|
|
Delete a parameter.
|
|
||||||||||||
|
Get the possible values for a double enumeration.
If the parameter parameter does not point to a valid parameter, but is |
|
||||||||||||
|
Get the possible values for an integer enumeration.
If the parameter parameter does not point to a valid parameter, but is |
|
|
Get the number of alternatives of an enumeration parameter.
NULL, or the parameter's class in not equal to CPL_PARAMETER_CLASS_ENUM the function returns an error. In the former case the error code CPL_ERROR_NULL_INPUT is set and in the latter case the error code will be CPL_ERROR_TYPE_MISMATCH. |
|
||||||||||||
|
Get the possible values for a string enumeration.
If the parameter parameter does not point to a valid parameter, but is |
|
||||||||||||||||||||||||
|
Create a new enumeration parameter.
To properly initialise the newly created enumeration, the parameter's default value (together with the number of alternatives following) and the list of enumeration alternatives must be passed as the variable argument list arguments. The list of enumeration alternatives must contain the default value! Apart from the number of possible alternatives, which must be an argument of type
The following example creates a string enumeration parameter with the unique name
|
|
|
Get the value of the given boolean parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not a boolean parameter, i.e. the parameter's type is different from CPL_TYPE_BOOL, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the parameter's class.
|
|
|
Get the parameter's activity status for the command line context.
|
|
|
Get the command line alias name of the given parameter.
|
|
|
Get the context of a parameter.
|
|
|
Get the value of the given double parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an double parameter, i.e. the parameter's type is different from CPL_TYPE_DOUBLE, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the parameter's activity status for the environment context.
|
|
|
Get the environment alias name of the given parameter.
|
|
|
Get the parameter's activity status for the configuration file context.
|
|
|
Get the configuration file alias name of the given parameter.
|
|
|
Get the description of a parameter.
|
|
|
Get the numerical identifier of the given parameter.
|
|
|
Get the value of the given integer parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an integer parameter, i.e. the parameter's type is different from CPL_TYPE_INT, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the name of a parameter.
|
|
|
Get the presence status flag of the given parameter.
If the parameter parameter does not point to a valid parameter, but is
|
|
|
Get the value of the given string parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an string parameter, i.e. the parameter's type is different from CPL_TYPE_STRING, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the parameter's user tag.
|
|
|
Get the parameter's value type.
|
|
|
Get the default value of the given boolean parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not a boolean parameter, i.e. the parameter's type is different from CPL_TYPE_BOOL, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the default value of the given double parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an double parameter, i.e. the parameter's type is different from CPL_TYPE_INT, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the default value of the given integer parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an integer parameter, i.e. the parameter's type is different from CPL_TYPE_INT, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Get the default value of the given string parameter.
CPL_ERROR_NULL_INPUT is set on return. Also, if the parameter self is not an string parameter, i.e. the parameter's type is different from CPL_TYPE_INT, the error code CPL_ERROR_TYPE_MISMATCH is set. |
|
|
Prints the given parameter.
|
|
|
Get the maximum value of a double range parameter.
If the parameter parameter does not point to a valid parameter, but is |
|
|
Get the maximum value of an integer range parameter.
If the parameter parameter does not point to a valid parameter, but is |
|
|
Get the minimum value of a double range parameter.
If the parameter parameter does not point to a valid parameter, but is |
|
|
Get the minimum value of an integer range parameter.
If the parameter parameter does not point to a valid parameter, but is |
|
||||||||||||||||||||||||
|
Create a new range parameter.
To properly initialise the newly created range the parameters default value together with the minimum and maximum value of the range has to be passed as the variable argument list arguments. The type of all initialisation arguments must match the parameter's value type as it is indicated by type.
The following example creates a double range parameter with the unique name
|
|
||||||||||||||||||||
|
Set alias names for the given parameter.
NULL. |
|
||||||||||||
|
Assign a boolean value to a parameter.
CPL_TYPE_BOOL. Any non-zero value passed as value is interpreted as true. |
|
||||||||||||
|
Set the parameter's activity status for the command line context.
|
|
||||||||||||
|
Set the command line alias name of the given parameter.
NULL pointer is passed instead of a valid parameter the function returns immediately.
|
|
||||||||||||
|
Assign a double value to a parameter.
CPL_TYPE_DOUBLE. |
|
||||||||||||
|
Set the parameter's activity status for the environment context.
|
|
||||||||||||
|
Set the environment alias name of the given parameter.
NULL pointer is passed instead of a valid parameter the function returns immediately.
|
|
||||||||||||
|
Set the parameter's activity status for the configuration file context.
|
|
||||||||||||
|
Set the configuration file alias name of the given parameter.
NULL pointer is passed instead of a valid parameter the function returns immediately.
|
|
||||||||||||
|
Set the numerical identifier of the given parameter.
|
|
||||||||||||
|
Assign an integer value to a parameter.
CPL_TYPE_INT. |
|
||||||||||||||||||||
|
Enables or disables the parameter for different contexts.
If a parameter is enabled for a particular context an application may modify the parameters value if it (its fully qualified name or its context specific alias name) appears in the context. If a parameter is disabled, an application must not change the parameters value. When a parameter is created it is enabled for all three contexts. |
|
||||||||||||
|
Change the presence status flag of the given parameter.
|
|
||||||||||||
|
Assign a string value to a parameter.
CPL_TYPE_STRING. |
|
||||||||||||||||||||||||
|
Create a new value parameter.
The newly created parameter is initialised with the default value passed to the function as the only variable argument list argument. The type of the value must match the parameter's value type as it is indicated by type.
The following example creates an integer value parameter with the unique name
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002