-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathini_parser.cpp
More file actions
56 lines (44 loc) · 1.15 KB
/
Copy pathini_parser.cpp
File metadata and controls
56 lines (44 loc) · 1.15 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
#include "ini_parser.h"
// ============================================================
// Domain models
// ============================================================
struct Person {
[[=rename("full_name")]]
std::string name;
[[=default_value(32)]]
int age;
[[=default_value("Chinese")]]
std::string nationality;
};
struct Config {
std::string host;
[[=range(0, 65535)]]
int port;
bool debug;
[[=default_value(5.0f)]]
float timeout;
};
struct FailExample {
[[=length(0, 4)]]
[[=rename("string_val")]]
std::string StringTooLong;
};
// ============================================================
// Composite model — all sections in one struct
// ============================================================
struct AllModels {
Person person;
Config config;
FailExample fail;
};
// ============================================================
// Demo
// ============================================================
int main() {
AllModels all;
IniParser::parse("combined.ini", all);
print_model(all.person);
print_model(all.config);
print_model(all.fail);
return 0;
}