-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathMain.cpp
More file actions
30 lines (23 loc) · 690 Bytes
/
Copy pathMain.cpp
File metadata and controls
30 lines (23 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <vector>
#include "Reflect.h"
struct Node {
std::string key;
int value;
std::vector<Node> children;
REFLECT() // Enable reflection for this type
};
int main() {
// Create an object of type Node
Node node = {"apple", 3, {{"banana", 7, {}}, {"cherry", 11, {}}}};
// Find Node's type descriptor
reflect::TypeDescriptor* typeDesc = reflect::TypeResolver<Node>::get();
// Dump a description of the Node object to the console
typeDesc->dump(&node);
return 0;
}
// Define Node's type descriptor
REFLECT_STRUCT_BEGIN(Node)
REFLECT_STRUCT_MEMBER(key)
REFLECT_STRUCT_MEMBER(value)
REFLECT_STRUCT_MEMBER(children)
REFLECT_STRUCT_END()