I will just point you to the Clang / LLVM project.
In this project, they created a way to encode data using a simple descriptive language, which is then loaded into a tool (called tblgen for the Generator Table) that is designed to create a C ++ file. For example, diagnostics :
let Component = "Sema" in { let CategoryName = "Semantic Issue" in {
Clang has several thousand diagnostic tools separated by several files. After tblgen processing, they will generate a huge .inc file, which for each diagnostics will contain a macro call. By defining a macro and including the file, you can create a C ++ table (or something else actually, but use it usually for tables):
static const StaticDiagInfoRec StaticDiagInfo[] = { #define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP, \ SFINAE,ACCESS,NOWERROR,SHOWINSYSHEADER, \ CATEGORY,BRIEF,FULL) \ { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, ACCESS, \ NOWERROR, SHOWINSYSHEADER, CATEGORY, \ STR_SIZE(#ENUM, uint8_t), STR_SIZE(GROUP, uint8_t), \ STR_SIZE(DESC, uint16_t), STR_SIZE(BRIEF, uint16_t), \ STR_SIZE(FULL, uint16_t), \ #ENUM, GROUP, DESC, BRIEF, FULL }, #include "clang/Basic/DiagnosticCommonKinds.inc" #include "clang/Basic/DiagnosticDriverKinds.inc" #include "clang/Basic/DiagnosticFrontendKinds.inc" #include "clang/Basic/DiagnosticLexKinds.inc" #include "clang/Basic/DiagnosticParseKinds.inc" #include "clang/Basic/DiagnosticASTKinds.inc" #include "clang/Basic/DiagnosticSemaKinds.inc" #include "clang/Basic/DiagnosticAnalysisKinds.inc" #undef DIAG { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} };
And the same files can create different tables, since you can write macros as you wish.
This, of course, is a very specific use.
But donโt worry, although the modules didnโt get into C ++ 11, we can hope for C ++ 1x.