-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.cpp
More file actions
32 lines (26 loc) · 770 Bytes
/
Copy pathtest.cpp
File metadata and controls
32 lines (26 loc) · 770 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
#include "inifile.hpp"
int main()
{
auto ini = util::inifile("test.ini");
if (!ini.good())
{
std::cerr << ini.error_msg() << std::endl;
std::exit(-1);
}
std::cout << "inifile sections:";
for (const auto sec : ini)
{
std::cout << " " << sec.name();
}
std::cout << '\n';
std::cout << "in default section: name = " << ini.get_string("name") << '\n';
ini.set_string("set", "string");
std::cout << "in section `sec1`: test = " << ini.section("sec1").get_int("test") << '\n';
std::cout << "int section `sec2`:\n";
for (const auto [k, v] : ini.section("sec2"))
{
std::cout << k << " = " << v << '\n';
}
std::cout << "\nshow all data:\n--------------\n";
ini.show();
}