Coder Social home page Coder Social logo

ini-editor's Introduction

ini-editor

A simple library to read and write ini files. Written in c++.

Features and Ini Style

  • line comments can start with # or ;.

  • a name cannot contain a = character, while a section cannot contain a ] character.

  • name and value can only be divided by =.

  • duplicate key (same name same section) won't give errors but only the first value will be kept.

  • whitespace around section, name and value are removed.

  • key output is in the form name = value (with spaces around =).

  • when saving with a source stream/file comments are preserved.

  • programmatically deleted keys are not saved to output, however if the specified source has a key not present in the editor it will be preserved.

Usage

Use ini::Editor to load and save ini files.

Examples

  • Load from file
ini::Editor editor;
editor.loadFromFile("path_to_file.ini");
  • Access content
// Set a new key or overwrite an old one
// if section and name are already present
editor.set("section", "name", "value");

// Get a value
std::string value = "default";
if (editor.get("section", "name", value))
	// Value found. value == "found_value"
else
	// Value not found. value == "default"

// Remove a key
editor.remove("section", "name");

// Check if a key exist
if (editor.has("secition", "name"))
	// Exist
else
	// Do not exist
  • Save to file
// Save it in a new file
editor.saveToFile("new_file.ini");

// Save it adapting to an existing .ini file
// adding new keys or altering existing ones
// mantaining its structure.
editor.saveToFile("new_file.ini", "existing_source.ini")

// When you want to overwrite the
// existing file just use
editor.saveChangesToFile("file.ini"); // same as editor.saveToFile("file.ini", "file.ini")

Testing

This project uses the GoogleTest framework. It is required to have the GTest library installed on your system to run tests as it uses the CMake command find_package() to find it.

Note

This is a university project made for an exam.

ini-editor's People

Contributors

frassom avatar

Stargazers

 avatar

ini-editor'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.