parserino.snapshot

A document tree as plain arrays, without pointers.

D can't store pointers to struct fields (like &element.node) in static data, so a document parsed at compile time is kept this way: the nodes in tree order, each one with its depth. At runtime it becomes a document again with a single pass (no tokenizer, no tree builder, no copy of the strings).

Types 3

A document as plain arrays (see the module): made by takeSnapshot, turned back into a document by restore

Fields
CompatMode compatMode
bool scripting
SnapshotNode[] nodes
SnapshotAttribute[] attributes
Methods
bool restore(DomDocument * doc) const @nogc nothrow pure @trustedRebuild the tree into `doc` (an empty document). It returns false if out of memory. The document uses the strings of the snapshot without copying them: the snapshot must outlive it (a static one al...

A node of a DomSnapshot

Fields
Ns ns
bool inTemplate
uint depth
uint name
uint attributes
string text
string qualifiedName
string systemId

An attribute of a DomSnapshot

Fields
uint name
Ns ns
string localName
string qualifiedName
string value

Functions 3

fnDomSnapshot takeSnapshot(const(DomDocument) * doc) pureA snapshot of `doc` (it uses the GC; it also works at compile time)
fnDomSnapshot parseToSnapshot(string html, bool scripting, ref RawParseError[] errors) pureParse `html` and take its snapshot; the parse errors go in `errors` (it works at compile time too). Unlike `parseToSnapshot`, it collects the errors.
fnDomSnapshot parseToSnapshot(string html, bool scripting = false) pureParse `html` and take its snapshot (for compile time: `static immutable s = parseToSnapshot(html);`)