@@ -9,34 +9,39 @@ Yet another `.ini` parser for modern c++ (made for cpp17), inspired and extend f
99
1010## Example
1111
12+ The ` config.ini ` 's content is something looks like:
13+
14+ ```
15+ [section1]
16+ any=5
17+
18+ [section2]
19+ any_vec = 1 2 3
20+ ```
21+
1222``` cpp
13- #include " ini/INIReader .h"
23+ #include " ini/ini .h"
1424
1525int main () {
1626 inih::INIReader r{"./test/fixtures/config.ini"};
1727
28+ // Get and parse the ini value
1829 const auto& v1 = r.Get<std::string>("section1", "any"); // "5"
1930 const auto& v2 = r.Get<int>("section1", "any"); // 5
2031 const auto& v3 = r.Get<double>("section1", "any"); // 5.0
2132 const auto& v4 = r.GetVector<float>("section2", "any_vec"); // [1.0, 2.0, 3.0]
2233 const auto& v5 = r.GetVector<std::string>("section2", "any_vec"); // ["1", "2", "3"]
2334
35+ // And also support writing to new ini file.
36+ r.InsertEntry("new_section", "key1", 5); // section and key not exist
37+ inih::INIWriter::write ("output.ini", r); // Dump ini to file
38+
2439 return 0;
2540}
2641```
2742
28- The ` config.ini ` 's content is something looks like:
29-
30- ```
31- [section1]
32- any=5
33-
34- [section2]
35- any_vec = 1 2 3
36- ```
37-
3843To learn more, please refer to [ test folder] ( https://github.com/SSARCandy/ini-cpp/tree/master/test ) , it covered ALL utilities.
3944
4045## Install
4146
42- Simply copy the header file ` ini/INIReader .h ` to your project, then done.
47+ Simply copy the header file ` ini/ini .h ` to your project, then done.
0 commit comments