From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- SQLiteStudio3/coreSQLiteStudio/config_builder.h | 76 +++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 SQLiteStudio3/coreSQLiteStudio/config_builder.h (limited to 'SQLiteStudio3/coreSQLiteStudio/config_builder.h') 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 Name = CfgTypedEntry(#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 -- cgit v1.2.3