dyaml/doc/html/api/dyaml.hacks.html

142 lines
5.3 KiB
HTML
Raw Normal View History

2014-05-19 17:54:48 +00:00
<!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" >
2014-08-01 01:00:40 +00:00
<title>dyaml.hacks - D:YAML 0.5 API documentation</title>
2014-05-19 17:54:48 +00:00
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body><div id="top">
<div id="header">
2014-08-01 01:00:40 +00:00
<img id="logo" alt="D:YAML logo" src="images/logo.png"><a id="main-heading" href="index.html">D:YAML 0.5 API documentation</a>
2014-05-19 17:54:48 +00:00
</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.dumper.html">dyaml.dumper</a></li>
<li><a href="dyaml.exception.html">dyaml.exception</a></li>
<li><a href="dyaml.hacks.html">dyaml.hacks</a></li>
<li><a href="dyaml.linebreak.html">dyaml.linebreak</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.representer.html">dyaml.representer</a></li>
<li><a href="dyaml.resolver.html">dyaml.resolver</a></li>
<li><a href="dyaml.style.html">dyaml.style</a></li>
</ul>
</div>
</div>
<div id="content">
<h1>dyaml.hacks</h1>
<!-- Generated by Ddoc from dyaml/hacks.d -->
2014-08-01 01:00:40 +00:00
<p>Functionality that may sometimes be needed but allows unsafe or unstandard behavior, and should only be used in specific cases.</p>
2014-05-19 17:54:48 +00:00
<dl><dt class="d_decl"><a name="scalarStyleHack"></a>nothrow @safe ScalarStyle <a name="scalarStyleHack"></a><span class="ddoc_psymbol">scalarStyleHack</span>(ref const(Node) <b>node</b>);
</dt>
2014-08-01 01:00:40 +00:00
<dd><p>Get the scalar style a <b>node</b> had in the file it was loaded from.
2014-05-19 17:54:48 +00:00
</p>
<p>This is only useful for nodes loaded from files.
<br>
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.
<br>
May only be called on scalar nodes (nodes where <b>node</b>.isScalar() == <b>true</b>).
</p>
<p><b>Example:</b><br>
<pre class="d_code"><span class="d_comment">// Node node // loaded from a file
</span><span class="d_keyword">if</span>(<span class="d_param">node</span>.isScalar)
{
<span class="d_keyword">import</span> std.stdio;
writeln(<span class="d_param">node</span>.<span class="d_psymbol">scalarStyleHack</span>());
}
</pre>
</p>
</dd>
<dt class="d_decl"><a name="collectionStyleHack"></a>nothrow @safe CollectionStyle <a name="collectionStyleHack"></a><span class="ddoc_psymbol">collectionStyleHack</span>(ref const(Node) <b>node</b>);
</dt>
<dd><p>Get the collection style a YAML <b>node</b> had in the file it was loaded from.
</p>
<p>May only be called on collection nodes (nodes where <b>node</b>.isScalar() != <b>true</b>).
2014-08-01 01:00:40 +00:00
<br>
<br>
2014-05-19 17:54:48 +00:00
</p>
<b>See Also:</b><div class="pbr">scalarStyleHack</div>
</dd>
<dt class="d_decl"><a name="scalarStyleHack"></a>nothrow @safe void <a name="scalarStyleHack"></a><span class="ddoc_psymbol">scalarStyleHack</span>(ref Node <b>node</b>, const ScalarStyle <b>rhs</b>);
</dt>
2014-08-01 01:00:40 +00:00
<dd><p>Set the scalar style <b>node</b> should have when written to a file.
2014-05-19 17:54:48 +00:00
</p>
<p>Setting the style might be useful when generating YAML or reformatting existing
<br>
2014-08-01 01:00:40 +00:00
files.
<br>
<br>
<br>
May only be called on scalar nodes (nodes where <b>node</b>.isScalar() == <b>true</b>).</p>
2014-05-19 17:54:48 +00:00
<b>Examples:</b><div class="pbr"><pre class="d_code">
writeln(<span class="d_string">"D:YAML scalarStyleHack setter unittest"</span>);
<span class="d_keyword">auto</span> <span class="d_param">node</span> = Node(5);
<span class="d_param">node</span>.<span class="d_psymbol">scalarStyleHack</span> = ScalarStyle.DoubleQuoted;
<span class="d_keyword">assert</span>(<span class="d_param">node</span>.<span class="d_psymbol">scalarStyleHack</span>() == ScalarStyle.DoubleQuoted);
</pre>
</div>
</dd>
<dt class="d_decl"><a name="collectionStyleHack"></a>nothrow @safe void <a name="collectionStyleHack"></a><span class="ddoc_psymbol">collectionStyleHack</span>(ref Node <b>node</b>, const CollectionStyle <b>rhs</b>);
</dt>
2014-08-01 01:00:40 +00:00
<dd><p>Set the collection style <b>node</b> should have when written to a file.
2014-05-19 17:54:48 +00:00
</p>
<p>Setting the style might be useful when generating YAML or reformatting existing
<br>
2014-08-01 01:00:40 +00:00
files.
<br>
<br>
<br>
May only be called on collection nodes (nodes where <b>node</b>.isScalar() != <b>true</b>).</p>
2014-05-19 17:54:48 +00:00
<b>Examples:</b><div class="pbr"><pre class="d_code">
writeln(<span class="d_string">"D:YAML collectionStyleHack setter unittest"</span>);
<span class="d_keyword">auto</span> <span class="d_param">node</span> = Node([1, 2, 3, 4, 5]);
<span class="d_param">node</span>.<span class="d_psymbol">collectionStyleHack</span> = CollectionStyle.Block;
<span class="d_keyword">assert</span>(<span class="d_param">node</span>.<span class="d_psymbol">collectionStyleHack</span>() == CollectionStyle.Block);
</pre>
</div>
</dd>
</dl>
</div>
<div id="copyright">
2014-08-01 01:00:40 +00:00
Copyright &copy; Ferdinand Majerech 2011-2014. Based on <a href="http://www.pyyaml.org">PyYAML</a> by Kirill Simonov. |
2014-05-19 17:54:48 +00:00
Page generated by AutoDDoc and <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>.
</div>
</body>
</html>