NimYAML/yaml.stream.html

507 lines
47 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.stream</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.stream</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="#AnchorId"
title="AnchorId = distinct int"><wbr />Anchor<wbr />Id</a></li>
<li><a class="reference" href="#YamlStreamEventKind"
title="YamlStreamEventKind = enum
yamlStartDoc, yamlEndDoc, yamlStartMap, yamlEndMap, yamlStartSeq, yamlEndSeq,
yamlScalar, yamlAlias"><wbr />Yaml<wbr />Stream<wbr />Event<wbr />Kind</a></li>
<li><a class="reference" href="#YamlStreamEvent"
title="YamlStreamEvent = object
case kind*: YamlStreamEventKind
of yamlStartMap:
mapAnchor*: AnchorId
mapTag*: TagId
of yamlStartSeq:
seqAnchor*: AnchorId
seqTag*: TagId
of yamlScalar:
scalarAnchor*: AnchorId
scalarTag*: TagId
scalarContent*: string
of yamlEndMap, yamlEndSeq, yamlStartDoc, yamlEndDoc:
nil
of yamlAlias:
aliasTarget*: AnchorId"><wbr />Yaml<wbr />Stream<wbr />Event</a></li>
<li><a class="reference" href="#YamlStream"
title="YamlStream = ref object of RootObj
nextImpl*: proc (s: YamlStream; e: var YamlStreamEvent): bool
lastTokenContextImpl*: proc (s: YamlStream; line, column: var int;
lineContent: var string): bool
isFinished*: bool
peeked: bool
cached: YamlStreamEvent"><wbr />Yaml<wbr />Stream</a></li>
<li><a class="reference" href="#YamlStreamError"
title="YamlStreamError = object of Exception"><wbr />Yaml<wbr />Stream<wbr />Error</a></li>
<li><a class="reference" href="#BufferYamlStream"
title="BufferYamlStream = ref object of YamlStream
pos: int
buf: seq[YamlStreamEvent] not nil"><wbr />Buffer<wbr />Yaml<wbr />Stream</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#yAnchorNone"
title="yAnchorNone: AnchorId = -1"><wbr />y<wbr />Anchor<wbr />None</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="#==,AnchorId,AnchorId"
title="`==`(left, right: AnchorId): bool"><wbr />`==`</a></li>
<li><a class="reference" href="#$,AnchorId"
title="`$`(id: AnchorId): string"><wbr />`$`</a></li>
<li><a class="reference" href="#hash,AnchorId"
title="hash(id: AnchorId): Hash"><wbr />hash</a></li>
<li><a class="reference" href="#basicInit,YamlStream,proc(YamlStream,int,int,string)"
title="basicInit(s: YamlStream; lastTokenContextImpl: proc (s: YamlStream;
line, column: var int; lineContent: var string): bool = noLastContext)"><wbr />basic<wbr />Init</a></li>
<li><a class="reference" href="#initYamlStream,"
title="initYamlStream(backend: iterator (): YamlStreamEvent): YamlStream"><wbr />init<wbr />Yaml<wbr />Stream</a></li>
<li><a class="reference" href="#newBufferYamlStream,"
title="newBufferYamlStream(): BufferYamlStream not nil"><wbr />new<wbr />Buffer<wbr />Yaml<wbr />Stream</a></li>
<li><a class="reference" href="#put,BufferYamlStream,YamlStreamEvent"
title="put(bys: BufferYamlStream; e: YamlStreamEvent)"><wbr />put</a></li>
<li><a class="reference" href="#next,YamlStream"
title="next(s: YamlStream): YamlStreamEvent"><wbr />next</a></li>
<li><a class="reference" href="#peek,YamlStream"
title="peek(s: YamlStream): YamlStreamEvent"><wbr />peek</a></li>
<li><a class="reference" href="#peek=,YamlStream,YamlStreamEvent"
title="peek=(s: YamlStream; value: YamlStreamEvent)"><wbr />peek=</a></li>
<li><a class="reference" href="#finished,YamlStream"
title="finished(s: YamlStream): bool"><wbr />finished</a></li>
<li><a class="reference" href="#getLastTokenContext,YamlStream,int,int,string"
title="getLastTokenContext(s: YamlStream; line, column: var int; lineContent: var string): bool"><wbr />get<wbr />Last<wbr />Token<wbr />Context</a></li>
<li><a class="reference" href="#==,YamlStreamEvent,YamlStreamEvent"
title="`==`(left: YamlStreamEvent; right: YamlStreamEvent): bool"><wbr />`==`</a></li>
<li><a class="reference" href="#$,YamlStreamEvent"
title="`$`(event: YamlStreamEvent): string"><wbr />`$`</a></li>
<li><a class="reference" href="#tag,YamlStreamEvent"
title="tag(event: YamlStreamEvent): TagId"><wbr />tag</a></li>
<li><a class="reference" href="#startDocEvent,"
title="startDocEvent(): YamlStreamEvent"><wbr />start<wbr />Doc<wbr />Event</a></li>
<li><a class="reference" href="#endDocEvent,"
title="endDocEvent(): YamlStreamEvent"><wbr />end<wbr />Doc<wbr />Event</a></li>
<li><a class="reference" href="#startMapEvent,TagId,AnchorId"
title="startMapEvent(tag: TagId = yTagQuestionMark; anchor: AnchorId = yAnchorNone): YamlStreamEvent"><wbr />start<wbr />Map<wbr />Event</a></li>
<li><a class="reference" href="#endMapEvent,"
title="endMapEvent(): YamlStreamEvent"><wbr />end<wbr />Map<wbr />Event</a></li>
<li><a class="reference" href="#startSeqEvent,TagId,AnchorId"
title="startSeqEvent(tag: TagId = yTagQuestionMark; anchor: AnchorId = yAnchorNone): YamlStreamEvent"><wbr />start<wbr />Seq<wbr />Event</a></li>
<li><a class="reference" href="#endSeqEvent,"
title="endSeqEvent(): YamlStreamEvent"><wbr />end<wbr />Seq<wbr />Event</a></li>
<li><a class="reference" href="#scalarEvent,string,TagId,AnchorId"
title="scalarEvent(content: string = &quot;&quot;; tag: TagId = yTagQuestionMark;
anchor: AnchorId = yAnchorNone): YamlStreamEvent"><wbr />scalar<wbr />Event</a></li>
<li><a class="reference" href="#aliasEvent,AnchorId"
title="aliasEvent(anchor: AnchorId): YamlStreamEvent"><wbr />alias<wbr />Event</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#14" id="64">Iterators</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#items.i,YamlStream"
title="items(s: YamlStream): YamlStreamEvent"><wbr />items</a></li>
<li><a class="reference" href="#mitems.i,BufferYamlStream"
title="mitems(bys: BufferYamlStream): var YamlStreamEvent"><wbr />mitems</a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"><p>The stream API provides the basic data structure on which all low-level APIs operate. It is not named <tt class="docutils literal"><span class="pre">streams</span></tt> to not confuse it with the modle in the stdlib with that name.</p>
</p>
<section id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="hashes.html">hashes</a>, <a class="reference external" href="../private/internal.html">../private/internal</a>, <a class="reference external" href="taglib.html">taglib</a>
</dl></section>
<section id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<dt id="AnchorId"><a name="AnchorId"></a><pre><span class="Identifier">AnchorId</span> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int</span></pre></dt>
<dd>
An <tt class="docutils literal"><span class="pre">AnchorId</span></tt> identifies an anchor in the current document. It becomes invalid as soon as the current document scope is invalidated (for example, because the parser yielded a <tt class="docutils literal"><span class="pre">yamlEndDocument</span></tt> event). <tt class="docutils literal"><span class="pre">AnchorId</span></tt> s exists because of efficiency, much like <tt class="docutils literal"><span class="pre">TagId</span></tt> s. The actual anchor name is a presentation detail and cannot be queried by the user.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L19"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlStreamEventKind"><a name="YamlStreamEventKind"></a><pre><span class="Identifier">YamlStreamEventKind</span> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">yamlStartDoc</span><span class="Other">,</span> <span class="Identifier">yamlEndDoc</span><span class="Other">,</span> <span class="Identifier">yamlStartMap</span><span class="Other">,</span> <span class="Identifier">yamlEndMap</span><span class="Other">,</span> <span class="Identifier">yamlStartSeq</span><span class="Other">,</span> <span class="Identifier">yamlEndSeq</span><span class="Other">,</span>
<span class="Identifier">yamlScalar</span><span class="Other">,</span> <span class="Identifier">yamlAlias</span></pre></dt>
<dd>
Kinds of YAML events that may occur in an <tt class="docutils literal"><span class="pre">YamlStream</span></tt>. Event kinds are discussed in <a class="reference external" href="#YamlStreamEvent">YamlStreamEvent</a>.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L27"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlStreamEvent"><a name="YamlStreamEvent"></a><pre><span class="Identifier">YamlStreamEvent</span> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">YamlStreamEventKind</span>
<span class="Keyword">of</span> <span class="Identifier">yamlStartMap</span><span class="Other">:</span>
<span class="Identifier">mapAnchor</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AnchorId</span>
<span class="Identifier">mapTag</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">TagId</span>
<span class="Keyword">of</span> <span class="Identifier">yamlStartSeq</span><span class="Other">:</span>
<span class="Identifier">seqAnchor</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AnchorId</span>
<span class="Identifier">seqTag</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">TagId</span>
<span class="Keyword">of</span> <span class="Identifier">yamlScalar</span><span class="Other">:</span>
<span class="Identifier">scalarAnchor</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AnchorId</span>
<span class="Identifier">scalarTag</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">TagId</span>
<span class="Identifier">scalarContent</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Keyword">of</span> <span class="Identifier">yamlEndMap</span><span class="Other">,</span> <span class="Identifier">yamlEndSeq</span><span class="Other">,</span> <span class="Identifier">yamlStartDoc</span><span class="Other">,</span> <span class="Identifier">yamlEndDoc</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">yamlAlias</span><span class="Other">:</span>
<span class="Identifier">aliasTarget</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AnchorId</span>
</pre></dt>
<dd>
<p>An element from a <a class="reference external" href="#YamlStream">YamlStream</a>. Events that start an object (<tt class="docutils literal"><span class="pre">yamlStartMap</span></tt>, <tt class="docutils literal"><span class="pre">yamlStartSeq</span></tt>, <tt class="docutils literal"><span class="pre">yamlScalar</span></tt>) have an optional anchor and a tag associated with them. The anchor will be set to <tt class="docutils literal"><span class="pre">yAnchorNone</span></tt> if it doesn't exist.</p>
<p>A non-existing tag in the YAML character stream will be resolved to the non-specific tags <tt class="docutils literal"><span class="pre">?</span></tt> or <tt class="docutils literal"><span class="pre">!</span></tt> according to the YAML specification. These are by convention mapped to the <tt class="docutils literal"><span class="pre">TagId</span></tt> s <tt class="docutils literal"><span class="pre">yTagQuestionMark</span></tt> and <tt class="docutils literal"><span class="pre">yTagExclamationMark</span></tt> respectively. Mapping is done by a <a class="reference external" href="#TagLibrary">TagLibrary</a>.</p>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L33"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlStream"><a name="YamlStream"></a><pre><span class="Identifier">YamlStream</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">RootObj</span>
<span class="Identifier">nextImpl</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">e</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">YamlStreamEvent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">lastTokenContextImpl</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">line</span><span class="Other">,</span> <span class="Identifier">column</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">lineContent</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</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></div><span class="Other pragmaend">.}</span>
<span class="Identifier">isFinished</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">peeked</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">cached</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span>
</pre></dt>
<dd>
<p>
A <tt class="docutils literal"><span class="pre">YamlStream</span></tt> is an iterator-like object that yields a well-formed stream of <tt class="docutils literal"><span class="pre">YamlStreamEvents</span></tt>. Well-formed means that every <tt class="docutils literal"><span class="pre">yamlStartMap</span></tt> is terminated by a <tt class="docutils literal"><span class="pre">yamlEndMap</span></tt>, every <tt class="docutils literal"><span class="pre">yamlStartSeq</span></tt> is terminated by a <tt class="docutils literal"><span class="pre">yamlEndSeq</span></tt> and every <tt class="docutils literal"><span class="pre">yamlStartDoc</span></tt> is terminated by a <tt class="docutils literal"><span class="pre">yamlEndDoc</span></tt>. Moreover, every emitted mapping has an even number of children.</p>
<p>The creator of a <tt class="docutils literal"><span class="pre">YamlStream</span></tt> is responsible for it being well-formed. A user of the stream may assume that it is well-formed and is not required to check for it. The procs in this module will always yield a well-formed <tt class="docutils literal"><span class="pre">YamlStream</span></tt> and expect it to be well-formed if they take it as input parameter.</p>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L59"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="YamlStreamError"><a name="YamlStreamError"></a><pre><span class="Identifier">YamlStreamError</span> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">Exception</span>
</pre></dt>
<dd>
Exception that may be raised by a <tt class="docutils literal"><span class="pre">YamlStream</span></tt> when the underlying backend raises an exception. The error that has occurred is available from <tt class="docutils literal"><span class="pre">parent</span></tt>.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L80"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="BufferYamlStream"><a name="BufferYamlStream"></a><pre><span class="Identifier">BufferYamlStream</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">YamlStream</span>
<span class="Identifier">pos</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">buf</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">YamlStreamEvent</span><span class="Other">]</span> <span class="Keyword">not</span> <span class="Keyword">nil</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L126"
class="link-seesrc" target="_blank">Source</a>
</dd>
</dl></section>
<section id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<dt id="yAnchorNone"><a name="yAnchorNone"></a><pre><span class="Identifier">yAnchorNone</span><span class="Other">:</span> <span class="Identifier">AnchorId</span> <span class="Other">=</span> <span class="DecNumber">-1</span></pre></dt>
<dd>
yielded when no anchor was defined for a YAML node
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L86"
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="=="><a name="==,AnchorId,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">`==`</span><span class="Other">(</span><span class="Identifier">left</span><span class="Other">,</span> <span class="Identifier">right</span><span class="Other">:</span> <span class="Identifier">AnchorId</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">borrow</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L89"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="$"><a name="$,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">`$`</span><span class="Other">(</span><span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">AnchorId</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">borrow</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L90"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="hash"><a name="hash,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">hash</span><span class="Other">(</span><span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">AnchorId</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Hash</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">borrow</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L91"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="basicInit"><a name="basicInit,YamlStream,proc(YamlStream,int,int,string)"></a><pre><span class="Keyword">proc</span> <span class="Identifier">basicInit</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">lastTokenContextImpl</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span>
<span class="Identifier">line</span><span class="Other">,</span> <span class="Identifier">column</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">lineContent</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</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></div><span class="Other pragmaend">.}</span> <span class="Other">=</span> <span class="Identifier">noLastContext</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="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>
initialize basic values of the YamlStream. Call this in your constructor if you subclass YamlStream.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L98"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="initYamlStream"><a name="initYamlStream,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">initYamlStream</span><span class="Other">(</span><span class="Identifier">backend</span><span class="Other">:</span> <span class="Keyword">iterator</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Creates a new <tt class="docutils literal"><span class="pre">YamlStream</span></tt> that uses the given iterator as backend.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L112"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="newBufferYamlStream"><a name="newBufferYamlStream,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newBufferYamlStream</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">BufferYamlStream</span> <span class="Keyword">not</span> <span class="Keyword">nil</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/stream.nim#L130"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="put"><a name="put,BufferYamlStream,YamlStreamEvent"></a><pre><span class="Keyword">proc</span> <span class="Identifier">put</span><span class="Other">(</span><span class="Identifier">bys</span><span class="Other">:</span> <span class="Identifier">BufferYamlStream</span><span class="Other">;</span> <span class="Identifier">e</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="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/stream.nim#L145"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="next"><a name="next,YamlStream"></a><pre><span class="Keyword">proc</span> <span class="Identifier">next</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="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>
Get the next item of the stream. Requires <tt class="docutils literal"><span class="pre">finished(s) == true</span></tt>. If the backend yields an exception, that exception will be encapsulated into a <tt class="docutils literal"><span class="pre">YamlStreamError</span></tt>, which will be raised.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L148"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="peek"><a name="peek,YamlStream"></a><pre><span class="Keyword">proc</span> <span class="Identifier">peek</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="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>
Get the next item of the stream without advancing the stream. Requires <tt class="docutils literal"><span class="pre">finished(s) == true</span></tt>. Handles exceptions of the backend like <tt class="docutils literal"><span class="pre">next()</span></tt>.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L173"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="peek="><a name="peek=,YamlStream,YamlStreamEvent"></a><pre><span class="Keyword">proc</span> <span class="Identifier">peek=</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="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>
Set the next item of the stream. Will replace a previously peeked item, if one exists.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L182"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="finished"><a name="finished,YamlStream"></a><pre><span class="Keyword">proc</span> <span class="Identifier">finished</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</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="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>
<tt class="docutils literal"><span class="pre">true</span></tt> if no more items are available in the stream. Handles exceptions of the backend like <tt class="docutils literal"><span class="pre">next()</span></tt>.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L188"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="getLastTokenContext"><a name="getLastTokenContext,YamlStream,int,int,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">getLastTokenContext</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">;</span> <span class="Identifier">line</span><span class="Other">,</span> <span class="Identifier">column</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">lineContent</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</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>
<tt class="docutils literal"><span class="pre">true</span></tt> if source context information is available about the last returned token. If <tt class="docutils literal"><span class="pre">true</span></tt>, line, column and lineContent are set to position and line content where the last token has been read from.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L210"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="=="><a name="==,YamlStreamEvent,YamlStreamEvent"></a><pre><span class="Keyword">proc</span> <span class="Identifier">`==`</span><span class="Other">(</span><span class="Identifier">left</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span><span class="Other">;</span> <span class="Identifier">right</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</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>
compares all existing fields of the given items
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L228"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="$"><a name="$,YamlStreamEvent"></a><pre><span class="Keyword">proc</span> <span class="Identifier">`$`</span><span class="Other">(</span><span class="Identifier">event</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</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>
outputs a human-readable string describing the given event
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L243"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="tag"><a name="tag,YamlStreamEvent"></a><pre><span class="Keyword">proc</span> <span class="Identifier">tag</span><span class="Other">(</span><span class="Identifier">event</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">TagId</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">FieldError</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>
returns the tag of the given event
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L263"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="startDocEvent"><a name="startDocEvent,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">startDocEvent</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the start of a YAML document
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L271"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="endDocEvent"><a name="endDocEvent,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">endDocEvent</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the end of a YAML document
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L275"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="startMapEvent"><a name="startMapEvent,TagId,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">startMapEvent</span><span class="Other">(</span><span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">TagId</span> <span class="Other">=</span> <span class="Identifier">yTagQuestionMark</span><span class="Other">;</span> <span class="Identifier">anchor</span><span class="Other">:</span> <span class="Identifier">AnchorId</span> <span class="Other">=</span> <span class="Identifier">yAnchorNone</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the start of a YAML mapping
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L279"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="endMapEvent"><a name="endMapEvent,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">endMapEvent</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the end of a YAML mapping
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L284"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="startSeqEvent"><a name="startSeqEvent,TagId,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">startSeqEvent</span><span class="Other">(</span><span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">TagId</span> <span class="Other">=</span> <span class="Identifier">yTagQuestionMark</span><span class="Other">;</span> <span class="Identifier">anchor</span><span class="Other">:</span> <span class="Identifier">AnchorId</span> <span class="Other">=</span> <span class="Identifier">yAnchorNone</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the beginning of a YAML sequence
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L288"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="endSeqEvent"><a name="endSeqEvent,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">endSeqEvent</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that marks the end of a YAML sequence
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L293"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="scalarEvent"><a name="scalarEvent,string,TagId,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">scalarEvent</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="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">TagId</span> <span class="Other">=</span> <span class="Identifier">yTagQuestionMark</span><span class="Other">;</span>
<span class="Identifier">anchor</span><span class="Other">:</span> <span class="Identifier">AnchorId</span> <span class="Other">=</span> <span class="Identifier">yAnchorNone</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that represents a YAML scalar
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L297"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="aliasEvent"><a name="aliasEvent,AnchorId"></a><pre><span class="Keyword">proc</span> <span class="Identifier">aliasEvent</span><span class="Other">(</span><span class="Identifier">anchor</span><span class="Other">:</span> <span class="Identifier">AnchorId</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <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>
creates a new event that represents a YAML alias
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L303"
class="link-seesrc" target="_blank">Source</a>
</dd>
</dl></section>
<section id="14">
<h1><a class="toc-backref" href="#14">Iterators</a></h1>
<dl class="item">
<dt id="items"><a name="items.i,YamlStream"></a><pre><span class="Keyword">iterator</span> <span class="Identifier">items</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">YamlStream</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">YamlStreamEvent</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="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>
Iterate over all items of the stream. You may not use <tt class="docutils literal"><span class="pre">peek()</span></tt> on the stream while iterating.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L217"
class="link-seesrc" target="_blank">Source</a>
</dd>
<dt id="mitems"><a name="mitems.i,BufferYamlStream"></a><pre><span class="Keyword">iterator</span> <span class="Identifier">mitems</span><span class="Other">(</span><span class="Identifier">bys</span><span class="Other">:</span> <span class="Identifier">BufferYamlStream</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">YamlStreamEvent</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>
Iterate over all items of the stream. You may not use <tt class="docutils literal"><span class="pre">peek()</span></tt> on the stream while iterating.
&nbsp;&nbsp;<a
href="/yaml/stream.nim#L223"
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:31 UTC</small>
</div>
</div>
</div>
</article>
</body>
</html>