Struct IconThemeFile.IconThemeReadOptions

Options to manage icon theme file reading

struct IconThemeReadOptions ;

Constructors

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

Fields

NameTypeDescription
baseOptions IniLikeFile.ReadOptionsBase IniLikeFile.ReadOptions.
extensionGroupPolicy IconThemeFile.ExtensionGroupPolicySet 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 IconThemeFile.UnknownGroupPolicySet 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.

Example

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").escapedValue("$") == "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);