Is yet another ini file format parser which was created to eliminate my Qt dependency. Sure, I could use one of the thousand already existing ones which are also small and cute, but there is no fun along this path.
- Groups
- Comments which start at the beginning of a line
;and#can be used to start a commet- Key/value pairs separated by
= - UTF8 seems to work by magic
- Values of the folowing types: string, integer
- Writing an Ini object back to string
- Converting
trueandfalseinto equivalent boolean type
- Interpreting line breaks in values
- If an Ini object is written back into string it ignores comments and the order used in the original file.
; This is a comment starting with an semicolon.
# You could also use the diamond as well.
# But please be sure not to put anything in front.
root_key=value
numbers=1024
boolean1=true
boolean2=t
boolean3=1
[group]
# Does not hurt to put comments in a group
group_key="another \"small\" value"
with_line_breaks=long\ntextThe library itself gives nothing about the source of the INI data. You just have to pass a string and check the result value for success. If anything went wrong, it will tell you why if possible.
std::string init_data = "...";
rsettings::Ini settings;
try
{
settings.parse(ini_data);
}
catch (rsettings::ParserError const& e)
{
std::cout << e.what() << std::endl;
exit(1);
}
bool value = settings.get<bool>("variable_name", false)One day you might get the fancy idea to convert the Ini object back into the INI format after doing a change or two.
std::string ini_data = settings.write();