- 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=
, andkey
. - Tiny (~75 LOC), cross-platform, self-contained and header-only.
- Zlib/libpng licensed.
#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;
}
mINI> ./sample
; auto-generated by mINI class {
[added]
number=456
string=new string
[test]
number=123
string=hello world
; } ---
mINI>
- 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