diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-05-08 00:11:09 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-05-11 15:18:02 -0700 |
commit | 1a8abe80dabd6b723897fc507808db30b126b3a4 (patch) | |
tree | d60a084d6b6b44b9fffe76864e00ed6d7176f2ad /src/til_settings.h | |
parent | a409d9fd5d861d52dca0e4ed33416a49b00ae2d9 (diff) |
til_settings: rework setting get/add for bare values
The core thing here is rather than turning a bare value into a
key as I was doing before - we just leave the bare value as a
bare value and its setting must be located positionally via
get_value_by_idx since there's no key.
Existing callers that used to get_key() positionally now
get_value_by_idx() positionally all the same, except it's the
value instead of the key. This is mostly done for things like
the module or fb name at the front of a settings instance.
The impetus for this change is partially just
cosmetic/ergonomics, but it's also rather strange for what's
really a key-less value to be treated as a value-less key. It
was also awkward to talk/reason about on the road to recursive
settings where bare values would be supported as a standalone
settings instance if properly escaped...
This also adds unescaping of keys, and adds a dependency on the
somewhat linux-specific open_memstream() which may need changing
in the future (see comments).
Diffstat (limited to 'src/til_settings.h')
-rw-r--r-- | src/til_settings.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/til_settings.h b/src/til_settings.h index 8911e6c..c9da235 100644 --- a/src/til_settings.h +++ b/src/til_settings.h @@ -37,9 +37,9 @@ struct til_setting_t { til_settings_t * til_settings_new(const char *label, const char *settings); til_settings_t * til_settings_free(til_settings_t *settings); -const char * til_settings_get_value(const til_settings_t *settings, const char *key, til_setting_t **res_setting); -const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, til_setting_t **res_setting); -int til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc); +const char * til_settings_get_value_by_key(const til_settings_t *settings, const char *key, til_setting_t **res_setting); +const char * til_settings_get_value_by_idx(const til_settings_t *settings, unsigned idx, til_setting_t **res_setting); +til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc); void til_settings_reset_descs(til_settings_t *settings); int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_desc_t *desc, const char **res_value, til_setting_t **res_setting, const til_setting_desc_t **res_desc); char * til_settings_as_arg(const til_settings_t *settings); |