Giter VIP home page Giter VIP logo

ini-rw's Introduction

ini-rw

Programming language Licence Code size Contributors

ini-rw: A .ini file reader and writer library programmed in C++17.

Features

  • Ability to open .ini files for either:
    • Reading
    • Writing
  • Ability to save changes to a .ini file if modified
  • Inline comment support for .ini sections and keys

Example

#include "IniFile.hpp"
#include <iostream>
#include <string>

int main()
{
    inirw::IniFile iniFile("path_to_ini_file");

    if (iniFile) // You could also use iniFile.is_loaded() instead
    {
        inirw::IniKey* iniKey = iniFile.get_key("section_name", "key_name");

        if (iniKey)
        {
            std::cout << "INI key information:\n";
            std::cout << "====================\n";
            std::cout << "Section: " << iniKey->get_section()->get_name() << '\n';
            std::cout << "Value: " << iniKey->ValueCommentPair.get_value() << '\n';
            std::cout << "Comment: " << iniKey->ValueCommentPair.get_comment() << '\n' << '\n';
        }
        else
        {
            std::cout << "The INI key was not found.\n";
        }

        iniFile.write_key_value<std::string>("library", "name", "ini-rw");
        iniFile.write_key_value<int>("library", "cpp_standard", 17);
        iniFile.write_key_value<bool>("library", "is_open_source", true);

        // Insert a pound symbol comment at the top of the loaded INI file
        iniFile.insert_comment(inirw::IniCommentPrefix::Pound, "Hello, World!");

        if (iniFile.save_changes())
        {
            std::cout << "The INI file was saved successfully!\n";
        }
    }
    else
    {
        std::cout << "Unable to open the INI file.\n";
    }
}

ini-rw's People

Contributors

beardedfish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ini-rw's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.