NimYAML/yaml.dom.html

251 lines
20 KiB
HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NimYAML - Module yaml.dom</title>
<link href="docutils.css" rel="stylesheet" type="text/css"/>
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900' rel='stylesheet' type='text/css'/>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
</head>
<body>
<a href="https://github.com/flyx/NimYAML"><img style="position: fixed; top: 0; right: 0; border: 0; z-index: 10;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
<header>
<a class="pagetitle" href="index.html">NimYAML</a>
<a href="index.html">Home</a>
<a href="testing.html">Testing Ground</a>
<span>Docs:</span>
<a href="api.html">Overview</a>
<span>
<a href="#">Serialization</a>
<ul>
<li><a href="serialization.html">Overview</a></li>
<li><a href="schema.html">Schema</a></li>
</ul>
</span>
<span>
<a href="#">Modules</a>
<ul class="monospace">
<li><a href="yaml.html">yaml</a></li>
<li><a href="yaml.dom.html">yaml.dom</a></li>
<li><a href="yaml.hints.html">yaml.hints</a></li>
<li><a href="yaml.parser.html">yaml.parser</a></li>
<li><a href="yaml.presenter.html">yaml.presenter</a></li>
<li><a href="yaml.serialization.html">yaml.serialization</a></li>
<li><a href="yaml.stream.html">yaml.stream</a></li>
<li><a href="yaml.taglib.html">yaml.taglib</a></li>
<li><a href="yaml.tojson.html">yaml.tojson</a></li>
</ul>
</span>
</header>
<article id="documentId">
<div class="container">
<h1 class="title">Module yaml.dom</h1>
<div class="row">
<div class="three columns">
<div>
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#YamlNodeKind"
title="YamlNodeKind = enum
yScalar, yMapping, ySequence"><wbr />Yaml<wbr />Node<wbr />Kind</a></li>
<li><a class="reference" href="#YamlNode"
title="YamlNode = ref YamlNodeObj not nil"><wbr />Yaml<wbr />Node</a></li>
<li><a class="reference" href="#YamlNodeObj"
title="YamlNodeObj = object
tag*: string
case kind*: YamlNodeKind
of yScalar: content*: string
of ySequence: children*: seq[YamlNode]
of yMapping: pairs*: seq[tuple[key, value: YamlNode]]"><wbr />Yaml<wbr />Node<wbr />Obj</a></li>
<li><a class="reference" href="#YamlDocument"
title="YamlDocument = object
root*: YamlNode"><wbr />Yaml<wbr />Document</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#newYamlNode,string,string"
title="newYamlNode(content: string; tag: string = &quot;?&quot;): YamlNode"><wbr />new<wbr />Yaml<wbr />Node</a></li>
<li><a class="reference" href="#newYamlNode,openArray[YamlNode not nil],string"
title="newYamlNode(children: openArray[YamlNode]; tag: string = &quot;?&quot;): YamlNode"><wbr />new<wbr />Yaml<wbr />Node</a></li>
<li><a class="reference" href="#newYamlNode,openArray[tuple[YamlNode not nil,YamlNode not nil]],string"
title="newYamlNode(pairs: openArray[tuple[key, value: YamlNode]]; tag: string = &quot;?&quot;): YamlNode"><wbr />new<wbr />Yaml<wbr />Node</a></li>
<li><a class="reference" href="#initYamlDoc,YamlNode not nil"
title="initYamlDoc(root: YamlNode): YamlDocument"><wbr />init<wbr />Yaml<wbr />Doc</a></li>
<li><a class="reference" href="#compose,YamlStream,TagLibrary"
title="compose(s: var YamlStream; tagLib: TagLibrary): YamlDocument"><wbr />compose</a></li>
<li><a class="reference" href="#loadDOM,"
title="loadDOM[](s: Stream | string): YamlDocument"><wbr />load<wbr />DOM</a></li>
<li><a class="reference" href="#serialize,YamlDocument,TagLibrary,AnchorStyle"
title="serialize(doc: YamlDocument; tagLib: TagLibrary; a: AnchorStyle = asTidy): YamlStream"><wbr />serialize</a></li>
<li><a class="reference" href="#dumpDOM,YamlDocument,Stream,AnchorStyle,PresentationOptions"
title="dumpDOM(doc: YamlDocument; target: Stream; anchorStyle: AnchorStyle = asTidy;
options: PresentationOptions = defaultPresentationOptions)"><wbr />dump<wbr />DOM</a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"><p>This is the DOM API, which enables you to load YAML into a tree-like structure. It can also dump the structure back to YAML. Formally, it represents the <em>Representation Graph</em> as defined in the YAML specification.</p>
<p>The main interface of this API are <tt class="docutils literal"><span class="pre">loadDOM</span></tt> and <tt class="docutils literal"><span class="pre">dumpDOM</span></tt>. The other exposed procs are low-level and useful if you want to load or generate parts of a <tt class="docutils literal"><span class="pre">YamlStream</span></tt>.</p>
</p>
<section id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="tables.html">tables</a>, <a class="reference external" href="streams.html">streams</a>, <a class="reference external" href="stream.html">stream</a>, <a class="reference external" href="taglib.html">taglib</a>, <a class="reference external" href="serialization.html">serialization</a>, <a class="reference external" href="../private/internal.html">../private/internal</a>, <a class="reference external" href="parser.html">parser</a>, <a class="reference external" href="presenter.html">presenter</a>
</dl></section>
<section id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<dt id="YamlNodeKind"><a name="YamlNodeKind"></a><pre><span class="Identifier">YamlNodeKind</span> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">yScalar</span><span class="Other">,</span> <span class="Identifier">yMapping</span><span class="Other">,</span> <span class="Identifier">ySequence</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L24"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlNode"><a name="YamlNode"></a><pre><span class="Identifier">YamlNode</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Identifier">YamlNodeObj</span> <span class="Keyword">not</span> <span class="Keyword">nil</span></pre></dt>
<dd>
Represents a node in a <tt class="docutils literal"><span class="pre">YamlDocument</span></tt>.
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L27"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlNodeObj"><a name="YamlNodeObj"></a><pre><span class="Identifier">YamlNodeObj</span> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">tag</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">YamlNodeKind</span>
<span class="Keyword">of</span> <span class="Identifier">yScalar</span><span class="Other">:</span> <span class="Identifier">content</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Keyword">of</span> <span class="Identifier">ySequence</span><span class="Other">:</span> <span class="Identifier">children</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">YamlNode</span><span class="Other">]</span>
<span class="Keyword">of</span> <span class="Identifier">yMapping</span><span class="Other">:</span> <span class="Identifier">pairs</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">YamlNode</span><span class="Other">]</span><span class="Other">]</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L30"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlDocument"><a name="YamlDocument"></a><pre><span class="Identifier">YamlDocument</span> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">root</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">YamlNode</span>
</pre></dt>
<dd>
Represents a YAML document.
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L37"
class="link-seesrc" target="_blank">Source</a>
</dd>
</dl></section>
<section id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<dt id="newYamlNode"><a name="newYamlNode,string,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newYamlNode</span><span class="Other">(</span><span class="Identifier">content</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">&quot;?&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlNode</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L41"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="newYamlNode"><a name="newYamlNode,openArray[YamlNode not nil],string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newYamlNode</span><span class="Other">(</span><span class="Identifier">children</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">YamlNode</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">&quot;?&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlNode</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L44"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="newYamlNode"><a name="newYamlNode,openArray[tuple[YamlNode not nil,YamlNode not nil]],string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newYamlNode</span><span class="Other">(</span><span class="Identifier">pairs</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">YamlNode</span><span class="Other">]</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">&quot;?&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlNode</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L48"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="initYamlDoc"><a name="initYamlDoc,YamlNode not nil"></a><pre><span class="Keyword">proc</span> <span class="Identifier">initYamlDoc</span><span class="Other">(</span><span class="Identifier">root</span><span class="Other">:</span> <span class="Identifier">YamlNode</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlDocument</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L52"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="compose"><a name="compose,YamlStream,TagLibrary"></a><pre><span class="Keyword">proc</span> <span class="Identifier">compose</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">tagLib</span><span class="Other">:</span> <span class="Identifier">TagLibrary</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlDocument</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">YamlStreamError</span><span class="Other">,</span> <span class="Identifier">YamlConstructionError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L99"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="loadDOM"><a name="loadDOM,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">loadDOM</span><span class="Other">[</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">Stream</span> <span class="Operator">|</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlDocument</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">YamlParserError</span><span class="Other">,</span> <span class="Identifier">YamlConstructionError</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L109"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="serialize"><a name="serialize,YamlDocument,TagLibrary,AnchorStyle"></a><pre><span class="Keyword">proc</span> <span class="Identifier">serialize</span><span class="Other">(</span><span class="Identifier">doc</span><span class="Other">:</span> <span class="Identifier">YamlDocument</span><span class="Other">;</span> <span class="Identifier">tagLib</span><span class="Other">:</span> <span class="Identifier">TagLibrary</span><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <span class="Identifier">AnchorStyle</span> <span class="Other">=</span> <span class="Identifier">asTidy</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStream</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L166"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="dumpDOM"><a name="dumpDOM,YamlDocument,Stream,AnchorStyle,PresentationOptions"></a><pre><span class="Keyword">proc</span> <span class="Identifier">dumpDOM</span><span class="Other">(</span><span class="Identifier">doc</span><span class="Other">:</span> <span class="Identifier">YamlDocument</span><span class="Other">;</span> <span class="Identifier">target</span><span class="Other">:</span> <span class="Identifier">Stream</span><span class="Other">;</span> <span class="Identifier">anchorStyle</span><span class="Other">:</span> <span class="Identifier">AnchorStyle</span> <span class="Other">=</span> <span class="Identifier">asTidy</span><span class="Other">;</span>
<span class="Identifier">options</span><span class="Other">:</span> <span class="Identifier">PresentationOptions</span> <span class="Other">=</span> <span class="Identifier">defaultPresentationOptions</span><span class="Other">)</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">YamlPresenterJsonError</span><span class="Other">,</span> <span class="Identifier">YamlPresenterOutputError</span><span class="Other">,</span> <span class="Identifier">YamlStreamError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Dump a YamlDocument as YAML character stream.
&nbsp;&nbsp;<a
href="/yaml/dom.nim#L185"
class="link-seesrc" target="_blank">Source</a>
</dd>
</dl></section>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small>Made with Nim. Generated: 2016-11-08 21:32:29 UTC</small>
</div>
</div>
</div>
</article>
</body>
</html>