Yaml Serializer¶
| Spice | |
|---|---|
YamlSerializer struct¶
Serializer for YAML output.
By default nested mappings and sequences are emitted in block style, which is how YAML documents are usually written, with indentWidth spaces per level. With flowStyle enabled everything is emitted on a single line using flow collections ({a: 1, b: [2, 3]}) instead.
Scalars are written plain wherever that is unambiguous and double-quoted otherwise, so a string that would be read back as a number, a boolean or null keeps its type. Either way the result round-trips through parseYaml from "std/text/yaml/yaml-parser".
Constructors¶
ctor¶
| Spice | |
|---|---|
Construct a YAML serializer
Parameters
| Name | Type | Description |
|---|---|---|
indentWidth |
unsigned long |
Number of spaces per indentation level, at least one (default: 2l) |
flowStyle |
bool |
Emit everything inline using flow collections instead of block style (default: false) |
ctor¶
| Spice | |
|---|---|
Construct a YAML serializer
Parameters
| Name | Type | Description |
|---|---|---|
indentWidth |
unsigned int |
Number of spaces per indentation level, at least one |
flowStyle |
bool |
Emit everything inline using flow collections instead of block style (default: false) |
Methods¶
serialize¶
| Spice | |
|---|---|
Serializes a YAML node into a YAML document
Parameters
| Name | Type | Description |
|---|---|---|
root |
YamlValue& |
Root node to serialize |
Returns: String — YAML representation
serialize¶
| Spice | |
|---|---|
Serializes a YAML node into a YAML document
Parameters
| Name | Type | Description |
|---|---|---|
root |
YamlValue* |
Root node to serialize |
Returns: String — YAML representation
serializeDocuments¶
| Spice | |
|---|---|
Serializes a sequence of YAML nodes into a multi-document YAML stream, with one --- marker per document. This is the counterpart of parseYamlDocuments from "std/text/yaml/yaml-parser".
Parameters
| Name | Type | Description |
|---|---|---|
documents |
YamlValue* |
Sequence node holding one item per document |
Returns: String — YAML representation
serializeValue¶
| Spice | |
|---|---|
Serializes a single YAML node in its inline form, as it would appear on the right hand side of a key: value pair
Parameters
| Name | Type | Description |
|---|---|---|
value |
YamlValue* |
Node to serialize |
Returns: String — YAML representation