IniLikeGroup.removeEntries

Remove all entries satisying ToDelete function. ToDelete should be function accepting string key and value and return boolean.

class IniLikeGroup
final
void
removeEntries
(
alias ToDelete
)
()

Examples

        string contents = 
`[Group]
Key1=Value1
Name=Value
# Comment
ToRemove=Value
Key2=Value2
NameGeneric=Value
Key3=Value3`;
        auto ilf = new IniLikeFile(iniLikeStringReader(contents));
        assert(ilf.group("Group").removeEntry("ToRemove"));
        assert(!ilf.group("Group").removeEntry("NonExistent"));
        ilf.group("Group").removeEntries!(function bool(string key, string value) {
            return key.startsWith("Name");
        })();
        
        auto group = ilf.group("Group");
        
        assert(group.value("Key1") == "Value1");
        assert(group.value("Key2") == "Value2");
        assert(group.value("Key3") == "Value3");
        assert(equal(group.byIniLine(), [
                    IniLikeLine.fromKeyValue("Key1", "Value1"), IniLikeLine.fromComment("# Comment"), 
                    IniLikeLine.fromKeyValue("Key2", "Value2"), IniLikeLine.fromKeyValue("Key3", "Value3")]));
        assert(!group.contains("Name"));
        assert(!group.contains("NameGeneric"));
    

Meta