abla/yaml/document

Generated from source.

Source module; follow its importing module's re-export links.

Source: abla/yaml/document.ab

YamlDocument (class)

class YamlDocument(val source: string, val value: Yaml,
    val nodes: array<YamlSourceNode>, val root: int, val limits: YamlLimits,
    val valid: bool)

Keeps the original YAML text, parsed value and source nodes used for lossless edits.

YamlDocumentResult (class)

class YamlDocumentResult(val document: YamlDocument, val succeeded: bool, val error: YamlError)

Holds a parsed or edited document with its success flag and diagnostic.

YamlPathPart (class)

class YamlPathPart(val indexed: bool, val key: Yaml, val index: int)

Identifies a path component as a sequence index or scalar mapping key.

yamlKey (fun)

fun yamlKey(key: string): YamlPathPart

Builds a path segment selecting the string mapping key.

yamlValueKey (fun)

fun yamlValueKey(key: Yaml): YamlPathPart

Builds a path segment selecting the typed scalar mapping key.

yamlIndex (fun)

fun yamlIndex(index: int): YamlPathPart

Builds a path segment selecting zero-based sequence index. The editor checks the index when using it.

yamlParseDocument (fun)

fun yamlParseDocument(source: string,
    limits: YamlLimits = yamlDefaultLimits()): YamlDocumentResult

Parses source with limits and retains its original text and source ranges for editing. Returns a located error and an invalid document on failure.

YamlDocument.toText (extension fun)

fun YamlDocument.toText(): string

Returns the document's retained source text.

YamlEditor (class)

class YamlEditor(val original: YamlDocument, var current: YamlDocument,
    var error: YamlError, var work: int)

Tracks the original and current documents, the first edit error and the editing work budget.

YamlDocument.edit (extension fun)

fun YamlDocument.edit(): YamlEditor

Starts an edit session with this document as the original and current value.

YamlEditor.finish (extension fun)

fun YamlEditor.finish(): YamlDocumentResult

Returns the edited document after successful operations. Any edit error or invalid source returns the original document and the error.

YamlEditor.fail (extension fun)

fun YamlEditor.fail(code: string, message: string, offset: int = 0): void

Records the first edit error at the corresponding source offset.

YamlEditor.ready (extension fun)

fun YamlEditor.ready(): bool

Returns whether the current document is valid and no edit error has been recorded.

YamlDocument.entryIndex (extension fun)

fun YamlDocument.entryIndex(id: int, part: YamlPathPart): int

Returns the matching sequence or mapping entry index, or -1 if the path part cannot match.

YamlEditor.resolve (extension fun)

fun YamlEditor.resolve(path: array<YamlPathPart>, count: int): int

The final alias occurrence can be replaced/removed locally. Traversal through one requires materialize first, so edits never silently fan out via anchors.

yamlLineStart (fun)

fun yamlLineStart(source: string, offset: int): int

Returns the starting byte offset of the line containing the supplied offset.

yamlIndentPrefix (fun)

fun yamlIndentPrefix(source: string, offset: int): bool

Returns whether only spaces precede the offset on its physical line.

yamlLineEnd (fun)

fun yamlLineEnd(source: string, offset: int): int

Returns the next line break offset or the end of the source.

yamlLineNext (fun)

fun yamlLineNext(source: string, offset: int): int

Returns the byte offset just beyond the current line ending.

yamlSourceNewline (fun)

fun yamlSourceNewline(source: string): string

Returns the source's first newline spelling, defaulting to LF.

yamlSpaces (fun)

fun yamlSpaces(count: int): string

Returns a string containing the requested number of spaces.

yamlLeadingIndent (fun)

fun yamlLeadingIndent(source: string, offset: int): int

Returns the count of leading spaces on the line at the offset.

YamlDocument.protectedAnchor (extension fun)

fun YamlDocument.protectedAnchor(id: int): bool

Returns whether the node contains an anchor still referenced by an alias.

YamlEditor.patch (extension fun)

fun YamlEditor.patch(begin: int, end: int, text: string): bool

Replaces a byte span, validates the resulting YAML and returns false if the bounds, limits or syntax are invalid.

yamlEditEmit (fun)

fun yamlEditEmit(value: Yaml, limits: YamlLimits): YamlEmitResult

Returns an inline-compatible flow encoding or the emitter's error.

yamlSingleQuote (fun)

fun yamlSingleQuote(text: string): string

Returns a single-quoted scalar with internal apostrophes doubled.

yamlSingleLinePrintable (fun)

fun yamlSingleLinePrintable(text: string): bool

Returns whether the text can be preserved as a single printable line.

yamlEditPlain (fun)

fun yamlEditPlain(text: string, flow: bool): bool

A conservative subset of plain style, safe in both block and flow positions.

YamlDocument.inFlow (extension fun)

fun YamlDocument.inFlow(id: int): bool

Returns whether the node is within a flow collection.

YamlDocument.blockText (extension fun)

fun YamlDocument.blockText(id: int, text: string): string

Returns a block scalar representation in the existing node's style or an empty string when that style cannot represent the value.

YamlDocument.inlineIndent (extension fun)

fun YamlDocument.inlineIndent(id: int): string

Returns the spacing prefix needed when replacing the specified inline node.

YamlDocument.replacement (extension fun)

fun YamlDocument.replacement(id: int, value: Yaml, encoded: string): string

Returns replacement text adapted to the node's original scalar or collection style.

YamlEquality (class)

class YamlEquality(val limits: YamlLimits, var nodes: int, var work: int)

Equality has its own bounded walk, independent of output size. A legal alias graph can expand beyond maximumBytes, yet setting that same value is a no-op.

YamlEquality.same (extension fun)

fun YamlEquality.same(left: Yaml, right: Yaml, depth: int): bool

Compares two YAML values within the depth, node and work limits and returns false if the comparison exceeds a budget.

yamlSame (fun)

fun yamlSame(left: Yaml, right: Yaml, limits: YamlLimits): bool

Returns structural YAML equality within the supplied comparison budget.

YamlEditor.replace (extension fun)

fun YamlEditor.replace(id: int, value: Yaml): bool

Replaces a node while preserving its presentation where possible and returns false if the edit cannot be applied safely.

YamlEditor.verify (extension fun)

fun YamlEditor.verify(path: array<YamlPathPart>, value: Yaml): bool

Returns whether the path resolves to the requested value, recording an edit error if it differs.

YamlDocument.newKeyText (extension fun)

fun YamlDocument.newKeyText(parent: int, key: Yaml, encoded: string): string

Returns the new mapping key in a compatible existing style, using the supplied encoding when that style cannot be reused.

YamlEditor.insertInto (extension fun)

fun YamlEditor.insertInto(parent: int, part: YamlPathPart, value: Yaml): bool

Inserts a new member in the specified collection and returns false for an invalid insertion or protected alias.

YamlEditor.guardAncestors (extension fun)

fun YamlEditor.guardAncestors(path: array<YamlPathPart>, count: int): bool

Checks the path for anchor definitions with live aliases and returns false when an ancestor cannot be safely edited.

YamlEditor.set (extension fun)

fun YamlEditor.set(path: array<YamlPathPart>, value: Yaml): bool

Sets value at path, replacing the root for an empty path or adding a missing mapping key. Returns false if the path cannot be resolved, a missing sequence index is requested, or the edit is invalid.

YamlEditor.insert (extension fun)

fun YamlEditor.insert(path: array<YamlPathPart>, value: Yaml): bool

Inserts value at the mapping key or sequence index named by path. Returns false for an empty path, an invalid parent or insertion, or a failed edit.

YamlEditor.remove (extension fun)

fun YamlEditor.remove(path: array<YamlPathPart>): bool

Removes the member or element at path. Returns false for the root, a missing or invalid path, or a protected edit such as removal of an anchor with live aliases.

YamlEditor.materialize (extension fun)

fun YamlEditor.materialize(path: array<YamlPathPart>): bool

Replaces an alias occurrence with its expanded value and returns false if the path, anchor or edit is invalid.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.