From 7ee1aab7286d529d5ae8e32ef0c43bef1cab912a Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sun, 1 Jul 2018 22:26:27 +0200 Subject: core: add macros to replace getter functions Add macros to handle full getter functions Remark: it is assumed the name of getter function is identical to the name in struct preferences. Signed-off-by: Jan Iversen --- core/settings/qPref_private.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'core/settings/qPref_private.h') diff --git a/core/settings/qPref_private.h b/core/settings/qPref_private.h index e2e8f350c..ebe266581 100644 --- a/core/settings/qPref_private.h +++ b/core/settings/qPref_private.h @@ -101,4 +101,36 @@ void qPref ## class::disk_ ## field(bool doSync) \ { \ LOADSYNC_TXT(name, field); \ } + + +//******* Macros to generate get function +#define GET_PREFERENCE_BOOL(class, field) \ +bool qPref ## class::field () const \ +{ \ + return prefs.field; \ +} + +#define GET_PREFERENCE_DOUBLE(class, field) \ +double qPref ## class::field () const \ +{ \ + return prefs.field; \ +} + +#define GET_PREFERENCE_ENUM(class, type, field) \ +struct type qPref ## class:: ## field () const \ +{ \ + return prefs.field; \ +} + +#define GET_PREFERENCE_INT(class, field) \ +int qPref ## class::field () const \ +{ \ + return prefs.field; \ +} + +#define GET_PREFERENCE_TXT(class, field) \ +const QString qPref ## class::field () const \ +{ \ + return prefs.field; \ +} #endif -- cgit v1.2.3-70-g09d2