This project is a library for reading and writing INI files. It is written in C++20 and uses the STL. It is tested with GCC 13, Clang 16 and MSVC 19.36. It should work with any compiler that supports C++20.
The library is able to read INI files and parses them automatically. It is able to read the following types:
bool
char
short
int
long
long long
unsigned char
unsigned short
unsigned int
unsigned long
unsigned long long
float
double
long double
std::string
std::string_view
const char*
Accessing a value is done with the get
template-function. It takes the section and the key as parameters and returns
the value as the specified type T
. If the value does not exist, the default value (T()
) is returned.
Setting a value is done with the set
template-function. It takes the section, the key and the value as parameters.
The value is converted to a string and written to the file. If the section or the key does not exist, it is created.
On every write, the file is completely rewritten.
#include <cppIni/cppIni.hpp>
File ini("test.ini");
const auto intValue = init.get<int>("section", "key");
const auto newValue = 42;
ini.set("section", "key", newValue);
cppIni is licensed under the MIT license. See COPYING for more information.