NimYAML Home Testing Ground Docs: Overview Serialization Modules NimYAML 2.x Source on GitHub

Module yaml/dumping

The dumping API enables you to dump native Nim values as YAML character stream. Along with the loading API, this forms the highest-level API of NimYAML.

Imports

parser, presenter, native, internal, taglib

Types

Dumper = object
  presentation*: PresentationOptions
  serialization*: SerializationOptions
Holds configuration for dumping Nim values. Default initialization yields the style that can be set via setDefaultStyle.

Procs

proc blockOnlyDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc canonicalDumper(): Dumper {....deprecated: "renamed to explanatoryDumper",
                                 raises: [], tags: [], forbids: [].}
proc dump[K](dumper: Dumper; value: K): string {.hint[XCannotRaiseY]: false, ...raises: [
    YamlPresenterJsonError, YamlPresenterOutputError, YamlSerializationError].}
Dump a Nim value as YAML into a string.
proc dump[K](dumper: Dumper; value: K; target: Stream) {....raises: [
    YamlPresenterJsonError, YamlPresenterOutputError, YamlSerializationError].}
Dump a Nim value as YAML into the given stream.
proc explanatoryDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc jsonDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc minimalDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc setBlockOnlyStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses block style exclusively.
proc setCanonicalStyle(dumper: var Dumper) {.
    ...deprecated: "renamed to setExplanatoryStyle", raises: [], tags: [],
    forbids: [].}
proc setDefaultStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses block style by default, but flow style for collections that only contain scalar values.
proc setExplanatoryStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Generates specific tags for all nodes, uses flow style, quotes all string scalars. Enables the !n! tag shorthand.
proc setJsonStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses flow style, omits tags, anchors and all other non-JSON entities, formats all scalars as corresponding JSON values.
proc setMinimalStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Tries to output single line flow-only output.
proc transform(dumper: Dumper; input: Stream | string;
               resolveToCoreYamlTags: bool = false): string {....raises: [IOError,
    OSError, YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].}
Parse input as YAML character stream and then dump it using the given presentation options. Returns the resulting string. If resolveToCoreYamlTags is true, non-specific tags will be replaced by specific tags according to the YAML core schema.
proc transform(dumper: Dumper; input: Stream | string; output: Stream;
               resolveToCoreYamlTags: bool = false) {....raises: [IOError, OSError,
    YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].}
Parse input as YAML character stream and then dump it to output using the given presentation options. If resolveToCoreYamlTags is true, non-specific tags will be replaced by specific tags according to the YAML core schema.

Exports

YamlStreamError, endMapEvent, hash, constructObject, startSeqEvent, defineCoreTag, ignore, collectionStyle, yamlTag, construct, yTagExclamationMark, peek=, yTagValue, yTagNull, constructObject, yamlTag, CollectionStyle, EventKind, hash, representObject, YamlStream, constructChild, startSeqEvent, yTagInteger, constructObject, constructionError, yTagSet, representChild, nimyamlTagRepositoryPrefix, endDocEvent, yTagMapping, implicit, startStreamEvent, ScalarStyle, constructObject, ==, presentTag, representObject, SerializationOptions, constructObject, $, Anchor, representChild, newYamlConstructionError, defineTag, representObject, constructObject, YamlLoadingError, defaultVal, Event, constructChild, constructObject, yamlTag, startMapEvent, endStreamEvent, peek, next, $, constructObjectDefault, representObject, representObject, Mark, transient, representObject, yTagYaml, constructObject, newBufferYamlStream, ConstructionContext, TagStyle, ==, scalarEvent, yamlTagRepositoryPrefix, constructScalarItem, yTagQuestionMark, constructObject, representChild, constructObject, scalar, representObject, representObject, yTagBoolean, put, hasSpecificTag, constructChild, getLastTokenContext, yamlTag, ==, representObject, yTagPairs, constructObject, yamlTag, yTagOrderedMap, representChild, Tag, properties, mitems, aliasEvent, yamlTag, representObject, emptyProperties, put, startDocEvent, startMapEvent, constructChild, constructObject, basicInit, $, scalarEvent, endSeqEvent, initConstructionContext, yTagNimField, initYamlStream, constructObject, yTagFloat, constructObject, yamlTag, constructChild, renderAttrs, YamlSerializationError, AnchorStyle, BufferYamlStream, representChild, yamlTag, yTagString, yamlTag, collection, constructChild, represent, yTagSequence, yTagBinary, representObject, yTagMerge, constructObjectDefault, sparse, constructObject, representObject, constructObject, SerializationContext, representChild, representObject, yAnchorNone, yamlTag, Properties, initSerializationContext, representObject, YamlConstructionError, items, yamlTag, representObject, yTagTimestamp, representObject