IconThemeFile.IconThemeReadOptions

Options to manage icon theme file reading

Constructors

this
this(Args args)

Setting parameters in any order, leaving not mentioned ones in default state.

Alias This

baseOptions

Members

Variables

baseOptions
IniLikeFile.ReadOptions baseOptions;

Base inilike.file.IniLikeFile.ReadOptions.

extensionGroupPolicy
ExtensionGroupPolicy extensionGroupPolicy;

Set policy about extension groups. By default they are all preserved. Set it to skip if you're not willing to support any extensions in your applications. Note that all groups still need to be preserved if desktop file must be rewritten.

unknownGroupPolicy
UnknownGroupPolicy unknownGroupPolicy;

Set policy about unknown groups. By default they are skipped without errors. Note that all groups still need to be preserved if desktop file must be rewritten.

Examples

        string contents =
`[Icon Theme]
Name=Theme
[X-SomeGroup]
Key=Value`;

        alias IconThemeFile.IconThemeReadOptions IconThemeReadOptions;

        auto iconTheme = new IconThemeFile(iniLikeStringReader(contents), IconThemeReadOptions(ExtensionGroupPolicy.skip));
        assert(iconTheme.group("X-SomeGroup") is null);

    contents =
`[Icon Theme]
Name=Theme
[/invalid group]
$=StrangeKey`;

        iconTheme = new IconThemeFile(iniLikeStringReader(contents), IconThemeReadOptions(UnknownGroupPolicy.preserve, IniLikeGroup.InvalidKeyPolicy.save));
        assert(iconTheme.group("/invalid group") !is null);
        assert(iconTheme.group("/invalid group").value("$") == "StrangeKey");

    contents =
`[X-SomeGroup]
Key=Value`;

        auto thrown = collectException!IniLikeReadException(new IconThemeFile(iniLikeStringReader(contents)));
        assert(thrown !is null);
        assert(thrown.lineNumber == 0);

        contents =
`[Icon Theme]
Valid=Key
$=Invalid`;

        assertThrown(new IconThemeFile(iniLikeStringReader(contents)));
        assertNotThrown(new IconThemeFile(iniLikeStringReader(contents), IconThemeReadOptions(IniLikeGroup.InvalidKeyPolicy.skip)));

        contents =
`[Icon Theme]
Name=Name
[/invalidpath]
Key=Value`;

        assertThrown(new IconThemeFile(iniLikeStringReader(contents), IconThemeReadOptions(UnknownGroupPolicy.throwError)));
        assertNotThrown(iconTheme = new IconThemeFile(iniLikeStringReader(contents), IconThemeReadOptions(UnknownGroupPolicy.preserve)));
        assert(iconTheme.cachePath().empty);
        assert(iconTheme.group("/invalidpath") !is null);
    

Meta