Function globs2FileReader

Parse mime/globs2 file by line ignoring empty lines and comments.

auto auto globs2FileReader(Range) (
  Range byLine
)
if (isInputRange!Range && is(ElementType!Range : string));

Returns

Range of GlobLine tuples.

Throws

MimeFileException on parsing error.

Example

string[] lines = [
    "#comment",
    "50:text/x-c++src:*.cpp",
    "60:text/x-c++src:*.C:cs",
    "50:text/x-csrc:*.c:cs"
];

auto expected = [GlobLine(50, "text/x-c++src", "*.cpp", false), GlobLine(60, "text/x-c++src", "*.C", true), GlobLine(50, "text/x-csrc", "*.c", true)];
assert(equal(globs2FileReader(lines), expected));

assertThrown!MimeFileException(globs2FileReader(["notanumber:text/plain:*.txt"]).array, "must throw");

MimeFileException mfe;
try {
    globs2FileReader(["notanumber:text/nopattern"]).array;
} catch(MimeFileException e) {
    mfe = e;
    assert(mfe.lineString == "notanumber:text/nopattern");
}
assert(mfe, "must throw");