16 if (value < min || value > max)
58 for (
size_t i = 0; i < cfg.
count; i++)
72 static bool is_valid_choice(
const cfg_enum_t *options,
size_t value)
75 size_t len = options->
count;
77 for (
size_t i = 0; i < len; i++)
80 if (choice.
value == value)
99 static void set_flag(
cfg_field_t *field,
size_t value,
bool set)
119 for (
size_t i = 0; i < cfg.
count; i++)
124 set_flag(field, option.
value, set);
133 static bool is_valid_flag(
const cfg_enum_t *options,
size_t value)
135 if (value == 0)
return true;
138 size_t len = options->
count;
140 size_t remaining = value;
141 for (
size_t i = 0; i < len; i++)
144 if (choice.
value != 0 && remaining & choice.
value)
146 remaining &= ~choice.
value;
150 return remaining == 0;
#define ASSERT_FIELD_TYPE(field, type)
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
CT_NODISCARD CT_PUREFN CT_BASE_API bool str_equal(const char *lhs, const char *rhs)
compare strings equality
STA_DECL void cfg_vector_push(cfg_field_t *field, char *value)
push a new value onto an array field
STA_DECL bool cfg_set_int(cfg_field_t *field, int value)
set the current value of an int field
STA_DECL void cfg_set_enum_value(cfg_field_t *field, size_t value)
set the current value of an enum field set the value via an integer value
STA_DECL bool cfg_set_flag(cfg_field_t *field, const char *choice, bool set)
set the current value of a flags field set the value via a string name
STA_DECL void cfg_set_string(cfg_field_t *field, char *value)
set the current value of a string field
STA_DECL bool cfg_set_enum(cfg_field_t *field, const char *choice)
set the current value of an enum field set the value via a string name
STA_DECL void cfg_set_bool(cfg_field_t *field, bool value)
set the current value of a bool field
STA_DECL void cfg_set_flag_value(cfg_field_t *field, size_t value)
set the current value of a flags field set the value via an integer value
#define CTASSERT(expr)
assert a condition, prints the condition as a message
#define CT_PARANOID_ASSERTF(expr,...)
assert a condition with a message and optional format arguments
CT_STD_API void vector_push(vector_t **vector, void *value)
push a value onto the end of a vector
a choice in a set of options
STA_FIELD_STRING const char * text
the name of this choice
size_t value
the value of this choice
a choice from a set of options
size_t count
the number of choices in this set
STA_FIELD_STRING const char * name
the name of this field