2016-01-05 22:17:39 +00:00
<!DOCTYPE html>
2016-01-13 21:45:08 +00:00
< 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 - NimYAML< / 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 >
< header >
< a class = "pagetitle" href = "/" > NimYAML< / a >
< a href = "index.html" > Home< / a >
< a href = "testing.html" > Testing Ground< / a >
2016-02-15 21:56:36 +00:00
< span > Docs:< / span >
2016-02-15 18:51:05 +00:00
< a href = "api.html" > Overview< / a >
2016-02-15 21:56:36 +00:00
< a href = "serialization.html" > Serialization< / a >
2016-01-13 21:45:08 +00:00
< a href = "yaml.html" > Module yaml< / a >
< / header >
< article id = "documentId" >
< div class = "container" >
< h1 class = "title" > NimYAML< / h1 >
2016-02-12 19:46:01 +00:00
< h1 id = "introduction" > Introduction< / h1 > < p > < strong > NimYAML< / strong > is a pure YAML implementation for Nim. It is able to read from and write to YAML character streams, and to serialize from and construct to native Nim types. It exclusively supports < a class = "reference external" href = "#http://www.yaml.org/spec/1.2/spec.html" > YAML 1.2< / a > .< / p >
< h2 id = "quickstart" > Quickstart< / h2 > < p > Data used in quickstart code may not be accurate and is solely used to showcase NimYAML's features.< / p >
< pre class = "listing" > < span class = "Keyword" > import< / span > < span class = "Identifier" > yaml< / span >
< span class = "Keyword" > type< / span >
< span class = "Identifier" > GenderKind< / span > < span class = "Operator" > *< / span > < span class = "Operator" > =< / span > < span class = "Keyword" > enum< / span >
< span class = "Identifier" > male< / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > female< / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > other< / span >
< span class = "Identifier" > Person< / span > < span class = "Operator" > *< / span > < span class = "Operator" > =< / span > < span class = "Keyword" > object< / span >
< span class = "Identifier" > name< / span > < span class = "Operator" > *:< / span > < span class = "Identifier" > string< / span >
< span class = "Identifier" > gender< / span > < span class = "Operator" > *:< / span > < span class = "Identifier" > GenderKind< / span >
< span class = "Identifier" > age< / span > < span class = "Operator" > *:< / span > < span class = "Identifier" > int32< / span >
< span class = "Identifier" > spouse< / span > < span class = "Operator" > *:< / span > < span class = "Keyword" > ref< / span > < span class = "Identifier" > Person< / span >
< span class = "Identifier" > offspring< / span > < span class = "Operator" > *:< / span > < span class = "Identifier" > seq< / span > < span class = "Punctuation" > [< / span > < span class = "Keyword" > ref< / span > < span class = "Identifier" > Person< / span > < span class = "Punctuation" > ]< / span >
< span class = "Keyword" > let< / span > < span class = "Identifier" > input< / span > < span class = "Operator" > =< / span > < span class = "Identifier" > newStringStream< / span > < span class = "Punctuation" > (< / span > < span class = "LongStringLit" > " " "
%YAML 1.2
---
- & a
name: Luke Skywalker
gender: male
age: 19
spouse: ~
offspring: []
- & b
name: Han Solo
gender: male
age: 35
spouse: & c
name: Leia Organa
gender: female
age: 19
spouse: *b
offspring: []
offspring: []
- *c
-
name: Anakin Skywalker
gender: male
age: 42
spouse: ~
offspring: [*a, *c]
" " " < / span > < span class = "Punctuation" > )< / span >
< span class = "Keyword" > var< / span > < span class = "Identifier" > persons< / span > < span class = "Punctuation" > :< / span > < span class = "Identifier" > seq< / span > < span class = "Punctuation" > [< / span > < span class = "Keyword" > ref< / span > < span class = "Identifier" > Person< / span > < span class = "Punctuation" > ]< / span >
< span class = "Identifier" > load< / span > < span class = "Punctuation" > (< / span > < span class = "Identifier" > input< / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > persons< / span > < span class = "Punctuation" > )< / span >
< span class = "Keyword" > for< / span > < span class = "Identifier" > person< / span > < span class = "Keyword" > in< / span > < span class = "Identifier" > persons< / span > < span class = "Punctuation" > :< / span >
< span class = "Identifier" > echo< / span > < span class = "Identifier" > person< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > name< / span > < span class = "Punctuation" > ,< / span > < span class = "StringLit" > " < / span > < span class = "EscapeSequence" > \n< / span > < span class = "StringLit" > age " < / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > person< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > age< / span >
< span class = "Keyword" > if< / span > < span class = "Identifier" > person< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > spouse< / span > < span class = "Operator" > !=< / span > < span class = "Keyword" > nil< / span > < span class = "Punctuation" > :< / span >
< span class = "Identifier" > echo< / span > < span class = "StringLit" > " spouse: " < / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > person< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > spouse< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > name< / span >
< span class = "Keyword" > for< / span > < span class = "Identifier" > child< / span > < span class = "Keyword" > in< / span > < span class = "Identifier" > person< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > offspring< / span > < span class = "Punctuation" > :< / span >
< span class = "Keyword" > case< / span > < span class = "Identifier" > child< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > gender< / span >
< span class = "Keyword" > of< / span > < span class = "Identifier" > male< / span > < span class = "Punctuation" > :< / span > < span class = "Identifier" > echo< / span > < span class = "StringLit" > " son: " < / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > child< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > name< / span >
< span class = "Keyword" > of< / span > < span class = "Identifier" > female< / span > < span class = "Punctuation" > :< / span > < span class = "Identifier" > echo< / span > < span class = "StringLit" > " daughter: " < / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > child< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > name< / span >
< span class = "Keyword" > of< / span > < span class = "Identifier" > other< / span > < span class = "Punctuation" > :< / span > < span class = "Identifier" > echo< / span > < span class = "StringLit" > " child: " < / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > child< / span > < span class = "Operator" > .< / span > < span class = "Identifier" > name< / span >
< span class = "Identifier" > echo< / span > < span class = "StringLit" > " ------------------------" < / span >
< span class = "Identifier" > dump< / span > < span class = "Punctuation" > (< / span > < span class = "Identifier" > persons< / span > < span class = "Punctuation" > ,< / span > < span class = "Identifier" > newFileStream< / span > < span class = "Punctuation" > (< / span > < span class = "Identifier" > stdout< / span > < span class = "Punctuation" > )< / span > < span class = "Punctuation" > )< / span > < / pre >
2016-01-13 21:45:08 +00:00
< div class = "row" >
< div class = "twelve-columns footer" >
< span class = "nim-sprite" > < / span >
< br / >
2016-02-15 21:56:36 +00:00
< small > Made with Nim. Generated: 2016-02-15 22:56:21 UTC< / small >
2016-01-13 21:45:08 +00:00
< / div >
< / div >
< / div >
< / article >
< / body >
< / html >