<pclass="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 <ttclass="docutils literal"><spanclass="pre">loadDom</span></tt> and <ttclass="docutils literal"><spanclass="pre">dumpDom</span></tt>. The other exposed procs are low-level and useful if you want to load or generate parts of a <ttclass="docutils literal"><spanclass="pre">YamlStream</span></tt>.</p>
<p>The <ttclass="docutils literal"><spanclass="pre">YamlNode</span></tt> objects in the DOM can be used similarly to the <ttclass="docutils literal"><spanclass="pre">JsonNode</span></tt> objects of Nim's <aclass="reference external"href="http://nim-lang.org/docs/json.html">json module</a>.</p>
<dtid="hash"><aname="hash,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">hash</span><spanclass="Other">(</span><spanclass="Identifier">o</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">Hash</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
<a
href="/yaml/dom.nim#L45"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="=="><aname="==,YamlNode not nil,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`==`</span><spanclass="Other">(</span><spanclass="Identifier">x</span><spanclass="Other">,</span><spanclass="Identifier">y</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">bool</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
<a
href="/yaml/dom.nim#L94"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="$"><aname="$,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`$`</span><spanclass="Other">(</span><spanclass="Identifier">n</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">string</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dtid="newYamlNode"><aname="newYamlNode,openArray[YamlNode not nil],string"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">newYamlNode</span><spanclass="Other">(</span><spanclass="Identifier">elems</span><spanclass="Other">:</span><spanclass="Identifier">openArray</span><spanclass="Other">[</span><spanclass="Identifier">YamlNode</span><spanclass="Other">]</span><spanclass="Other">;</span><spanclass="Identifier">tag</span><spanclass="Other">:</span><spanclass="Identifier">string</span><spanclass="Other">=</span><spanclass="StringLit">"?"</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span>
<dtid="initYamlDoc"><aname="initYamlDoc,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">initYamlDoc</span><spanclass="Other">(</span><spanclass="Identifier">root</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlDocument</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dtid="[]"><aname="[],YamlNode not nil,int"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`[]`</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">i</span><spanclass="Other">:</span><spanclass="Identifier">int</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Get the node at index <em>i</em> from a sequence. <em>node</em> must be a <em>ySequence</em>.
<a
href="/yaml/dom.nim#L310"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="[]="><aname="[]=,YamlNode not nil,int,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`[]=`</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Keyword">var</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">i</span><spanclass="Other">:</span><spanclass="Identifier">int</span><spanclass="Other">;</span><spanclass="Identifier">val</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Set the node at index <em>i</em> of a sequence. <em>node</em> must be a <em>ySequence</em>.
<a
href="/yaml/dom.nim#L315"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="[]"><aname="[],YamlNode not nil,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`[]`</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">key</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Identifier">KeyError</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Get the value for a key in a mapping. <em>node</em> must be a <em>yMapping</em>.
<a
href="/yaml/dom.nim#L320"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="[]="><aname="[]=,YamlNode not nil,YamlNode not nil,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`[]=`</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">key</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">value</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Set the value for a key in a mapping. <em>node</em> must be a <em>yMapping</em>.
<a
href="/yaml/dom.nim#L325"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="[]"><aname="[],YamlNode not nil,string"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">`[]`</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">;</span><spanclass="Identifier">key</span><spanclass="Other">:</span><spanclass="Identifier">string</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Identifier">KeyError</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Get the value for a string key in a mapping. <em>node</em> must be a <em>yMapping</em>. This searches for a scalar key with content <em>key</em> and either no explicit tag or the explicit tag <ttclass="docutils literal"><spanclass="pre">!!str</span></tt>.
<a
href="/yaml/dom.nim#L329"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="len"><aname="len,YamlNode not nil"></a><pre><spanclass="Keyword">proc</span><spanclass="Identifier">len</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">int</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
If <em>node</em> is a <em>yMapping</em>, return the number of key-value pairs. If <em>node</em> is a <em>ySequence</em>, return the number of elements. Else, return <ttclass="docutils literal"><spanclass="pre">0</span></tt>
<dtid="items"><aname="items.i,YamlNode not nil"></a><pre><spanclass="Keyword">iterator</span><spanclass="Identifier">items</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Iterates over all items of a sequence. <em>node</em> must be a <em>ySequence</em>.
<a
href="/yaml/dom.nim#L353"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="mitems"><aname="mitems.i,YamlNode not nil"></a><pre><spanclass="Keyword">iterator</span><spanclass="Identifier">mitems</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Keyword">var</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Iterates over all items of a sequence. <em>node</em> must be a <em>ySequence</em>. Values can be modified.
<a
href="/yaml/dom.nim#L358"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="pairs"><aname="pairs.i,YamlNode not nil"></a><pre><spanclass="Keyword">iterator</span><spanclass="Identifier">pairs</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Keyword">tuple</span><spanclass="Other">[</span><spanclass="Identifier">key</span><spanclass="Other">,</span><spanclass="Identifier">value</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">]</span><spanclass="Other pragmabegin">{.</span><divclass="pragma"><spanclass="Identifier">raises</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span><spanclass="Other">,</span><spanclass="Identifier">tags</span><spanclass="Other">:</span><spanclass="Other">[</span><spanclass="Other">]</span></div><spanclass="Other pragmaend">.}</span></pre></dt>
<dd>
Iterates over all key-value pairs of a mapping. <em>node</em> must be a <em>yMapping</em>.
<a
href="/yaml/dom.nim#L364"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dtid="mpairs"><aname="mpairs.i,YamlNode not nil"></a><pre><spanclass="Keyword">iterator</span><spanclass="Identifier">mpairs</span><spanclass="Other">(</span><spanclass="Identifier">node</span><spanclass="Other">:</span><spanclass="Keyword">var</span><spanclass="Identifier">YamlNode</span><spanclass="Other">)</span><spanclass="Other">:</span><spanclass="Keyword">tuple</span><spanclass="Other">[</span><spanclass="Identifier">key</span><spanclass="Other">:</span><spanclass="Identifier">YamlNode</span><spanclass="Other">,</span><spanclass="Identifier">value</span><spanclass="Other">:</span><spanclass="Keyword">var</span><spanclass="Identifier">YamlNode</span><spanclass="Other">]</span><spanclass="Other pragmabegin">{.</span><divclass="pragma">