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
structDomSnapshot
A document as plain arrays (see the module): made by takeSnapshot, turned back into a document by restore
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...structSnapshotNode
structSnapshotAttribute
An attribute of a DomSnapshot
Functions 3
fn
DomSnapshot takeSnapshot(const(DomDocument) * doc) pureA snapshot of `doc` (it uses the GC; it also works at compile time)fn
DomSnapshot 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.fn
DomSnapshot parseToSnapshot(string html, bool scripting = false) pureParse `html` and take its snapshot (for compile time: `static immutable s = parseToSnapshot(html);`)