2019-02-23 04:41:53 +00:00
# Dqn
Personal utility library.
2019-08-27 12:17:59 +00:00
## DqnHeader
A simple C++ introspection metaprogram designed as a prebuild step and generates a summary of function prototypes and comments in a header file based on annotations. It is not designed to be used as a header file for compilation and will most likely fail syntax rules if tried.
2019-02-23 04:41:53 +00:00
The generated file is written to stdout.
2019-08-27 12:17:59 +00:00
### Build
Build DqnHeader by defining `DQN_HEADER_IMPLEMENTATION` before compiling and execute it as follows
`DqnHeader.exe SourceCode.h > GeneratedFile.h`
2019-02-23 04:41:53 +00:00
### Usage
2019-08-27 12:17:59 +00:00
Include `DqnHeader.h` in a file and use the macros, annotations as described.
* Extract function prototypes using the `DQN_HEADER_COPY_PROTOTYPE` macro
* Copy comments by writing comments with `// @` as the prefix
* Copy many lines of code by enclosing it in `DQN_HEADER_COPY_BEGIN` and `DQN_HEADER_COPY_END` macros
2019-02-23 04:41:53 +00:00
```
2019-08-27 12:17:59 +00:00
#include "DqnHeader.h"
2019-02-23 04:41:53 +00:00
2019-08-27 12:17:59 +00:00
// @ ptr1: Pointer to the first block of memory
// @ ptr2: Pointer to the second block of memory
// @ num_bytes: The number of bytes to compare in both blocks of memory
DQN_HEADER_COPY_PROTOTYPE(int, Dqn_MemCmp(void const *ptr1, void const *ptr2, size_t num_bytes))
2019-02-23 04:41:53 +00:00
{
2019-08-27 12:17:59 +00:00
int result = memcmp(ptr1, ptr2, num_bytes);
return result;
2019-02-23 04:41:53 +00:00
}
2019-08-27 12:17:59 +00:00
DQN_HEADER_COPY_BEGIN
struct HelloWorld
{
int foo, bar;
};
DQN_HEADER_COPY_END
2019-02-23 04:41:53 +00:00
2019-08-27 12:17:59 +00:00
```
2019-02-23 04:41:53 +00:00
2019-08-27 12:17:59 +00:00
Which generates the following output
2019-02-23 04:41:53 +00:00
```
2019-08-27 12:32:27 +00:00
// ptr1: Pointer to the first block of memory
// ptr2: Pointer to the second block of memory
// num_bytes: The number of bytes to compare in both blocks of memory
2019-08-27 12:17:59 +00:00
int Dqn_MemCmp(void const *ptr1, void const *ptr2, size_t num_bytes);
struct HelloWorld
{
int foo, bar;
};
2019-02-23 04:41:53 +00:00
```
2019-08-27 12:17:59 +00:00