Functions
The following functions are available globally.
-
dump(objects:
canonical: indent: width: allowUnicode: lineBreak: explicitStart: explicitEnd: version: sortKeys: sequenceStyle: mappingStyle: newLineScalarStyle: ) Produce a YAML string from objects.
Throws
Declaration
Swift
public func dump<Objects>( objects: Objects, canonical: Bool = false, indent: Int = 0, width: Int = 0, allowUnicode: Bool = false, lineBreak: Emitter.LineBreak = .ln, explicitStart: Bool = false, explicitEnd: Bool = false, version: (major: Int, minor: Int)? = nil, sortKeys: Bool = false, sequenceStyle: Node.Sequence.Style = .any, mappingStyle: Node.Mapping.Style = .any, newLineScalarStyle: Node.Scalar.Style = .any) throws -> String where Objects: Sequence
Parameters
objects
Sequence of Objects.
canonical
Output should be the “canonical” format as in the YAML specification.
indent
The indentation increment.
width
The preferred line width. @c -1 means unlimited.
allowUnicode
Unescaped non-ASCII characters are allowed if true.
lineBreak
Preferred line break.
explicitStart
Explicit document start
---
.explicitEnd
Explicit document end
...
.version
YAML version directive.
sortKeys
Whether or not to sort Mapping keys in lexicographic order.
sequenceStyle
The style for sequences (arrays / lists)
mappingStyle
The style for mappings (dictionaries)
Return Value
YAML string.
-
dump(object:
canonical: indent: width: allowUnicode: lineBreak: explicitStart: explicitEnd: version: sortKeys: sequenceStyle: mappingStyle: newLineScalarStyle: ) Produce a YAML string from an object.
Throws
Declaration
Swift
public func dump( object: Any?, canonical: Bool = false, indent: Int = 0, width: Int = 0, allowUnicode: Bool = false, lineBreak: Emitter.LineBreak = .ln, explicitStart: Bool = false, explicitEnd: Bool = false, version: (major: Int, minor: Int)? = nil, sortKeys: Bool = false, sequenceStyle: Node.Sequence.Style = .any, mappingStyle: Node.Mapping.Style = .any, newLineScalarStyle: Node.Scalar.Style = .any) throws -> String
Parameters
object
Object.
canonical
Output should be the “canonical” format as in the YAML specification.
indent
The indentation increment.
width
The preferred line width. @c -1 means unlimited.
allowUnicode
Unescaped non-ASCII characters are allowed if true.
lineBreak
Preferred line break.
explicitStart
Explicit document start
---
.explicitEnd
Explicit document end
...
.version
YAML version directive.
sortKeys
Whether or not to sort Mapping keys in lexicographic order.
sequenceStyle
The style for sequences (arrays / lists)
mappingStyle
The style for mappings (dictionaries)
Return Value
YAML string.
-
serialize(nodes:
canonical: indent: width: allowUnicode: lineBreak: explicitStart: explicitEnd: version: sortKeys: sequenceStyle: mappingStyle: newLineScalarStyle: ) Declaration
Swift
public func serialize<Nodes>( nodes: Nodes, canonical: Bool = false, indent: Int = 0, width: Int = 0, allowUnicode: Bool = false, lineBreak: Emitter.LineBreak = .ln, explicitStart: Bool = false, explicitEnd: Bool = false, version: (major: Int, minor: Int)? = nil, sortKeys: Bool = false, sequenceStyle: Node.Sequence.Style = .any, mappingStyle: Node.Mapping.Style = .any, newLineScalarStyle: Node.Scalar.Style = .any) throws -> String where Nodes: Sequence, Nodes.Iterator.Element == Node
Parameters
nodes
Sequence of
Node
s.canonical
Output should be the “canonical” format as in the YAML specification.
indent
The indentation increment.
width
The preferred line width. @c -1 means unlimited.
allowUnicode
Unescaped non-ASCII characters are allowed if true.
lineBreak
Preferred line break.
explicitStart
Explicit document start
---
.explicitEnd
Explicit document end
...
.version
YAML version directive.
sortKeys
Whether or not to sort Mapping keys in lexicographic order.
sequenceStyle
The style for sequences (arrays / lists)
mappingStyle
The style for mappings (dictionaries)
Return Value
YAML string.
-
serialize(node:
canonical: indent: width: allowUnicode: lineBreak: explicitStart: explicitEnd: version: sortKeys: sequenceStyle: mappingStyle: newLineScalarStyle: ) Declaration
Swift
public func serialize( node: Node, canonical: Bool = false, indent: Int = 0, width: Int = 0, allowUnicode: Bool = false, lineBreak: Emitter.LineBreak = .ln, explicitStart: Bool = false, explicitEnd: Bool = false, version: (major: Int, minor: Int)? = nil, sortKeys: Bool = false, sequenceStyle: Node.Sequence.Style = .any, mappingStyle: Node.Mapping.Style = .any, newLineScalarStyle: Node.Scalar.Style = .any) throws -> String
Parameters
node
Node
.canonical
Output should be the “canonical” format as in the YAML specification.
indent
The indentation increment.
width
The preferred line width. @c -1 means unlimited.
allowUnicode
Unescaped non-ASCII characters are allowed if true.
lineBreak
Preferred line break.
explicitStart
Explicit document start
---
.explicitEnd
Explicit document end
...
.version
YAML version directive.
sortKeys
Whether or not to sort Mapping keys in lexicographic order.
sequenceStyle
The style for sequences (arrays / lists)
mappingStyle
The style for mappings (dictionaries)
Return Value
YAML string.
-
Parse all YAML documents in a String and produce corresponding Swift objects.
Throws
YamlError
Declaration
Swift
public func load_all(yaml: String, _ resolver: Resolver = .default, _ constructor: Constructor = .default, _ encoding: Parser.Encoding = .default) throws -> YamlSequence<Any>
Parameters
yaml
String
resolver
Resolver
constructor
Constructor
encoding
Parser.Encoding
Return Value
YamlSequence
-
Parse the first YAML document in a String and produce the corresponding Swift object.
Throws
YamlError
Declaration
Swift
public func load(yaml: String, _ resolver: Resolver = .default, _ constructor: Constructor = .default, _ encoding: Parser.Encoding = .default) throws -> Any?
Parameters
yaml
String
resolver
Resolver
constructor
Constructor
encoding
Parser.Encoding
Return Value
Any?
-
Parse all YAML documents in a String and produce corresponding representation trees.
Throws
YamlError
Declaration
Swift
public func compose_all(yaml: String, _ resolver: Resolver = .default, _ constructor: Constructor = .default, _ encoding: Parser.Encoding = .default) throws -> YamlSequence<Node>
Parameters
yaml
String
resolver
Resolver
constructor
Constructor
encoding
Parser.Encoding
Return Value
YamlSequence
-
Parse the first YAML document in a String and produce the corresponding representation tree.
Throws
YamlError
Declaration
Swift
public func compose(yaml: String, _ resolver: Resolver = .default, _ constructor: Constructor = .default, _ encoding: Parser.Encoding = .default) throws -> Node?
Parameters
yaml
String
resolver
Resolver
constructor
Constructor
encoding
Parser.Encoding
Return Value
Node?