Skip to content

πŸ“‘ Yet another ini config parser for modern C++

License

Notifications You must be signed in to change notification settings

SSARCandy/ini-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Dec 15, 2024
1c2bd14 Β· Dec 15, 2024

History

69 Commits
Jun 5, 2020
Mar 12, 2023
Mar 12, 2023
Nov 28, 2024
Dec 5, 2021
Jun 5, 2020
May 30, 2020
May 30, 2020
Jun 5, 2020
May 30, 2020
Apr 12, 2023
Dec 15, 2024
Jul 2, 2021
Jul 16, 2021
Jul 28, 2020
Jun 5, 2020

Repository files navigation

C++ INI Parser

C/C++ CI codecov

Yet another .ini parser for modern c++ (made for cpp17), inspired and extend from inih.

Example

The config.ini's content is something looks like:

[section1]
any=5

[section2]
any_vec = 1 2 3
#include "ini/ini.h"

int main() {
    inih::INIReader r{"./test/fixtures/config.ini"};

    // Get and parse the ini value
    const auto& v1 = r.Get<std::string>("section1", "any"); // "5"
    const auto& v2 = r.Get<int>("section1", "any"); // 5
    const auto& v3 = r.Get<double>("section1", "any"); // 5.0
    const auto& v4 = r.GetVector<float>("section2", "any_vec"); // [1.0, 2.0, 3.0]
    const auto& v5 = r.GetVector<std::string>("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, it covered ALL utilities.

Install

Simply copy the header file ini/ini.h to your project, then done.