-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.cpp
60 lines (48 loc) · 1.47 KB
/
main.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <UDRefl/UDRefl.hpp>
#include <iostream>
using namespace Ubpa;
using namespace Ubpa::UDRefl;
struct A {
int data{ 1 };
const int c_data{ 2 };
inline static int s_data{ 3 };
inline static const int sc_data{ 4 };
};
int main() {
Mngr.RegisterType<A>();
Mngr.AddField<&A::data>("data");
Mngr.AddField<&A::c_data>("c_data");
Mngr.AddField(Type_of<A>, "s_data", &A::s_data);
Mngr.AddField(Type_of<A>, "sc_data", &A::sc_data);
A a;
ObjectView ptr{ a };
for (const auto& [name, fieldinfo] : FieldRange_of<A>)
std::cout << name.GetView() << std::endl;
ptr.Var("data") = 10;
ptr.Var("s_data") = 20;
std::cout
<< "//" << std::endl
<< "// unowned var" << std::endl
<< "////////////////" << std::endl;
for (const auto& [name, var] : VarRange_of<A>)
std::cout << name.GetView() << ": " << var << std::endl;
std::cout
<< "//" << std::endl
<< "// var" << std::endl
<< "////////" << std::endl;
for (const auto& [name, var] : ptr.GetVars())
std::cout << name.GetView() << ": " << var << std::endl;
std::cout
<< "//" << std::endl
<< "// owned var" << std::endl
<< "//////////////" << std::endl;
for (const auto& [name, var] : ptr.GetVars(FieldFlag::Owned))
std::cout << name.GetView() << ": " << var << std::endl;
std::cout
<< "//" << std::endl
<< "// unowned var" << std::endl
<< "////////////////" << std::endl;
for (const auto& [name, var] : ptr.GetVars(FieldFlag::Unowned))
std::cout << name.GetView() << ": " << var << std::endl;
return 0;
}