ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
schema.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#include "../common.h"
17#include <stdbool.h>
18#include <stddef.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23#include "../options/builder.h"
24#include "../options/options.h"
25
34
45typedef bool (*builder_validate_fn_t)(const void *options_struct);
46
53typedef struct {
54 const char
56 const char
60 const char *category;
61 size_t field_offset;
62 size_t field_size;
63
64 // Validation - uses builder's validate function directly
67
68 // Custom parsing for OPTION_TYPE_CALLBACK
69 bool (*parse_fn)(const char *arg, void *dest,
70 char **error_msg);
71
72 // Mode applicability bitmask
74
75 // Documentation
76 const char *description;
77
78 // Type-specific constraints (optional)
79 union {
80 struct {
81 int min;
82 int max;
83 } int_range;
84 struct {
85 double min;
86 double max;
87 } float_range;
88 } constraints;
89
90 // Mode-aware default getter (for options with mode-specific defaults)
91 const void *(*mode_default_getter)(
93 mode);
98
105config_schema_get_by_toml_key(const char *toml_key);
106
114config_schema_get_by_category(const char *category, size_t *count);
115
122
139 size_t num_configs);
140
150void config_schema_destroy(void);
151
152#ifdef __cplusplus
153}
154#endif
Options builder API for flexible command-line option configuration.
option_type_t
Custom help section descriptor.
Definition builder.h:180
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
asciichat_mode_t
Mode type for options parsing.
Definition options.h:916
option_mode_bitmask_t
Option mode bitmask.
Definition options.h:933
⚙️ Common definitions, error codes, macros, and types shared throughout the application
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
const config_option_metadata_t ** config_schema_get_by_category(const char *category, size_t *count)
Get all option metadata for a category.
Definition schema.c:414
void config_schema_destroy(void)
Clean up dynamically allocated schema resources.
Definition schema.c:467
option_context_t
Context where an option can appear.
Definition schema.h:29
@ OPTION_CONTEXT_BOTH
Can appear in both CLI and config.
Definition schema.h:32
@ OPTION_CONTEXT_CONFIG
Config-only option (never on CLI).
Definition schema.h:31
@ OPTION_CONTEXT_CLI
CLI-only option (cannot appear in config).
Definition schema.h:30
const config_option_metadata_t * config_schema_get_all(size_t *count)
Get all option metadata.
Definition schema.c:447
asciichat_error_t config_schema_build_from_configs(const options_config_t **configs, size_t num_configs)
Build schema dynamically from options builder configs.
Definition schema.c:250
const config_option_metadata_t * config_schema_get_by_toml_key(const char *toml_key)
Get option metadata by TOML key.
Definition schema.c:393
bool(* builder_validate_fn_t)(const void *options_struct)
Validation function from options builder.
Definition schema.h:45
Option metadata for config file parsing.
Definition schema.h:53
option_context_t context
Where this option can appear.
Definition schema.h:59
option_type_t type
Value type (from builder).
Definition schema.h:58
size_t field_size
Size of field in options_t.
Definition schema.h:62
bool(* parse_fn)(const char *arg, void *dest, char **error_msg)
Custom parser for callbacks (or NULL).
Definition schema.h:69
option_mode_bitmask_t mode_bitmask
Which modes this option applies to.
Definition schema.h:73
size_t field_offset
offsetof(options_t, field) - where to store value
Definition schema.h:61
const char * description
Description for docs/help generation.
Definition schema.h:76
const char * category
Category name (e.g., "network", "client", "audio").
Definition schema.h:60
builder_validate_fn_t validate_fn
Definition schema.h:65
const char * toml_key
TOML key path (e.g., "network.port", "client.address").
Definition schema.h:55
const char * cli_flag
CLI flag name (e.g., "--port") or NULL if no CLI flag.
Definition schema.h:57
Immutable parsing tables produced from an options builder.
Definition builder.h:456