- NimYAML
+ NimYAML
Home
Testing Ground
Docs:
@@ -102,10 +102,26 @@
refs: Table[AnchorId, pointer]">ConstructionContext
SerializationContext
+ refs: Table[pointer, AnchorId]
+ style: AnchorStyle
+ nextAnchorId: AnchorId">SerializationContext
RawYamlStream
+ YamlNodeKind
+ YamlNode
+ YamlNodeObj
+ YamlDocument
dump
+ newYamlNode
+ newYamlNode
+ newYamlNode
+ initYamlDoc
+ compose
+ loadDOM
+ serialize
+ dumpDOM
@@ -474,7 +507,7 @@
yTypeUnknown | * |
Source
YamlStreamEventKind = enum
@@ -483,7 +516,7 @@ class="link-seesrc" target="_blank">Source
Kinds of YAML events that may occur in an YamlStream. Event kinds are discussed in YamlStreamEvent.
Source
TagId = distinct int
@@ -493,7 +526,7 @@ A TagId identifies a
URI strings are mapped to TagId s for efficiency reasons (you do not need to compare strings every time) and to be able to discover unknown tag URIs early in the parsing process.
Source
AnchorId = distinct int
@@ -501,7 +534,7 @@ class="link-seesrc" target="_blank">Source
An AnchorId 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 yamlEndDocument event). AnchorId s exists because of efficiency, much like TagId s. The actual anchor name is a presentation detail and cannot be queried by the user.
Source
YamlStreamEvent = object
@@ -531,7 +564,7 @@ class="link-seesrc" target="_blank">Source
A non-existing tag in the YAML character stream will be resolved to the non-specific tags ? or ! according to the YAML specification. These are by convention mapped to the TagId s yTagQuestionMark and yTagExclamationMark respectively. Mapping is done by a TagLibrary.
Source
YamlStream = object
@@ -545,7 +578,7 @@ A YamlStream is an it
The creator of a YamlStream 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 YamlStream and expect it to be well-formed if it's an input.
Source
TagLibrary = ref object
@@ -559,7 +592,7 @@ class="link-seesrc" target="_blank">Source
You can base your tag library on common tag libraries by initializing them with initFailsafeTagLibrary, initCoreTagLibrary or initExtendedTagLibrary.
Source
WarningCallback = proc (line, column: int; lineContent: string; message: string)
@@ -569,7 +602,7 @@ Callback for parser warnings. Currently, this callback may be called on two occa
Source
YamlParser = ref object
@@ -582,7 +615,7 @@ class="link-seesrc" target="_blank">Source
A parser object. Retains its TagLibrary across calls to parse. Can be used to access anchor names while parsing a YAML character stream, but only until the document goes out of scope (i.e. until yamlEndDocument is yielded).
Source
PresentationStyle = enum
@@ -596,7 +629,7 @@ Different styles for YAML character stream output.
Source
proc `==`(left: YamlStreamEvent; right: YamlStreamEvent): bool {.raises: [], tags: [].}
compares all existing fields of the given items
Source
proc `$`(event: YamlStreamEvent): string {.raises: [], tags: [].}
outputs a human-readable string describing the given event
Source
proc startDocEvent(): YamlStreamEvent {.inline, raises: [], tags: [].}
Source
proc endDocEvent(): YamlStreamEvent {.inline, raises: [], tags: [].}
Source
proc startMapEvent(tag: TagId = yTagQuestionMark; anchor: AnchorId = yAnchorNone): YamlStreamEvent {.
@@ -1132,14 +1203,14 @@ class="link-seesrc" target="_blank">Source
Source
proc endMapEvent(): YamlStreamEvent {.inline, raises: [], tags: [].}
Source
proc startSeqEvent(tag: TagId = yTagQuestionMark; anchor: AnchorId = yAnchorNone): YamlStreamEvent {.
@@ -1147,14 +1218,14 @@ class="link-seesrc" target="_blank">Source
Source
proc endSeqEvent(): YamlStreamEvent {.inline, raises: [], tags: [].}
Source
proc scalarEvent(content: string = ""; tag: TagId = yTagQuestionMark;
@@ -1163,14 +1234,14 @@ class="link-seesrc" target="_blank">Source
Source
proc aliasEvent(anchor: AnchorId): YamlStreamEvent {.inline, raises: [], tags: [].}
Source
proc constructJson(s: var YamlStream): seq[JsonNode] {.
@@ -1180,15 +1251,14 @@ class="link-seesrc" target="_blank">Source
Warning: The special float values [+-]Inf and NaN will be parsed into Nim's JSON structure without error. However, they cannot be rendered to a JSON character stream, because these values are not part of the JSON specification. Nim's JSON implementation currently does not check for these values and will output invalid JSON when rendering one of these values into a JSON character stream.
Source
-
proc loadToJson(s: Stream): seq[JsonNode] {.raises: [IOError, YamlParserError,
- YamlConstructionError, OutOfMemError], tags: [RootEffect].}
+proc loadToJson(s: Stream): seq[JsonNode] {.raises: [], tags: [RootEffect].}
Uses YamlParser and constructJson to construct an in-memory JSON tree from a YAML character stream.
Source
proc present(s: var YamlStream; target: Stream; tagLib: TagLibrary;
@@ -1198,24 +1268,24 @@ class="link-seesrc" target="_blank">Source
Convert s to a YAML character stream and write it to target.
Source
proc transform(input: Stream; output: Stream; style: PresentationStyle;
indentationStep: int = 2) {.raises: [IOError, YamlParserError,
- YamlPresenterJsonError, YamlPresenterOutputError, OutOfMemError],
+ YamlPresenterJsonError, YamlPresenterOutputError],
tags: [RootEffect, WriteIOEffect].}
Parser input as YAML character stream and then dump it to output while resolving non-specific tags to the ones in the YAML core tag library.
Source
proc guessType(scalar: string): TypeHint {.raises: [], tags: [].}
Parse scalar string according to the RegEx table documented at TypeHint.
Source
proc newYamlParser(tagLib: TagLibrary = initExtendedTagLibrary();
@@ -1223,28 +1293,28 @@ class="link-seesrc" target="_blank">Source
Creates a YAML parser. if callback is not nil, it will be called whenever the parser yields a warning.
Source
proc getLineNumber(p: YamlParser): int {.raises: [], tags: [].}
Get the line number (1-based) of the recently yielded parser token. Useful for error reporting at later loading stages.
Source
proc getColNumber(p: YamlParser): int {.raises: [], tags: [].}
Get the column number (1-based) of the recently yielded parser token. Useful for error reporting at later parsing stages.
Source
proc getLineContent(p: YamlParser; marker: bool = true): string {.raises: [], tags: [].}
Get the content of the input line containing the recently yielded parser token. Useful for error reporting at later parsing stages. The line will be terminated by "\n". If marker is true, a second line will be returned containing a ^ at the position of the recent parser token.
Source
proc parse(p: YamlParser; s: Stream): YamlStream {.raises: [],
@@ -1252,7 +1322,7 @@ class="link-seesrc" target="_blank">Source
Parse the given stream as YAML character stream.
Source
proc initYamlStream(backend: iterator (): YamlStreamEvent): YamlStream {.raises: [],
@@ -1260,7 +1330,7 @@ class="link-seesrc" target="_blank">Source
Creates a new YamlStream that uses the given iterator as backend.
Source
proc next(s: var YamlStream): YamlStreamEvent {.raises: [YamlStreamError],
@@ -1268,7 +1338,7 @@ class="link-seesrc" target="_blank">Source
Get the next item of the stream. Requires finished(s) == true. If the backend yields an exception, that exception will be encapsulated into a YamlStreamError, which will be raised.
Source
proc peek(s: var YamlStream): YamlStreamEvent {.raises: [YamlStreamError],
@@ -1276,21 +1346,21 @@ class="link-seesrc" target="_blank">Source
Get the next item of the stream without advancing the stream. Requires finished(s) == true. Handles exceptions of the backend like next().
Source
proc peek=(s: var YamlStream; value: YamlStreamEvent) {.raises: [], tags: [].}
Set the next item of the stream. Will replace a previously peeked item, if one exists.
Source
proc finished(s: var YamlStream): bool {.raises: [YamlStreamError], tags: [RootEffect].}
true if no more items are available in the stream. Handles exceptions of the backend like next().
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1298,7 +1368,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1306,7 +1376,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1314,7 +1384,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1322,7 +1392,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1330,7 +1400,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1338,7 +1408,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1346,7 +1416,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1354,7 +1424,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1362,7 +1432,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1370,7 +1440,7 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: (system.[]|tables.[]|tables.[]|json.[]|tables.[]|tables.[]|system.[]|json.[]|tables.[]|system.[]|tables.[]|system.[]|system.[]|tables.[]|macros.[]|tables.[]|tables.[]|...)(
@@ -1378,21 +1448,21 @@ class="link-seesrc" target="_blank">Source
Source
proc lazyLoadTag(uri: string): TagId {.inline, raises: [], tags: [].}
Internal function. Do not call explicitly.
Source
proc safeTagUri(id: TagId): string {.raises: [], tags: [].}
Internal function. Do not call explicitly.
Source
proc constructChild[T](s: var YamlStream; c: ConstructionContext; result: var T) {.
@@ -1400,7 +1470,7 @@ class="link-seesrc" target="_blank">Source
Used for implementing constructObject on a non-scalar type. Call it for constructing child values of the object that is constructed. It will ensure correct tag and anchor on the input stream for the child object and then call constructObject on the child object.
Source
proc constructChild[O](s: var YamlStream; c: ConstructionContext; result: var ref O) {.
@@ -1408,14 +1478,14 @@ class="link-seesrc" target="_blank">Source
Used for implementing constructObject on a non-scalar type. Call it for constructing child values of the object that is constructed. It will handle anchors, aliases and nil values, and then call constructChild on the base type.
Source
proc yamlTag[](T: typedesc[string]): TagId {.inline, noSideEffect, raises: [].}
Source
proc constructObject(s: var YamlStream; c: ConstructionContext; result: var string) {.
@@ -1423,7 +1493,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject(value: string; ts: TagStyle = tsNone; c: SerializationContext): RawYamlStream {.
@@ -1431,7 +1501,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject[T](s: var YamlStream; c: ConstructionContext; result: var T) {.
@@ -1439,7 +1509,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[T](value: T; ts: TagStyle = tsNone; c: SerializationContext): RawYamlStream {.
@@ -1447,7 +1517,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject[T](s: var YamlStream; c: ConstructionContext; result: var T) {.
@@ -1455,7 +1525,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[T](value: T; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1463,7 +1533,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject[T](s: var YamlStream; c: ConstructionContext; result: var T) {.
@@ -1471,7 +1541,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[T](value: T; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1479,14 +1549,14 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[](T: typedesc[bool]): TagId {.inline, raises: [].}
Source
proc constructObject(s: var YamlStream; c: ConstructionContext; result: var bool) {.
@@ -1494,7 +1564,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject(value: bool; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1502,7 +1572,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject(s: var YamlStream; c: ConstructionContext; result: var char) {.
@@ -1510,7 +1580,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject(value: char; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1518,14 +1588,14 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[I, ](T: typedesc[seq[I]]): TagId {.inline, raises: [].}
Source
proc constructObject[T](s: var YamlStream; c: ConstructionContext; result: var seq[T]) {.
@@ -1533,7 +1603,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[T](value: seq[T]; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1541,14 +1611,14 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[K, V, ](T: typedesc[Table[K, V]]): TagId {.inline, raises: [].}
Source
proc constructObject[K, V](s: var YamlStream; c: ConstructionContext;
@@ -1557,7 +1627,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[K, V](value: Table[K, V]; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1565,7 +1635,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject[O](s: var YamlStream; c: ConstructionContext; result: var O) {.
@@ -1573,7 +1643,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[O](value: O; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1581,7 +1651,7 @@ class="link-seesrc" target="_blank">Source
Source
proc constructObject[O](s: var YamlStream; c: ConstructionContext; result: var O) {.
@@ -1589,7 +1659,7 @@ class="link-seesrc" target="_blank">Source
Source
proc representObject[O](value: O; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1597,14 +1667,14 @@ class="link-seesrc" target="_blank">Source
Source
proc yamlTag[O, ](T: typedesc[ref O]): TagId {.inline, raises: [].}
Source
proc constructChild[T](s: var YamlStream; c: ConstructionContext; result: var T) {.
@@ -1612,7 +1682,7 @@ class="link-seesrc" target="_blank">Source
Used for implementing constructObject on a non-scalar type. Call it for constructing child values of the object that is constructed. It will ensure correct tag and anchor on the input stream for the child object and then call constructObject on the child object.
Source
proc constructChild[O](s: var YamlStream; c: ConstructionContext; result: var ref O) {.
@@ -1620,7 +1690,7 @@ class="link-seesrc" target="_blank">Source
Used for implementing constructObject on a non-scalar type. Call it for constructing child values of the object that is constructed. It will handle anchors, aliases and nil values, and then call constructChild on the base type.
Source
proc representObject[O](value: ref O; ts: TagStyle; c: SerializationContext): RawYamlStream {.
@@ -1628,7 +1698,7 @@ class="link-seesrc" target="_blank">Source
Source
proc construct[T](s: var YamlStream; target: var T) {.
@@ -1636,7 +1706,7 @@ class="link-seesrc" target="_blank">Source
Construct a Nim value from a YAML stream.
Source
proc load[K](input: Stream; target: var K) {.raises: [YamlConstructionError, IOError,
@@ -1644,7 +1714,7 @@ class="link-seesrc" target="_blank">Source
Load a Nim value from a YAML character stream.
Source
proc represent[T](value: T; ts: TagStyle = tsRootOnly; a: AnchorStyle = asTidy): YamlStream {.
@@ -1652,7 +1722,7 @@ class="link-seesrc" target="_blank">Source
Represent a Nim value as YamlStream.
Source
proc dump[K](value: K; target: Stream; style: PresentationStyle = psDefault;
@@ -1662,7 +1732,71 @@ class="link-seesrc" target="_blank">Source
Dump a Nim value as YAML character stream.
Source
+
+proc newYamlNode(content: string; tag: string = "?"): YamlNode {.raises: [], tags: [].}
+
+
+ Source
+
+proc newYamlNode(children: openArray[YamlNode]; tag: string = "?"): YamlNode {.
+ raises: [], tags: [].}
+
+
+ Source
+
+proc newYamlNode(pairs: openArray[tuple[key, value: YamlNode]]; tag: string = "?"): YamlNode {.
+ raises: [], tags: [].}
+
+
+ Source
+
+proc initYamlDoc(root: YamlNode): YamlDocument {.raises: [], tags: [].}
+
+
+ Source
+
+proc compose(s: var YamlStream; tagLib: TagLibrary): YamlDocument {.
+ raises: [YamlStreamError, YamlConstructionError], tags: [RootEffect].}
+
+
+ Source
+
+proc loadDOM(s: Stream): YamlDocument {.raises: [IOError, YamlParserError,
+ YamlConstructionError], tags: [RootEffect, ReadIOEffect].}
+
+
+ Source
+
+proc serialize(doc: YamlDocument; tagLib: TagLibrary; a: AnchorStyle = asTidy): YamlStream {.
+ raises: [], tags: [RootEffect].}
+
+
+ Source
+
+proc dumpDOM(doc: YamlDocument; target: Stream; style: PresentationStyle = psDefault;
+ anchorStyle: AnchorStyle = asTidy; indentationStep: int = 2) {.
+ raises: [YamlPresenterJsonError, YamlPresenterOutputError],
+ tags: [RootEffect, WriteIOEffect].}
+
+Dump a YamlDocument as YAML character stream.
+ Source
@@ -1675,7 +1809,7 @@ class="link-seesrc" target="_blank">Source
Iterate over all items of the stream. You may not use peek() on the stream while iterating.
Source
@@ -1687,21 +1821,21 @@ class="link-seesrc" target="_blank">Source
Source
template setTagUriForType[](t: typedesc; uri: string): stmt
Associate the given uri with a certain type. This uri is used as YAML tag when loading and dumping values of this type.
Source
template setTagUriForType[](t: typedesc; uri: string; idName: expr): stmt
Like setTagUriForType, but lets you choose a symbol for the TagId of the uri. This is only necessary if you want to implement serialization / construction yourself.
Source
template constructScalarItem(bs: var YamlStream; item: YamlStreamEvent; name: string;
@@ -1709,63 +1843,63 @@ class="link-seesrc" target="_blank">Source
Source
template constructObject(s: var YamlStream; c: ConstructionContext; result: var int)
Source
template representObject(value: int; tagStyle: TagStyle; c: SerializationContext): RawYamlStream
Source
template constructObject(s: var YamlStream; c: ConstructionContext; result: var uint)
Source
template representObject(value: uint; ts: TagStyle; c: SerializationContext): RawYamlStream
Source
template constructObject(s: var YamlStream; c: ConstructionContext; result: var float)
Source
template representObject(value: float; tagStyle: TagStyle; c: SerializationContext): RawYamlStream
Source
template yamlTag[](T: typedesc[object | enum]): expr
Source
template yamlTag[](T: typedesc[tuple]): expr
Source
@@ -1778,7 +1912,7 @@ class="link-seesrc" target="_blank">Source
- Made with Nim. Generated: 2016-02-16 20:44:55 UTC
+ Made with Nim. Generated: 2016-02-25 22:45:29 UTC