-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.cpp
More file actions
executable file
·73 lines (52 loc) · 1.57 KB
/
start.cpp
File metadata and controls
executable file
·73 lines (52 loc) · 1.57 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "entity.hpp"
#include <cassert>
#include <iostream>
using CField = ipgdlib::entity::CField<unsigned char>;
using CFields = ipgdlib::entity::CFields<unsigned char, unsigned char,CField>;
using CEntity = ipgdlib::entity::CEntity<CFields>;
int main(int argc,char * argv[])
{
CFields fCustomer(
{
{"id",sizeof(unsigned int)},
{"name",sizeof(char*)},
{"sex",sizeof(char)},
{"age",sizeof(unsigned char)}
});
assert(fCustomer.count() == 4);
// Create Unique Entity
CEntity::Unique eCustomer(fCustomer);
// Create Shared Entity
CEntity::Shared eSharedCustomer(eCustomer);
// Access
// - Using Copy Memory
unsigned int id;
id = 20;
eCustomer.copyAttrFrom(0,&id);
id = 0;
eCustomer.copyAttrTo("id",&id);
assert(id == 20);
id = 30;
eCustomer.copyAttrFrom("id",&id);
id = 0;
eCustomer.copyAttrTo(0,&id);
assert(id == 30);
// - Using As Method
eCustomer.as<char>(2) = 'F';
assert(eCustomer.as<char>("sex") == 'F');
eCustomer.as<char>("sex") = 'M';
assert(eCustomer.as<char>(2) == 'M');
/*
// - Using Custom Type
CCTPrimitive<unsigned char> ctAge;
eCustomer.toCustomType(3,ctAge);
ctAge = 20;
assert((ctAge == 20));
assert((eCustomer.as<unsigned char>("age") == 20));
eCustomer.toCustomType("age",ctAge);
ctAge = 30;
assert((ctAge == 30));
assert((eCustomer.as<unsigned char>(3) == 30));
*/
return 0;
}