Setting parameters in any order, leaving not mentioned ones in default state.
Assign arg to the struct member of corresponding type. Note: It's compile-time error to assign parameter of type which is not part of ReadOptions.
Behavior on groups with duplicate names.
Behavior on duplicate keys.
Behavior on invalid keys.
Whether to preserve comments on reading.
1 string contents = `# The first comment 2 [First Entry] 3 # Comment 4 GenericName=File manager 5 GenericName[ru]=Файловый менеджер 6 # Another comment 7 [Another Group] 8 Name=Commander 9 # The last comment`; 10 11 alias IniLikeFile.ReadOptions ReadOptions; 12 alias IniLikeFile.DuplicateKeyPolicy DuplicateKeyPolicy; 13 alias IniLikeFile.DuplicateGroupPolicy DuplicateGroupPolicy; 14 15 IniLikeFile ilf = new IniLikeFile(iniLikeStringReader(contents), null, ReadOptions(No.preserveComments)); 16 assert(!ilf.readOptions().preserveComments); 17 assert(ilf.leadingComments().empty); 18 assert(equal( 19 ilf.group("First Entry").byIniLine(), 20 [IniLikeLine.fromKeyValue("GenericName", "File manager"), IniLikeLine.fromKeyValue("GenericName[ru]", "Файловый менеджер")] 21 )); 22 assert(equal( 23 ilf.group("Another Group").byIniLine(), 24 [IniLikeLine.fromKeyValue("Name", "Commander")] 25 )); 26 27 contents = `[Group] 28 Duplicate=First 29 Key=Value 30 Duplicate=Second`; 31 32 ilf = new IniLikeFile(iniLikeStringReader(contents), null, ReadOptions(DuplicateKeyPolicy.skip)); 33 assert(equal( 34 ilf.group("Group").byIniLine(), 35 [IniLikeLine.fromKeyValue("Duplicate", "First"), IniLikeLine.fromKeyValue("Key", "Value")] 36 )); 37 38 ilf = new IniLikeFile(iniLikeStringReader(contents), null, ReadOptions(DuplicateKeyPolicy.preserve)); 39 assert(equal( 40 ilf.group("Group").byIniLine(), 41 [IniLikeLine.fromKeyValue("Duplicate", "First"), IniLikeLine.fromKeyValue("Key", "Value"), IniLikeLine.fromKeyValue("Duplicate", "Second")] 42 )); 43 assert(ilf.group("Group").value("Duplicate") == "First"); 44 45 contents = `[Duplicate] 46 Key=First 47 [Group] 48 [Duplicate] 49 Key=Second`; 50 51 ilf = new IniLikeFile(iniLikeStringReader(contents), null, ReadOptions(DuplicateGroupPolicy.preserve)); 52 auto byGroup = ilf.byGroup(); 53 assert(byGroup.front["Key"] == "First"); 54 assert(byGroup.back["Key"] == "Second"); 55 56 auto byNode = ilf.byNode(); 57 assert(byNode.front.group.groupName == "Duplicate"); 58 assert(byNode.front.key == "Duplicate"); 59 assert(byNode.back.key is null); 60 61 contents = `[Duplicate] 62 Key=First 63 [Group] 64 [Duplicate] 65 Key=Second`; 66 67 ilf = new IniLikeFile(iniLikeStringReader(contents), null, ReadOptions(DuplicateGroupPolicy.skip)); 68 auto byGroup2 = ilf.byGroup(); 69 assert(byGroup2.front["Key"] == "First"); 70 assert(byGroup2.back.groupName == "Group"); 71
Behavior of ini-like file reading.