From 3245b81e6074f06a026dc057096c8333b18064b7 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 16 Jul 2020 15:19:09 +0200 Subject: [PATCH] [settings] Add shorthand macros for getting/setting options --- src/settings.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/settings.h b/src/settings.h index 4c910090..c614021f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -28,7 +28,7 @@ struct settings_category { int -settings_categories_count(); +settings_categories_count(void); struct settings_category * settings_category_get_byindex(int index); @@ -40,10 +40,10 @@ int settings_option_count(struct settings_category *category); struct settings_option * -settings_option_get_byindex(struct settings_category *category, int index); +settings_option_get(struct settings_category *category, const char *name); struct settings_option * -settings_option_get(struct settings_category *category, const char *name); +settings_option_get_byindex(struct settings_category *category, int index); int @@ -55,6 +55,10 @@ settings_option_getbool(struct settings_option *option); char * settings_option_getstr(struct settings_option *option); +#define SETTINGS_GETINT(category, name) settings_option_getint(settings_option_get((category), (name))) +#define SETTINGS_GETBOOL(category, name) settings_option_getbool(settings_option_get((category), (name))) +#define SETTINGS_GETSTR(category, name) settings_option_getstr(settings_option_get((category), (name))) + int settings_option_setint(struct settings_option *option, int value); @@ -64,7 +68,14 @@ settings_option_setbool(struct settings_option *option, bool value); int settings_option_setstr(struct settings_option *option, const char *value); +#define SETTINGS_SETINT(category, name, value) settings_option_setint(settings_option_get((category), (name)), (value)) +#define SETTINGS_SETBOOL(category, name, value) settings_option_setbool(settings_option_get((category), (name)), (value)) +#define SETTINGS_SETSTR(category, name, value) settings_option_setstr(settings_option_get((category), (name)), (value)) + + int settings_option_delete(struct settings_option *option); +#define SETTINGS_DELETE(category, name) settings_option_delete(settings_option_get((category), (name))) + #endif /* __SETTINGS_H__ */