Function iniLikeRangeReader

Convenient function for creation of IniLikeReader instance.

auto auto iniLikeRangeReader(Range) (
  Range range
);

Parameters

NameDescription
range input range of strings (strings must be without trailing new line characters)

Returns

IniLikeReader for given range.

See Also

iniLikeFileReader, iniLikeStringReader

Example

string contents =
`First comment
Second comment
[First group]
KeyValue1
KeyValue2
[Second group]
KeyValue3
KeyValue4
[Empty group]
[Third group]
KeyValue5
KeyValue6`;
auto r = iniLikeRangeReader(contents.splitLines());

auto byLeadingLines = r.byLeadingLines;

assert(byLeadingLines.front == "First comment");
assert(byLeadingLines.equal(["First comment", "Second comment"]));

auto byGroup = r.byGroup;

assert(byGroup.front.groupName == "First group");
assert(byGroup.front.originalLine == "[First group]");


assert(byGroup.front.byEntry.front == "KeyValue1");
assert(byGroup.front.byEntry.equal(["KeyValue1", "KeyValue2"]));
byGroup.popFront();
assert(byGroup.front.groupName == "Second group");
byGroup.popFront();
assert(byGroup.front.groupName == "Empty group");
assert(byGroup.front.byEntry.empty);
byGroup.popFront();
assert(byGroup.front.groupName == "Third group");
byGroup.popFront();
assert(byGroup.empty);