Construct a Loader to load YAML from a file.
Construct a Loader to load YAML from a buffer.
Destroy the Loader.
Specify custom Constructor to use.
Load single YAML document.
Load all YAML documents.
Set stream name. Used in debugging messages.
Foreach over YAML documents.
Specify custom Resolver to use.
Construct a Loader to load YAML from a string (char []).
Load single YAML document from a file:
auto rootNode = Loader("file.yaml").load(); ...
Load all YAML documents from a file:
auto nodes = Loader("file.yaml").loadAll(); ...
Iterate over YAML documents in a file, lazily loading them:
auto loader = Loader("file.yaml"); foreach(ref node; loader) { ... }
Load YAML from a string:
char[] yaml_input = "red: '#ff0000'\n" "green: '#00ff00'\n" "blue: '#0000ff'".dup; auto colors = Loader.fromString(yaml_input).load(); foreach(string color, string value; colors) { import std.stdio; writeln(color, " is ", value, " in HTML/CSS"); }
Load a file into a buffer in memory and then load YAML from that buffer:
try { import std.file; void[] buffer = std.file.read("file.yaml"); auto yamlNode = Loader(buffer); // Read data from yamlNode here... } catch(FileException e) { writeln("Failed to read file 'file.yaml'"); }
Use a custom constructor/resolver to support custom data types and/or implicit tags:
auto constructor = new Constructor(); auto resolver = new Resolver(); // Add constructor functions / resolver expressions here... auto loader = Loader("file.yaml"); loader.constructor = constructor; loader.resolver = resolver; auto rootNode = loader.load(node);
Loads YAML documents from files or char[].
User specified Constructor and/or Resolver can be used to support new tags / data types.