DocPrinter

Simple Document printer, with support for serialization caching where the latter avoids having to generate unchanged sub-trees

Members

Aliases

Doc
alias Doc = Document!(T)
Undocumented in source.
Node
alias Node = Doc.Node
Undocumented in source.

Functions

cache
DocPrinter cache(bool yes)

Enable or disable use of cached document snippets. These represent document branches that remain unaltered, and can be emitted verbatim instead of traversing the tree

indent
DocPrinter indent(uint indentation)

Sets the number of spaces used when increasing indentation levels. Use a value of zero to disable explicit formatting

print
const(T)[] print(Doc doc, T[] content)

Generate a text representation of the document tree

print
void print(Doc doc, OutputStream stream)

Generate a text representation of the document tree

print
void print(Node root, void delegate(const(T)[][]...) emit)

Generate a representation of the given node-subtree

Examples

istring document = "<blah><xml>foo</xml></blah>";

auto doc = new Document!(char);
doc.parse (document.dup);

auto p = new DocPrinter!(char);
char[1024] buf;
auto newbuf = p.print (doc, buf);
test(document == newbuf);
test(buf.ptr == newbuf.ptr);
test(document == p.print(doc));

Meta