encode

package
v0.0.0-...-70fd0a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package encode implements Go types encoding into YAML as part of yamly engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTBuilder

type ASTBuilder struct {
	// contains filtered or unexported fields
}

ASTBuilder implements yamly.TreeBuilder

func NewASTBuilder

func NewASTBuilder(opts ...ASTBuilderOption) *ASTBuilder

func (*ASTBuilder) EndMapping

func (b *ASTBuilder) EndMapping()

func (*ASTBuilder) EndSequence

func (b *ASTBuilder) EndSequence()

func (*ASTBuilder) InsertBoolean

func (b *ASTBuilder) InsertBoolean(val bool)

func (*ASTBuilder) InsertFloat

func (b *ASTBuilder) InsertFloat(val float64)

func (*ASTBuilder) InsertInteger

func (b *ASTBuilder) InsertInteger(val int64)

func (*ASTBuilder) InsertNull

func (b *ASTBuilder) InsertNull()

func (*ASTBuilder) InsertRaw

func (b *ASTBuilder) InsertRaw(data []byte, err error)

func (*ASTBuilder) InsertRawText

func (b *ASTBuilder) InsertRawText(text []byte, err error)

func (*ASTBuilder) InsertString

func (b *ASTBuilder) InsertString(val string)

func (*ASTBuilder) InsertTimestamp

func (b *ASTBuilder) InsertTimestamp(val time.Time)

func (*ASTBuilder) InsertUnsigned

func (b *ASTBuilder) InsertUnsigned(val uint64)

func (*ASTBuilder) Result

func (b *ASTBuilder) Result() (ast.Node, error)

func (*ASTBuilder) StartMapping

func (b *ASTBuilder) StartMapping()

func (*ASTBuilder) StartSequence

func (b *ASTBuilder) StartSequence()

type ASTBuilderOption

type ASTBuilderOption func(*builderOpts)

ASTBuilderOption allows to modify ASTBuilder behavior

func WithUnquotedOneLineStrings

func WithUnquotedOneLineStrings() ASTBuilderOption

WithUnquotedOneLineStrings make ASTBuilder create nodes for one-line strings with absent quoting style (instead of default double quoting style)

type ASTWriter

type ASTWriter struct {
	// contains filtered or unexported fields
}

ASTWriter implements yamly.TreeWriter

func NewASTWriter

func NewASTWriter(opts ...WriteOption) *ASTWriter

func (*ASTWriter) VisitAliasNode

func (w *ASTWriter) VisitAliasNode(n *ast.AliasNode)

func (*ASTWriter) VisitAnchorNode

func (w *ASTWriter) VisitAnchorNode(n *ast.AnchorNode)

func (*ASTWriter) VisitContentNode

func (w *ASTWriter) VisitContentNode(n *ast.ContentNode)

func (*ASTWriter) VisitMappingEntryNode

func (w *ASTWriter) VisitMappingEntryNode(n *ast.MappingEntryNode)

func (*ASTWriter) VisitMappingNode

func (w *ASTWriter) VisitMappingNode(n *ast.MappingNode)

func (*ASTWriter) VisitNullNode

func (w *ASTWriter) VisitNullNode(n *ast.NullNode)

func (*ASTWriter) VisitPropertiesNode

func (w *ASTWriter) VisitPropertiesNode(n *ast.PropertiesNode)

func (*ASTWriter) VisitSequenceNode

func (w *ASTWriter) VisitSequenceNode(n *ast.SequenceNode)

func (*ASTWriter) VisitStreamNode

func (w *ASTWriter) VisitStreamNode(n *ast.StreamNode)

func (*ASTWriter) VisitTagNode

func (w *ASTWriter) VisitTagNode(n *ast.TagNode)

func (*ASTWriter) VisitTextNode

func (w *ASTWriter) VisitTextNode(n *ast.TextNode)

func (*ASTWriter) WriteBytes

func (w *ASTWriter) WriteBytes(ast ast.Node) ([]byte, error)

func (*ASTWriter) WriteString

func (w *ASTWriter) WriteString(ast ast.Node) (string, error)

func (*ASTWriter) WriteTo

func (w *ASTWriter) WriteTo(dst io.Writer, ast ast.Node) error

type AnchorsKeeper

type AnchorsKeeper interface {
	// StoreAnchor marks anchor name as met.
	StoreAnchor(anchorName string)

	// BindToLatestAnchor binds given node to the most recent stored anchor name.
	BindToLatestAnchor(n ast.Node)

	// DereferenceAlias returns node associated with given alias (anchor name).
	// If alias was not stored or node was not bound to it, returns an error
	DereferenceAlias(alias string) (ast.Node, error)
}

AnchorsKeeper defines methods to bind anchors to aliases and dereference aliases.

type WriteOption

type WriteOption func(*writeOptions)

WriteOption allows to modify ASTWriter behavior

func WithAnchorsKeeper

func WithAnchorsKeeper(ak AnchorsKeeper) WriteOption

WithAnchorsKeeper makes ASTWriter use provided AnchorsKeeper and dereference unknown aliases (i.e. aliases for anchors which are not contained in written AST)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL