217 lines
8.4 KiB
HTML
217 lines
8.4 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||
|
|
||
|
<html lang='en'>
|
||
|
<head>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
|
||
|
<title>dyaml.loader - D:YAML 0.1 API documentation</title>
|
||
|
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||
|
</head>
|
||
|
|
||
|
<body><div id="top">
|
||
|
<div id="header">
|
||
|
<img id="logo" alt="D:YAML logo" src="images/logo.png"><a id="main-heading" href="index.html">D:YAML 0.1 API documentation</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="navigation">
|
||
|
<div class="navblock">
|
||
|
<div id="toctop">
|
||
|
<ul><li><a href="../index.html">Documentation home</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="navblock">
|
||
|
<ul><li><a href="index.html">Main page</a></li>
|
||
|
<li><a href="dyaml.constructor.html">dyaml.constructor</a></li>
|
||
|
<li><a href="dyaml.exception.html">dyaml.exception</a></li>
|
||
|
<li><a href="dyaml.loader.html">dyaml.loader</a></li>
|
||
|
<li><a href="dyaml.node.html">dyaml.node</a></li>
|
||
|
<li><a href="dyaml.resolver.html">dyaml.resolver</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="content">
|
||
|
<h1>dyaml.loader</h1>
|
||
|
<!-- Generated by Ddoc from dyaml/loader.d -->
|
||
|
<p>Class and convenience functions used to load YAML documents.</p>
|
||
|
|
||
|
<dl><dt class="d_decl">Node <a name="load"></a><span class="ddoc_psymbol">load</span>(in string <b>filename</b>);
|
||
|
</dt>
|
||
|
<dd><p>Load single YAML document from a file.
|
||
|
</p>
|
||
|
<p>If there is no or more than one YAML document in the file, this will throw.
|
||
|
Use <a href="#loadAll"><span class="d_inlinecode">loadAll</span></a> for such files.
|
||
|
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>filename</b></td>
|
||
|
<td valign=top>Name of the file to load from.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Returns:</b><div class="pbr">Root node of the document.
|
||
|
|
||
|
</div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if there wasn't exactly one document in the file,
|
||
|
the file could not be opened or on a YAML parsing error.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">Node <a name="load"></a><span class="ddoc_psymbol">load</span>(Stream <b>input</b>, in string <b>name</b> = "<unknown>");
|
||
|
</dt>
|
||
|
<dd><p>Load single YAML document from a stream.
|
||
|
</p>
|
||
|
<p>You can use this to e.g load YAML from memory.
|
||
|
<br>
|
||
|
|
||
|
If there is no or more than one YAML document in the stream, this will throw.
|
||
|
Use <a href="#loadAll"><span class="d_inlinecode">loadAll</span></a> for such files.
|
||
|
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Stream <b>input</b></td>
|
||
|
<td valign=top>Stream to read from. Must be readable.</td></tr>
|
||
|
<tr><td valign=top>string <b>name</b></td>
|
||
|
<td valign=top>Name of the stream, used in error messages.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Returns:</b><div class="pbr">Root node of the document.
|
||
|
|
||
|
</div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if there wasn't exactly one document in the stream,
|
||
|
the stream could not be read from or on a YAML parsing error.
|
||
|
|
||
|
</div>
|
||
|
<b>Examples:</b><div class="pbr">Loading YAML from memory:
|
||
|
<pre class="d_code"> <span class="d_keyword">import</span> std.stream;
|
||
|
<span class="d_keyword">import</span> std.stdio;
|
||
|
|
||
|
string yaml_input = <span class="d_string">"red: '#ff0000'\n"</span>
|
||
|
<span class="d_string">"green: '#00ff00'\n"</span>
|
||
|
<span class="d_string">"blue: '#0000ff'"</span>;
|
||
|
|
||
|
<span class="d_keyword">auto</span> colors = yaml.<span class="d_psymbol">load</span>(<span class="d_keyword">new</span> MemoryStream(<span class="d_keyword">cast</span>(<span class="d_keyword">char</span>[])yaml_input));
|
||
|
|
||
|
<span class="d_keyword">foreach</span>(string color, string value; colors)
|
||
|
{
|
||
|
writeln(color, <span class="d_string">" is "</span>, value, <span class="d_string">" in HTML/CSS"</span>);
|
||
|
}
|
||
|
</pre>
|
||
|
</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">Node[] <a name="loadAll"></a><span class="ddoc_psymbol">loadAll</span>(in string <b>filename</b>);
|
||
|
</dt>
|
||
|
<dd><p>Load all YAML documents from a file.
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>filename</b></td>
|
||
|
<td valign=top>Name of the file to load from.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Returns:</b><div class="pbr">Array of root nodes of documents in the stream.
|
||
|
If the stream is empty, empty array will be returned.
|
||
|
|
||
|
</div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or on a YAML parsing error.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">Node[] <a name="loadAll"></a><span class="ddoc_psymbol">loadAll</span>(Stream <b>input</b>, in string <b>name</b> = "<unknown>");
|
||
|
</dt>
|
||
|
<dd><p>Load all YAML documents from a stream.
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Stream <b>input</b></td>
|
||
|
<td valign=top>Stream to read from. Must be readable.</td></tr>
|
||
|
<tr><td valign=top>string <b>name</b></td>
|
||
|
<td valign=top>Name of the stream, used in error messages.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Returns:</b><div class="pbr">Array of root nodes of documents in the file.
|
||
|
If the file is empty, empty array will be returned.
|
||
|
|
||
|
</div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if the stream could not be read from or on a YAML parsing error.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">struct <a name="Loader"></a><span class="ddoc_psymbol">Loader</span>;
|
||
|
</dt>
|
||
|
<dd><p>Loads YAML documents from files or streams.</p>
|
||
|
|
||
|
<dl><dt class="d_decl">this(in string <b>filename</b>);
|
||
|
</dt>
|
||
|
<dd><p>Construct a Loader to load YAML from a file.
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>filename</b></td>
|
||
|
<td valign=top>Name of the file to load from.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or read from.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">this(in string <b>filename</b>, Constructor <b>constructor</b>, Resolver <b>resolver</b>);
|
||
|
</dt>
|
||
|
<dd><p>Construct a Loader to load YAML from a file, with provided constructor and resolver.
|
||
|
</p>
|
||
|
<p>Constructor and resolver can be used to implement custom data types in YAML.
|
||
|
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>filename</b></td>
|
||
|
<td valign=top>Name of the file to load from.</td></tr>
|
||
|
<tr><td valign=top>Constructor <b>constructor</b></td>
|
||
|
<td valign=top>Constructor to use.</td></tr>
|
||
|
<tr><td valign=top>Resolver <b>resolver</b></td>
|
||
|
<td valign=top>Resolver to use.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or read from.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">this(Stream <b>input</b>, in string <b>name</b>, Constructor <b>constructor</b>, Resolver <b>resolver</b>);
|
||
|
</dt>
|
||
|
<dd><p>Construct a Loader to load YAML from a stream with provided constructor and resolver.
|
||
|
</p>
|
||
|
<p>Stream can be used to load YAML from memory and other sources.
|
||
|
Constructor and resolver can be used to implement custom data types in YAML.
|
||
|
|
||
|
</p>
|
||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Stream <b>input</b></td>
|
||
|
<td valign=top>Stream to read from. Must be readable.</td></tr>
|
||
|
<tr><td valign=top>string <b>name</b></td>
|
||
|
<td valign=top>Name of the stream. Used in error messages.</td></tr>
|
||
|
<tr><td valign=top>Constructor <b>constructor</b></td>
|
||
|
<td valign=top>Constructor to use.</td></tr>
|
||
|
<tr><td valign=top>Resolver <b>resolver</b></td>
|
||
|
<td valign=top>Resolver to use.</td></tr>
|
||
|
</table></div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if the stream could not be read from.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">Node <a name="loadSingleDocument"></a><span class="ddoc_psymbol">loadSingleDocument</span>();
|
||
|
</dt>
|
||
|
<dd><p>Load single YAML document.
|
||
|
</p>
|
||
|
<p>If no or more than one YAML document is found, this will throw a YAMLException.
|
||
|
|
||
|
</p>
|
||
|
<b>Returns:</b><div class="pbr">Root node of the document.
|
||
|
|
||
|
</div>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException if there wasn't exactly one document
|
||
|
or on a YAML parsing error.</div>
|
||
|
|
||
|
</dd>
|
||
|
<dt class="d_decl">int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(int delegate(ref Node) <b>dg</b>);
|
||
|
</dt>
|
||
|
<dd><p>Foreach over YAML documents.
|
||
|
</p>
|
||
|
<p>Parses documents lazily, as they are needed.
|
||
|
|
||
|
</p>
|
||
|
<b>Throws:</b><div class="pbr">YAMLException on a parsing error.</div>
|
||
|
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div id="copyright">
|
||
|
Copyright © Ferdinand Majerech 2011. Based on <a href="http://www.pyyaml.org">PyYAML</a> by Kirill Simonov. |
|
||
|
Page generated by Autodoc and <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>.
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|