Dumper

Disabled Default Constructor

A disabled default is present on this object. To use it, use one of the other constructors or a factory function.

Constructors

this
this(Range stream)

Construct a Dumper writing to a file.

Members

Functions

dump
void dump(Node[] documents...)

Dump one or more YAML _documents to the file/stream.

Properties

YAMLVersion
string YAMLVersion [@property setter]

Specify YAML version string. "1.1" by default.

canonical
bool canonical [@property setter]

Write scalars in canonical form?

explicitEnd
bool explicitEnd [@property setter]

Always explicitly write document end?

explicitStart
bool explicitStart [@property setter]

Always explicitly write document start?

indent
uint indent [@property setter]

Set indentation width. 2 by default. Must not be zero.

lineBreak
LineBreak lineBreak [@property setter]

Set line break to use. Unix by default.

name
string name [@property setter]

Set stream name. Used in debugging messages.

representer
Representer representer [@property setter]

Specify custom Representer to use.

resolver
Resolver resolver [@property setter]

Specify custom Resolver to use.

tagDirectives
string[string] tagDirectives [@property setter]

Specify tag directives.

textWidth
uint textWidth [@property setter]

Set preferred text _width.

Examples

Write to a file

auto node = Node([1, 2, 3, 4, 5]);
dumper(new Appender!string()).dump(node);

Write multiple YAML documents to a file

1 auto node1 = Node([1, 2, 3, 4, 5]);
2 auto node2 = Node("This document contains only one string");
3 dumper(new Appender!string()).dump(node1, node2);
4 //Or with an array:
5 dumper(new Appender!string()).dump([node1, node2]);

Write to memory

auto stream = new Appender!string();
auto node = Node([1, 2, 3, 4, 5]);
dumper(stream).dump(node);

Use a custom representer/resolver to support custom data types and/or implicit tags

1 auto node = Node([1, 2, 3, 4, 5]);
2 auto representer = new Representer();
3 auto resolver = new Resolver();
4 //Add representer functions / resolver expressions here...
5 auto dumper = dumper(new Appender!string());
6 dumper.representer = representer;
7 dumper.resolver = resolver;
8 dumper.dump(node);

Meta