dyaml.resolver

Implements a class that resolves YAML tags. This can be used to implicitly resolve tags for custom data types, removing the need to explicitly specify tags in YAML. A tutorial can be found here.

Code based on PyYAML.

class Resolver;

Resolves YAML tags (data types).

Can be used to implicitly resolve custom data types of scalar values.

this(in const(bool) defaultImplicitResolvers = true);

Construct a Resolver.

If you don't want to implicitly resolve default YAML tags/data types, you can use defaultImplicitResolvers to disable default resolvers.

Parameters:
const(bool) defaultImplicitResolvers Use default YAML implicit resolvers?
void addImplicitResolver(string tag, Regex!(char) regexp, in string first);

Add an implicit scalar resolver.

If a scalar matches regexp and starts with any character in first, its tag is set to tag. If it matches more than one resolver regexp resolvers added first override ones added later. Default resolvers override any user specified resolvers, but they can be disabled in Resolver constructor.
If a scalar is not resolved to anything, it is assigned the default YAML tag for strings.

Parameters:
string tag Tag to resolve to.
Regex!(char) regexp Regular expression the scalar must match to have this tag.
string first String of possible starting characters of the scalar.
Examples:
Resolve scalars starting with 'A' to !tag :
 import std.regex;

 import yaml;

 void main()
 {
     auto loader = Loader("file.txt");
     auto resolver = new Resolver();
     resolver.addImplicitResolver("!tag", std.regex.regex("A*"), "A");
     loader.resolver = resolver;

     //Note that we have no constructor from tag "!tag", so we can't
     //actually load anything that resolves to this tag.
     //See Constructor API documentation and tutorial for more information.

     auto node = loader.load();
 }
package const @property Tag defaultScalarTag();

Return default scalar tag.

package const @property Tag defaultSequenceTag();

Return default sequence tag.

package const @property Tag defaultMappingTag();

Return default mapping tag.