iniLikeRangeReader

Convenient function for creation of IniLikeReader instance.

iniLikeRangeReader
(
Range
)
(
Range range
)

Parameters

range Range

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

Return Value

Type: auto

IniLikeReader for given range.

Examples

    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 byFirstLines = r.byFirstLines;
    
    assert(byFirstLines.front == "First comment");
    assert(byFirstLines.equal(["First comment", "Second comment"]));
    
    auto byGroup = r.byGroup;
    
    assert(byGroup.front.name == "First group");
    assert(byGroup.front.originalLine == "[First group]");
    //assert(byGroup.map!(g => g.name).equal(["First group", "Second group", "Empty group", "Third group"]));
    
    
    assert(byGroup.front.byEntry.front == "KeyValue1");
    assert(byGroup.front.byEntry.equal(["KeyValue1", "KeyValue2"]));
    byGroup.popFront();
    assert(byGroup.front.name == "Second group");
    byGroup.popFront();
    assert(byGroup.front.name == "Empty group");
    assert(byGroup.front.byEntry.empty);
    byGroup.popFront();
    assert(byGroup.front.name == "Third group");
    byGroup.popFront();
    assert(byGroup.empty);

See Also

iniLikeFileReader, iniLikeStringReader

Meta