summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-09 13:37:57 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-11 15:19:25 -0700
commit9f34bd92ec66dc3dda73a2e3f52fc888b90befbb (patch)
treec80200c5099b708a5266f92cc587508f848f2796
parent31a0147a720f2f0ef30df41512f41f43734662dd (diff)
til_settings: add til_settings_get_count()
Getter for accessing til_settings_t.num With recursive settings modules will start using settings instances to represent things like lists of module names. (modules/compose::layers for instance) For those cases they'll want to know the number of settings in the instance before iterating across getting their values positionally.
-rw-r--r--src/til_settings.c8
-rw-r--r--src/til_settings.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/til_settings.c b/src/til_settings.c
index 0328475..71aefb4 100644
--- a/src/til_settings.c
+++ b/src/til_settings.c
@@ -199,6 +199,14 @@ til_settings_t * til_settings_free(til_settings_t *settings)
}
+unsigned til_settings_get_count(const til_settings_t *settings)
+{
+ assert(settings);
+
+ return settings->num;
+}
+
+
/* find key= in settings, return value NULL if missing, optionally store setting @res_setting if found */
const char * til_settings_get_value_by_key(const til_settings_t *settings, const char *key, til_setting_t **res_setting)
{
diff --git a/src/til_settings.h b/src/til_settings.h
index 4cfddf3..a2dacb8 100644
--- a/src/til_settings.h
+++ b/src/til_settings.h
@@ -43,6 +43,7 @@ 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);
+unsigned til_settings_get_count(const til_settings_t *settings);
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);
© All Rights Reserved