Return enum values as integers instead of strings

If the enums are converted to the acutual enum values before they are
returned, this removes the need for the modules to process the enum
strings to enum values. This allows modules to use enumerations with
minimal effort.
This commit is contained in:
Markus Mäkelä
2017-01-05 12:18:32 +02:00
parent 03391748ee
commit 9fa2de29d9
3 changed files with 26 additions and 7 deletions

View File

@ -93,6 +93,13 @@ enum mxs_module_param_options
MXS_MODULE_OPT_PATH_F_OK = (1 << 4) /**< PATH: Path must exist */
};
/** String to enum value mappings */
typedef struct mxs_enum_value
{
const char *name; /**< Name of the enum value */
int enum_value; /**< The integer value of the enum */
}MXS_ENUM_VALUE;
/** Module parameter declaration */
typedef struct mxs_module_param
{
@ -100,7 +107,7 @@ typedef struct mxs_module_param
enum mxs_module_param_type type; /**< Type of the parameter */
const char *default_value; /**< Default value for the parameter, NULL for no default value */
uint64_t options; /**< Parameter options */
const char **accepted_values; /**< Only for enum values */
const MXS_ENUM_VALUE *accepted_values; /**< Only for enum values */
} MXS_MODULE_PARAM;
/**