Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/x-rays5/inireader
A simple c++17 header only ini parser/writer.
https://github.com/x-rays5/inireader
cpp cpp17 headeronly ini ini-parser parser
Last synced: 1 day ago
JSON representation
A simple c++17 header only ini parser/writer.
- Host: GitHub
- URL: https://github.com/x-rays5/inireader
- Owner: X-rays5
- License: mit
- Created: 2021-05-18T15:17:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T00:35:17.000Z (19 days ago)
- Last Synced: 2024-10-21T03:51:05.178Z (18 days ago)
- Topics: cpp, cpp17, headeronly, ini, ini-parser, parser
- Language: C++
- Homepage: https://inireader.docsforge.com/
- Size: 150 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# inireader
A simple c++17 header only ini parser/writer.For examples look at the [wiki](https://github.com/X-rays5/inireader/wiki)
# Basic usage```cpp
#include
#include
#include/*
config.ini:foo=bar
[Numbers]
float=3.14
*/int main() {
ini::Parser ini_file;
try {
ini_file.Parse("config.ini");
ini_file.GetRootSection()["foo"] = "bar";
auto float_val = ini_file["Numbers"]["float"].as();std::cout << ini_file.GetRootSection()["foo"].as() << " " << float_val << "\n";
ini_file.GetRootSection().Add("foo", "bar");
ini_file.AddSection("Hello World").Add("foo", "bar");std::ofstream writer("config.ini");
if (writer.is_open())
writer << ini_file.Stringify();
writer.close();
} catch (std::runtime_error& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}return EXIT_SUCCESS;
}
```
# CMake usage
```cmake
cmake_minimum_required(VERSION 3.24)
project(example)set(CMAKE_CXX_STANDARD 17)
add_subdirectory(inireader)
add_executable(${PROJECT_NAME} main.cpp)
# Include the inireader headers via the cmake INTERFACE library API.
target_link_libraries(${PROJECT_NAME} PRIVATE inireader::inireader)```