Personal all-purpose utility library
Go to file
2019-08-24 13:38:58 +10:00
Code Fix bugs in making linked buffers 2019-08-24 13:38:58 +10:00
Data Change inspect function macro to DQN_INSPECT_FUNCTION 2019-05-03 20:23:14 +10:00
Project/Msvc Allow arbitrary meta properties on enum fields 2019-04-01 00:51:14 +11:00
.gitignore Initial commit 2017-04-09 15:08:31 +10:00
readme.md Move readme to root 2019-02-23 15:41:53 +11:00

Dqn

Personal utility library.

DqnInspect

A simple C++ introspection metaprogram designed as a prebuild step and generates type information for the inspected types. It is a minimal single header file licensed in the public domain with only CRT dependencies. It is only able to parse C-like C++, i.e. Plain Old Data types only.

The generated file is written to stdout.

Usage

Annotate the C++ code using DQN_INSPECT, i.e.

DQN_INSPECT struct Entity
{
    V2 pos;
    V2 size;
}

DQN_INSPECT enum struct SomeEnum
{
    Hello,
    Foo
}

And then build DqnInspect by defining DQN_INSPECT_EXECUTABLE_IMPLEMENTATION before compiling and execute it as follows

DqnInspect.exe SourceCode.h > SourceCodeInspected.h

Include and use the file in code

#include "DqnReflect.h"
#include "SourceCode.h"
#include "SourceCodeInspected.h"
SomeEnum enum = SomeEnum::Hello;
printf("%s\n", DqnInspect_EnumString(enum)); // prints Hello

Entity entity = {};
DqnInspect_Struct const *inspector = DqnInspect_GetStruct(&entity);
for (int i = 0; i < inspector->members_len; ++i)
    printf("%s\n", inspector->members[i].name);