64 struct yac_param *param,
const char *value_str) {
72 "NULL value not allowed for parameter '%s'", self->
name);
78 size_t len = strlen(value_str);
84 "empty string not allowed for parameter '%s'", self->
name);
94 "string length %zu exceeds max_str_len %zu for parameter '%s'",
103 const struct yac_param *param,
char *buf,
size_t buflen) {
111 "value for parameter '%s' is undefined, user must set it first",
118 "NULL value not allowed for parameter '%s'", self->
name);
119 if (buflen > 0) buf[0] =
'\0';
127 "empty string not allowed for parameter '%s'", self->
name);
132 "buffer too small for value of parameter '%s'",
163 .get_sub_count = NULL,
164 .get_sub_by_name = NULL,
165 .get_sub_by_index = NULL,
170 .set_scalar_int = NULL,
171 .set_scalar_dble = NULL,
172 .get_scalar_int = NULL,
173 .get_scalar_dble = NULL
177 const char *
name,
char **value_ptr,
const char *default_value,
178 int allow_NULL,
int allow_empty,
size_t max_str_len,
int has_default,
183 !has_default || (allow_NULL || default_value),
184 "default_value is NULL but allow_NULL is false for parameter '%s'",
name);
186 !has_default || !default_value || allow_empty ||
187 (strlen(default_value) > 0),
188 "default_value is empty but allow_empty is false for parameter '%s'",
191 !has_default || !default_value || (strlen(default_value) <= max_str_len),
192 "default_value length %zu exceeds max_str_len %zu for parameter '%s'",
193 default_value ? strlen(default_value) : 0, max_str_len,
name);
195 !is_defined || *value_ptr || allow_NULL,
196 "initial value is NULL but allow_NULL is false for parameter '%s'",
199 !is_defined || !*value_ptr || allow_empty || ((*value_ptr)[0] !=
'\0'),
200 "initial value is empty but allow_empty is false for parameter '%s'",
203 !is_defined || !*value_ptr || (strlen(*value_ptr) <= max_str_len),
204 "initial value length %zu exceeds max_str_len %zu for parameter '%s'",
205 (is_defined && *value_ptr) ? strlen(*value_ptr) : 0, max_str_len,
name);
#define YAC_ASSERT(exp, msg)
yac_param_scalar_kind
Scalar parameter storage kind.
@ YAC_PARAM_SCALAR_KIND_STR
Scalar value backed by string storage.
yac_param_type
Parameter type for generic configuration interface.
@ YAC_PARAM_TYPE_SCALAR
Single typed value (e.g., int, double, string, enum)
#define YAC_PARAM_ASSERT(COND,...)
#define YAC_PARAM_CHECK_BASIC()
static int yac_param_str_get_scalar(const struct yac_param *param, char *buf, size_t buflen)
static const char * yac_param_str_get_name(const struct yac_param *param)
static int yac_param_str_get_scalar_kind(const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind)
static const struct yac_param_vtable yac_param_str_vtable
static int yac_param_str_set_scalar(struct yac_param *param, const char *value_str)
static int yac_param_str_is_default(const struct yac_param *param)
Check if the string parameter is at its default value.
static enum yac_param_type yac_param_str_get_type(const struct yac_param *param)
struct yac_param * yac_param_str_new(const char *name, char **value_ptr, const char *default_value, int allow_NULL, int allow_empty, size_t max_str_len, int has_default, int is_defined)
Create a string parameter.
static void yac_param_str_delete(struct yac_param *param)
const struct yac_param_vtable * vtable
enum yac_param_type(* get_type)(const struct yac_param *param)
#define YAC_ASSERT_F(exp, format,...)