Master92 / cppIni

A C++20 library for reading and writing INI files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cppIni - A C++20 library for reading and writing INI files

Release Build License GitHub stars

Features

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.

Reading and manipulating INI files

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.

Usage

#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);

License

cppIni is licensed under the MIT license. See COPYING for more information.

About

A C++20 library for reading and writing INI files

License:GNU General Public License v3.0


Languages

Language:C++ 92.7%Language:CMake 5.1%Language:C 2.2%