Skip to content

r-lyeh-archived/mINI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mINI ▫️

  • mINI is a minimal .INI reader/writer (C++11)
  • Basic usage around std::map<key,value> wrapper.
  • Extendable, key/value types can be redefined (variant sample included).
  • Relaxed spec supported: key=value, key=, and key.
  • Tiny (~75 LOC), cross-platform, self-contained and header-only.
  • Zlib/libpng licensed.

Showcase

#include <iostream>
#include <cassert>

#include "mini.hpp"

int main() {
    // load file
    std::string content =
    "; this is a comment\n"
    "[test\t]\r\n"
    "number = 123\n"
    " \tstring=hello world\r";

    // load content
    mINI ini;
    bool ok = ini.load( content );

    // tests
    assert( ini["test.number"] == "123" );         // symbol value
    assert( ini["test.string"] == "hello world" ); // symbol value

    assert( ini.line("test.number") == 3 );        // line number
    assert( ini.line("test.string") == 4 );        // line number

    // append new symbols
    ini["added.number"] = "456";
    ini["added.string"] = "new string";

    // save and print
    std::cout << ini.save() << std::endl;
}

Possible output

mINI> ./sample
; auto-generated by mINI class {

[added]
number=456
string=new string

[test]
number=123
string=hello world

; } ---

mINI> 

Changelog

  • v1.0.2 (2016/06/02): Allow relaxed spec parsing
  • v1.0.2 (2016/06/02): Renamed methods (load/save to parse/dump)
  • v1.0.2 (2016/06/02): Optional header/footer when dumping
  • v1.0.1 (2016/04/28): Improve symbol trimming
  • v1.0.0 (2015/09/18): Initial version

About

▫️ A very minimal .INI reader/writer (C++11)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages