diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/coreSQLiteStudio/config_builder.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/config_builder.h')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/config_builder.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/config_builder.h b/SQLiteStudio3/coreSQLiteStudio/config_builder.h new file mode 100644 index 0000000..f4e030e --- /dev/null +++ b/SQLiteStudio3/coreSQLiteStudio/config_builder.h @@ -0,0 +1,76 @@ +#ifndef CFGINTERNALS_H
+#define CFGINTERNALS_H
+
+#include "config_builder/cfgmain.h"
+#include "config_builder/cfgcategory.h"
+#include "config_builder/cfgentry.h"
+#include "config_builder/cfglazyinitializer.h"
+
+#define CFG_CATEGORIES(Type,Body) _CFG_CATEGORIES_WITH_METANAME_AND_TITLE(Type,Body,"",QString())
+
+#define CFG_CATEGORY(Name,Body) \
+ _CFG_CATEGORY_WITH_TITLE(Name,Body,QString())
+
+#define CFG_ENTRY(Type, Name, ...) CfgTypedEntry<Type> Name = CfgTypedEntry<Type>(#Name, ##__VA_ARGS__);
+
+#define CFG_DEFINE(Type) _CFG_DEFINE(Type, true)
+#define CFG_DEFINE_RUNTIME(Type) _CFG_DEFINE(Type, false)
+#define CFG_LOCAL(Type, Name) Cfg::Type Name = Cfg::Type(false);
+#define CFG_LOCAL_PERSISTABLE(Type, Name) Cfg::Type Name = Cfg::Type(true);
+#define CFG_DEFINE_LAZY(Type) \
+ namespace Cfg\
+ {\
+ Type* cfgMainInstance##Type = nullptr;\
+ void init##Type##Instance()\
+ {\
+ cfgMainInstance##Type = new Type(true);\
+ }\
+ Type* get##Type##Instance()\
+ {\
+ return cfgMainInstance##Type;\
+ }\
+ CfgLazyInitializer* cfgMainInstance##Type##LazyInit = new CfgLazyInitializer(init##Type##Instance, #Type);\
+ }
+
+#define CFG_INSTANCE(Type) (*Cfg::get##Type##Instance())
+
+// Macros below are kind of private. You should not need to use them explicitly.
+// They are called from macros above.
+
+#define _CFG_CATEGORIES_WITH_METANAME(Type,Body,MetaName) \
+ _CFG_CATEGORIES_WITH_METANAME_AND_TITLE(Type,Body,MetaName,QString())
+
+#define _CFG_CATEGORIES_WITH_TITLE(Type,Body,Title) \
+ _CFG_CATEGORIES_WITH_METANAME_AND_TITLE(Type,Body,"",Title)
+
+#define _CFG_CATEGORIES_WITH_METANAME_AND_TITLE(Type,Body,MetaName,Title) \
+ namespace Cfg\
+ {\
+ struct API_EXPORT Type : public CfgMain\
+ {\
+ Type(bool persistable) : CfgMain(#Type, persistable, MetaName, Title) {}\
+ Body\
+ };\
+ API_EXPORT Type* get##Type##Instance();\
+ }
+
+#define _CFG_DEFINE(Type, Persistant) \
+ namespace Cfg\
+ {\
+ Type* cfgMainInstance##Type = new Type(Persistant);\
+ Type* get##Type##Instance()\
+ {\
+ return cfgMainInstance##Type;\
+ }\
+ }
+
+#define _CFG_CATEGORY_WITH_TITLE(Name,Body,Title) \
+ struct API_EXPORT _##Name##Type : public CfgCategory\
+ {\
+ _##Name##Type() : CfgCategory(#Name, Title) {}\
+ Body\
+ };\
+ _##Name##Type Name;
+
+
+#endif // CFGINTERNALS_H
|
