#include "param_enum.h"
#include "param_internal.h"
#include "utils_common.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
Go to the source code of this file.
|
| static enum yac_param_type | yac_param_enum_get_type (const struct yac_param *param) |
| |
| static int | yac_param_enum_is_default (const struct yac_param *param) |
| |
| static const char * | yac_param_enum_get_name (const struct yac_param *param) |
| |
| static int | yac_param_enum_set_scalar_int (struct yac_param *param, int value) |
| |
| static int | yac_param_enum_set_scalar (struct yac_param *param, const char *value_str) |
| |
| static int | yac_param_enum_get_scalar_int (const struct yac_param *param, int *value) |
| |
| static int | yac_param_enum_get_scalar (const struct yac_param *param, char *buf, size_t buflen) |
| |
| static int | yac_param_enum_get_scalar_kind (const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind) |
| |
| static void | yac_param_enum_delete (struct yac_param *param) |
| |
| struct yac_param * | yac_param_enum_new (const char *name, int *value_ptr, int default_value, struct yac_name_type_pair const *enum_table, size_t enum_table_size, int has_default, int is_defined) |
| | Create a new enum parameter for configuration.
|
| |
◆ yac_param_enum_delete()
| static void yac_param_enum_delete |
( |
struct yac_param * | param | ) |
|
|
static |
◆ yac_param_enum_get_name()
| static const char * yac_param_enum_get_name |
( |
const struct yac_param * | param | ) |
|
|
static |
◆ yac_param_enum_get_scalar()
| static int yac_param_enum_get_scalar |
( |
const struct yac_param * | param, |
|
|
char * | buf, |
|
|
size_t | buflen ) |
|
static |
◆ yac_param_enum_get_scalar_int()
| static int yac_param_enum_get_scalar_int |
( |
const struct yac_param * | param, |
|
|
int * | value ) |
|
static |
◆ yac_param_enum_get_scalar_kind()
◆ yac_param_enum_get_type()
◆ yac_param_enum_is_default()
| static int yac_param_enum_is_default |
( |
const struct yac_param * | param | ) |
|
|
static |
◆ yac_param_enum_new()
| struct yac_param * yac_param_enum_new |
( |
const char * | name, |
|
|
int * | value_ptr, |
|
|
int | default_value, |
|
|
struct yac_name_type_pair const * | enum_table, |
|
|
size_t | enum_table_size, |
|
|
int | has_default, |
|
|
int | is_defined ) |
Create a new enum parameter for configuration.
This parameter type allows selection from a fixed set of named integer values (enums).
Special handling:
- String-based getters/setters operate using the enum name (e.g., "conservative").
- Int-based getters/setters operate using the enum integer value.
- Conversion between string and int is handled internally using the provided enum_table.
- Invalid names or values will result in an error.
- Parameters
-
| name | Name of the parameter (must not be NULL or empty) |
| value_ptr | Pointer to the integer value to be set/read |
| default_value | Default enum value (must be present in enum_table, ignored if has_default is false) |
| enum_table | Array of name/type pairs defining the enum |
| enum_table_size | Number of entries in enum_table (must be > 0) |
| has_default | If true, parameter has a default value; if false, value is undefined until set |
| is_defined | If true, initial value is considered defined; if false, initial value is considered undefined and user must set it before getting |
- Returns
- New parameter handle
Definition at line 148 of file param_enum.c.
◆ yac_param_enum_set_scalar()
| static int yac_param_enum_set_scalar |
( |
struct yac_param * | param, |
|
|
const char * | value_str ) |
|
static |
◆ yac_param_enum_set_scalar_int()
| static int yac_param_enum_set_scalar_int |
( |
struct yac_param * | param, |
|
|
int | value ) |
|
static |
◆ yac_param_enum_vtable
Initial value:= {
.get_sub_count = NULL,
.get_sub_by_name = NULL,
.get_sub_by_index = NULL,
.append = NULL,
.set_scalar_dble = NULL,
.get_scalar_dble = NULL
}
static int yac_param_enum_get_scalar_kind(const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind)
static int yac_param_enum_set_scalar_int(struct yac_param *param, int value)
static int yac_param_enum_is_default(const struct yac_param *param)
static int yac_param_enum_get_scalar(const struct yac_param *param, char *buf, size_t buflen)
static int yac_param_enum_get_scalar_int(const struct yac_param *param, int *value)
static int yac_param_enum_set_scalar(struct yac_param *param, const char *value_str)
static void yac_param_enum_delete(struct yac_param *param)
static const char * yac_param_enum_get_name(const struct yac_param *param)
static enum yac_param_type yac_param_enum_get_type(const struct yac_param *param)
Definition at line 130 of file param_enum.c.