Function MimeType.clone

Create MimeType deep copy.

MimeType clone() pure nothrow @safe const;

Example

auto origin = new MimeType("text/xml");
origin.icon = "xml";
origin.genericIcon = "text";
origin.displayName = "XML document";
origin.addXMLnamespace(XMLnamespace("http://www.w3.org/1999/xhtml", "html"));
origin.addParent("text/plain");
origin.addAlias("application/xml");
origin.addGlob("*.xml");

auto firstMagic = MimeMagic(50);
firstMagic.addMatch(MagicMatch(MagicMatch.Type.string_, [0x01, 0x02]));
origin.addMagic(firstMagic);

auto secondMagic = MimeMagic(60);
secondMagic.addMatch(MagicMatch(MagicMatch.Type.string_, [0x03, 0x04]));
origin.addMagic(secondMagic);

origin.addTreeMagic(TreeMagic(50));

auto clone = origin.clone();
assert(clone.name() == origin.name());
assert(clone.icon() == origin.icon());
assert(clone.genericIcon() == origin.genericIcon());
assert(clone.XMLnamespaces() == origin.XMLnamespaces());
assert(clone.displayName() == origin.displayName());
assert(clone.parents() == origin.parents());
assert(clone.aliases() == origin.aliases());
assert(clone.globs() == origin.globs());
assert(clone.magics().length == origin.magics().length);

clone.clearTreeMagic();
assert(origin.treeMagics().length == 1);

origin.addParent("text/markup");
assert(origin.parents() == ["text/plain", "text/markup"]);
assert(clone.parents() == ["text/plain"]);