https://github.com/ssarcandy/ini-cpp
📑 Yet another ini config parser for modern C++
https://github.com/ssarcandy/ini-cpp
cmake configparser cpp17 gtest header-only ini ini-parser
Last synced: 7 months ago
JSON representation
📑 Yet another ini config parser for modern C++
- Host: GitHub
- URL: https://github.com/ssarcandy/ini-cpp
- Owner: SSARCandy
- License: other
- Created: 2020-05-30T11:15:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-15T19:17:00.000Z (about 1 year ago)
- Last Synced: 2025-04-10T01:11:38.999Z (11 months ago)
- Topics: cmake, configparser, cpp17, gtest, header-only, ini, ini-parser
- Language: C++
- Homepage: https://ssarcandy.tw/ini-cpp/index.html
- Size: 303 KB
- Stars: 42
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# C++ INI Parser
[](https://github.com/SSARCandy/ini-cpp/actions/workflows/c-cpp.yml)
[](https://codecov.io/gh/SSARCandy/ini-cpp)
Yet another `.ini` parser for modern c++ (made for cpp17), inspired and extend from [inih](https://github.com/benhoyt/inih).
## Example
The `config.ini`'s content is something looks like:
```
[section1]
any=5
[section2]
any_vec = 1 2 3
```
```cpp
#include "ini/ini.h"
int main() {
inih::INIReader r{"./test/fixtures/config.ini"};
// Get and parse the ini value
const auto& v1 = r.Get("section1", "any"); // "5"
const auto& v2 = r.Get("section1", "any"); // 5
const auto& v3 = r.Get("section1", "any"); // 5.0
const auto& v4 = r.GetVector("section2", "any_vec"); // [1.0, 2.0, 3.0]
const auto& v5 = r.GetVector("section2", "any_vec"); // ["1", "2", "3"]
// And also support writing to new ini file.
r.InsertEntry("new_section", "key1", 5); // Create new entry
inih::INIWriter::write("output.ini", r); // Dump ini to file
return 0;
}
```
To learn more, please refer to [test folder](https://github.com/SSARCandy/ini-cpp/tree/master/test), it covered ALL utilities.
## Install
Simply copy the header file `ini/ini.h` to your project, then done.