// INI document (demo data) static immutable string rawIniDocument = `; This is a comment. [section1] foo = bar ;another comment oachkatzl = schwoaf ;try pronouncing that `; // Combine feature flags to build the required dialect. const myDialect = (IniDialect.defaults | IniDialect.inlineComments); // Instantiate a new parser and supply our document string. auto parser = IniParser!(myDialect)(rawIniDocument); int comments = 0; int sections = 0; int keys = 0; int values = 0; // Process token by token. foreach (const parser.Token token; parser) { if (token.type == IniTokenType.comment) { ++comments; } if (token.type == IniTokenType.sectionHeader) { ++sections; } if (token.type == IniTokenType.key) { ++keys; } if (token.type == IniTokenType.value) { ++values; } } assert(comments == 3); assert(sections == 1); assert(keys == 2); assert(values == 2);
Low-level INI parser with filtered output
This wrapper will only supply tokens of these types: