Emitter

public final class Emitter

Class responsible for emitting libYAML events.

  • Line break options to use when emitting YAML.

    See more

    Declaration

    Swift

    public enum LineBreak
  • Retrieve this Emitter’s binary output.

    Declaration

    Swift

    public internal(set) var data: Data { get }
  • Configuration options to use when emitting YAML.

    See more

    Declaration

    Swift

    public struct Options
  • Configuration options to use when emitting YAML.

    Declaration

    Swift

    public var options: Options { get set }
  • Create an Emitter with the specified options.

    Declaration

    Swift

    public init(canonical: Bool = false,
                indent: Int = 0,
                width: Int = 0,
                allowUnicode: Bool = false,
                lineBreak: 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)

    Parameters

    canonical

    Set if the output should be in the “canonical” format described in the YAML specification.

    indent

    Set the indentation value.

    width

    Set the preferred line width. -1 means unlimited.

    allowUnicode

    Set if unescaped non-ASCII characters are allowed.

    lineBreak

    Set the preferred line break.

    explicitStart

    Explicit document start ---.

    explicitEnd

    Explicit document end ....

    version

    The %YAML directive value or nil.

    sortKeys

    Set if emitter should sort keys in lexicographic order.

    sequenceStyle

    Set the style for sequences (arrays / lists)

    mappingStyle

    Set the style for mappings (dictionaries)

  • Open & initialize the emitter.

    Throws

    YamlError if the Emitter was already opened or closed.

    Declaration

    Swift

    public func open() throws
  • Close the Emitter.

    Throws

    YamlError if the Emitter hasn’t yet been initialized.

    Declaration

    Swift

    public func close() throws
  • Ingest a Node to include when emitting the YAML output.

    Throws

    YamlError if the Emitter hasn’t yet been opened or has been closed.

    Declaration

    Swift

    public func serialize(node: Node) throws

    Parameters

    node

    The Node to serialize.