9596806644
to be used for unordered map storage. This is because AAs still don't work correctly and even if they did, require the user to define both toHash and opCmp/opEquals for every YAML struct/class. Now only opCmp needs to be defined. Documentation/tutorials/examples have been updated accordingly.
141 lines
5.4 KiB
HTML
141 lines
5.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.resolver - D:YAML 0.3 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.3 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.dumper.html">dyaml.dumper</a></li>
|
|
<li><a href="dyaml.encoding.html">dyaml.encoding</a></li>
|
|
<li><a href="dyaml.exception.html">dyaml.exception</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.resolver</h1>
|
|
<!-- Generated by Ddoc from dyaml/resolver.d -->
|
|
<p>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
|
|
<a href="../tutorials/custom_types.html">here</a>.
|
|
</p>
|
|
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
|
|
|
<dl><dt class="d_decl">class <a name="Resolver"></a><span class="ddoc_psymbol">Resolver</span>;
|
|
</dt>
|
|
<dd><p>Resolves YAML tags (data types).
|
|
</p>
|
|
<p>Can be used to implicitly resolve custom data types of scalar values.</p>
|
|
|
|
<dl><dt class="d_decl">this(bool <b>defaultImplicitResolvers</b> = true);
|
|
</dt>
|
|
<dd><p>Construct a Resolver.
|
|
</p>
|
|
<p>If you don't want to implicitly resolve default YAML tags/data types,
|
|
you can use <b>defaultImplicitResolvers</b> to disable default resolvers.
|
|
|
|
</p>
|
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>bool <b>defaultImplicitResolvers</b></td>
|
|
<td valign=top>Use default YAML implicit resolvers?</td></tr>
|
|
</table></div>
|
|
|
|
</dd>
|
|
<dt class="d_decl">void <a name="addImplicitResolver"></a><span class="ddoc_psymbol">addImplicitResolver</span>(string <b>tag</b>, Regex!(char) <b>regexp</b>, string <b>first</b>);
|
|
</dt>
|
|
<dd><p>Add an implicit scalar resolver.
|
|
</p>
|
|
<p>If a scalar matches <b>regexp</b> and starts with any character in <b>first</b>,
|
|
its tag is set to <b>tag</b>. 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.
|
|
<br>
|
|
|
|
If a scalar is not resolved to anything, it is assigned the default
|
|
YAML tag for strings.
|
|
|
|
</p>
|
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>tag</b></td>
|
|
<td valign=top>Tag to resolve to.</td></tr>
|
|
<tr><td valign=top>Regex!(char) <b>regexp</b></td>
|
|
<td valign=top>Regular expression the scalar must match to have this tag.</td></tr>
|
|
<tr><td valign=top>string <b>first</b></td>
|
|
<td valign=top>String of possible starting characters of the scalar.</td></tr>
|
|
</table></div>
|
|
<b>Examples:</b><div class="pbr">Resolve scalars starting with 'A' to !tag :
|
|
<pre class="d_code"> <span class="d_keyword">import</span> std.regex;
|
|
|
|
<span class="d_keyword">import</span> yaml;
|
|
|
|
<span class="d_keyword">void</span> main()
|
|
{
|
|
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.txt"</span>);
|
|
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
|
resolver.<span class="d_psymbol">addImplicitResolver</span>(<span class="d_string">"!tag"</span>, std.regex.regex(<span class="d_string">"A.*"</span>), <span class="d_string">"A"</span>);
|
|
loader.resolver = resolver;
|
|
|
|
<span class="d_comment">//Note that we have no constructor from tag "!tag", so we can't
|
|
</span> <span class="d_comment">//actually load anything that resolves to this tag.
|
|
</span> <span class="d_comment">//See Constructor API documentation and tutorial for more information.
|
|
</span>
|
|
<span class="d_keyword">auto</span> node = loader.load();
|
|
}
|
|
</pre>
|
|
</div>
|
|
|
|
</dd>
|
|
<dt class="d_decl">package const @property Tag <a name="defaultScalarTag"></a><span class="ddoc_psymbol">defaultScalarTag</span>();
|
|
</dt>
|
|
<dd><p>Return default scalar tag.</p>
|
|
|
|
</dd>
|
|
<dt class="d_decl">package const @property Tag <a name="defaultSequenceTag"></a><span class="ddoc_psymbol">defaultSequenceTag</span>();
|
|
</dt>
|
|
<dd><p>Return default sequence tag.</p>
|
|
|
|
</dd>
|
|
<dt class="d_decl">package const @property Tag <a name="defaultMappingTag"></a><span class="ddoc_psymbol">defaultMappingTag</span>();
|
|
</dt>
|
|
<dd><p>Return default mapping tag.</p>
|
|
|
|
</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 AutoDDoc and <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>.
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|