ini



void loadINI(char[] filename, void delegate(char[] name) encounteredSection, void delegate(char[] name, char[] value) encounteredValue);
Loads an ini style file, calling the delegates when it encounters a data.

It loads the file filename, which should be in a format of [section] # comment name = value ; comment

name = { multi line value }

It calls the delegate encounteredSection, passing it the name of the section as an argument. This is case sensitive, so if the file has [section] it will call encounteredSection("section"); and if it says [Section] it will call encounteredSection("Section");.

It calls the delegate encounteredValue with the name / value pair when it encounters one, cutting off leading and trailing whitespace of the value. Whitespace in the middle of the value is preserved.

The name passed is converted to lowercase and has all whitespace stripped from it. So if it encounters:

some Name = Hello

It will call encounteredValue("somename", "Hello");.

It does not currently pass the current section name to the encounteredValue function in any way. As of this version, it is your responsibility to keep track of that if you need it.

bool toBool(char[] str);
toBool:
attempts to convert a string that might be found in the ini to a boolean value.

See the source for its details; this function is only about 15 lines long.


Page generated by Ddoc.