20 self->callback = event;
43 map_set(self->event_lookup, param, events);
55 CT_NEVER(
"a flag `%s` already exists (new: %s, old: %s)", arg, info->
name, prev->
name);
69 for (
size_t i = 0; i < args.
count; i++)
72 add_arg(ap, arg.
arg, field);
80 for (
size_t i = 0; i < field_count; i++)
83 add_single_field(ap, field);
88 for (
size_t i = 0; i < group_count; i++)
91 add_config_fields(ap, group);
104 self->config = config;
109 self->posarg_callbacks =
vector_new(16, arena);
118 ARENA_IDENTIFY(self->posarg_callbacks,
"posarg_callbacks",
self, arena);
123 add_config_fields(
self, config);
136 add_config_fields(
self, self->config);
144 ap_callback_t *fn = ap_callback_new(callback, data, self->arena);
149 add_pos_callback(
self, fn);
153 add_arg_callback(
self, param, fn);
162 return self->posargs;
170 return self->unknown;
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
size_t ap_count_params(ap_t *self)
get the number of processed arguments
STA_DECL vector_t * ap_get_unknown(ap_t *self)
get all unknown arguments
void ap_event(ap_t *self, const cfg_field_t *param, ap_event_t callback, void *data)
add a callback event to a parameter
ap_t * ap_new(cfg_group_t *config, arena_t *arena)
create a new parser instance
void ap_update(ap_t *self)
update the parser with the latest config
STA_DECL vector_t * ap_get_posargs(ap_t *self)
get all positional arguments
bool(* ap_event_t)(ap_t *ap, const cfg_field_t *param, const void *value, void *data)
callback for a parameter event called when a parameter is parsed return true to indicate the event wa...
STA_DECL vector_t * ap_get_errors(ap_t *self)
get all errors
CT_PUREFN CT_CONFIG_API typevec_t * cfg_get_groups(const cfg_group_t *config)
get all subgroups in a configuration group
CT_PUREFN CT_CONFIG_API vector_t * cfg_get_fields(const cfg_group_t *config)
get all fields in a configuration group
CT_PUREFN CT_CONFIG_API const cfg_info_t * cfg_get_info(const cfg_field_t *field)
get the information about a configuration field
CT_NODISCARD CT_STD_API map_t * map_optimal(size_t size, hash_info_t info, arena_t *arena)
create a new map with an optimal size
CT_STD_API void map_reset(map_t *map)
clear all key-value pairs from a map
CT_STD_API void map_set(map_t *map, const void *key, void *value)
set a key-value pair in a map
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get(const map_t *map, const void *key)
get a value from a map
#define ARENA_IDENTIFY(ptr, name, parent, arena)
rename and reparent a pointer in a custom allocator
#define ARENA_REPARENT(arena, ptr, parent)
reparent a pointer in a custom allocator
#define ARENA_MALLOC(size, name, parent, arena)
allocate memory from a custom allocator
#define CT_NEVER(...)
assert that a code path is never reached
#define CTASSERT(expr)
assert a condition, prints the condition as a message
CT_STD_API const hash_info_t kTypeInfoString
type information for a c style string
CT_STD_API const hash_info_t kTypeInfoPtr
type information for a generic pointer this operates on the pointer itself and not the data it points...
CT_NODISCARD CT_PUREFN CT_STD_API size_t typevec_len(const typevec_t *vec)
get the length of a vector
CT_NODISCARD CT_PUREFN CT_STD_API void * typevec_offset(const typevec_t *vec, size_t index)
get a pointer to the value at the given index
CT_NODISCARD CT_PUREFN CT_STD_API void * vector_get(const vector_t *vector, size_t index)
get a value from a vector
CT_NODISCARD CT_STD_API vector_t * vector_new(size_t size, arena_t *arena)
create a new vector with an initial capacity
CT_STD_API void vector_push(vector_t **vector, void *value)
push a value onto the end of a vector
CT_NODISCARD CT_STD_API vector_t * vector_init(void *value, arena_t *arena)
create a new vector with a single initial value
CT_NODISCARD CT_PUREFN CT_STD_API size_t vector_len(const vector_t *vector)
get the length of a vector
map_t * name_lookup
a mapping of names to parameters
information about a configuration field
cfg_arg_array_t args
the spellings to use for this field
STA_FIELD_STRING const char * name
the name of this field
A vector with a fixed type size.
a generic vector of pointers