-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmacro_reg.cpp
More file actions
39 lines (30 loc) · 735 Bytes
/
Copy pathmacro_reg.cpp
File metadata and controls
39 lines (30 loc) · 735 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
31
32
33
34
35
36
37
38
39
#include "struct_mapping/struct_mapping.h"
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
BEGIN_STRUCT(Planet)
MEMBER(bool, giant)
MEMBER(long long, surface_area)
MEMBER_OPTIONS(
double,
mass,
struct_mapping::Bounds{1.0e23, 1.0e27},
struct_mapping::Default{1.0e25})
MEMBER(std::vector<std::string>, satellites)
END_STRUCT
int main()
{
std::istringstream json_data(R"json(
{
"giant": false,
"surface_area": 510072000000000,
"satellites": ["Moon", "R24"]
}
)json");
Planet earth;
struct_mapping::map_json_to_struct(earth, json_data);
std::ostringstream out_json_data;
struct_mapping::map_struct_to_json(earth, out_json_data, " ");
std::cout << out_json_data.str() << std::endl;
}