dyaml.hacks

Functionality that may be sometimes needed but allows unsafe or unstandard behavior, and should only be used in specific cases.

nothrow @safe ScalarStyle scalarStyleHack(ref const(Node) node);

Get the scalar style a YAML node had in the file it was loaded from.

This is only useful for nodes loaded from files.
This is a "hack" because a YAML application is supposed to be unaware of styles used in YAML styles, i.e. treating different styles differently is unstandard. However, determining style may be useful in some cases, e.g. YAML utilities.
May only be called on scalar nodes (nodes where node.isScalar() == true).

Example:

// Node node // loaded from a file
if(node.isScalar)
{
    import std.stdio;
    writeln(node.scalarStyleHack());
}

nothrow @safe CollectionStyle collectionStyleHack(ref const(Node) node);

Get the collection style a YAML node had in the file it was loaded from.

May only be called on collection nodes (nodes where node.isScalar() != true).

See Also:
scalarStyleHack
nothrow @safe void scalarStyleHack(ref Node node, const ScalarStyle rhs);

Set the scalar style a YAML node had in the file it was loaded from.

Setting the style might be useful when generating YAML or reformatting existing files.
May only be called on scalar nodes (nodes where node.isScalar() == true).

Examples:
writeln("D:YAML scalarStyleHack setter unittest");
auto node = Node(5);
node.scalarStyleHack = ScalarStyle.DoubleQuoted;
assert(node.scalarStyleHack() == ScalarStyle.DoubleQuoted);
nothrow @safe void collectionStyleHack(ref Node node, const CollectionStyle rhs);

Set the scalar style a YAML node had in the file it was loaded from.

Setting the style might be useful when generating YAML or reformatting existing files.
May only be called on collection nodes (nodes where node.isScalar() != true).

Examples:
writeln("D:YAML collectionStyleHack setter unittest");
auto node = Node([1, 2, 3, 4, 5]);
node.collectionStyleHack = CollectionStyle.Block;
assert(node.collectionStyleHack() == CollectionStyle.Block);