lit

package
v0.0.0-...-9cd5b15 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: BSD-2-Clause Imports: 17 Imported by: 17

README

xelf/lit

Xelf needs a literal representation to parse into and work with.

Xelf has the Lit type representing a literal expression that contains the resolved type, the source information and an abstract value. The omitted value source location and the independent value type simplify the implementation and allow lazy conversions.

We use three interfaces that describe sets of value implementations:

  • Val for simple values
  • Mut for mutable values
  • Prx for mutable proxy values

We have three ways to parse an Ast to a value implementations:

  • ParseVal returns generic values, using immutable values for primitive literals
  • ParseMut returns generic mutable values
  • Mut.Parse parses into a mutable value provided by the user. The parse method can be optimize and allows user defined values.

There are other some helper methods:

  • Read, ReadInto to read from a named reader
  • Parse, ParseInto to read from a string

We have another set of interfaces to cover capabilities:

  • Idxr for indexable values like list or obj
  • Appender for appendable values like idxr, list
  • Keyr for keyable values like dict or obj
  • Wrapper for value wrappers that would hide the other interfaces

Reg is a registry interface for a reflection and proxy cache. Caching is required, not only to improve performance, but to support self referential types. PrxReg is the notable implementation that can be shared as process global cache. The interface provides:

  • Reflect(reflect.Typ) (typ.Type, error)
  • ProxyValue(reflect.Value) (Mut, error)

MutReg is a second optional registry for named and user-provided value implementations. It provides a custom Zero method as api, that can be used instead of the generic package function.

Regs is a simple struct that embeds both registries, to make it easier to pass around.

The registry must be used to creating new proxy values. Created proxies keep a reference to their origin registry to create proxies for contained values. Proxy values may point to a pointer and represent an optional type directly.

The primary value implementations can be used as value Bool or as mutable *Bool, because working exclusively with pointer types is cumbersome for simple values: (*lit.Bool)(cor.Bool(true)). Both options however only represent a value with the type bool, we provide an OptMut wrapper with a null flag of type <bool?>. The Null type has only a value implementation.

Other implementations are always mutable variants, because we would gain nothing from using a value type implicitly addressed and wrapped in an interface and instead would increase code complexity.

The generic Map implementation can explicitly be used instead of dicts by users provided types to make working with dicts easier. Dict is a useful default because it preserves order which may be important for some internal conversions and program resolution.

Another special implementation is the AnyPrx that proxies to interface values with resolved type alternatives and manage a literal that represents that interface value.

The MapPrx uses a neat trick to provide mutable element values even though go map elements are not addressable without using a pointer element type.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIdxNotFound = fmt.Errorf("idx not found")
	ErrKeyNotFound = fmt.Errorf("key not found")
	ErrAssign      = typ.ErrAssign
	ErrIdxBounds   = typ.ErrIdxBounds
)
View Source
var BreakIter = fmt.Errorf("break iter")

BreakIter is a special error value that can be returned from iterators. It indicates that the iteration should be stopped even though no actual failure occurred.

View Source
var SkipCont = errors.New("skip contained values")

SkipCont can be returned from EditFunc to skip over the contained values.

Functions

func AnyWrap

func AnyWrap(t typ.Type) *typ.Wrap

func AssignPath

func AssignPath(mut Mut, path cor.Path, val Val) (err error)

AssignPath sets an element of root at path to val or returns an error. It fails on missing intermediate container values.

func Compare

func Compare(x, y Val) (int8, error)

func Conv

func Conv(reg Reg, t reflect.Type, val Val) (reflect.Value, error)

Conv converts val to type t and returns a reflect value or an error.

func Equal

func Equal(x, y Val) bool

Equal returns whether two literal values are structurally equal. Value types and implementations are not compared.

func ParseInto

func ParseInto(str string, mut Mut) error

ParseInto parses str into mut or returns an error.

func PrintZero

func PrintZero(p *bfr.P, t typ.Type) error

func ReadInto

func ReadInto(r io.Reader, name string, mut Mut) error

ReadInto parses named reader r into mut or returns an error.

func UpdateRegs

func UpdateRegs(rs, o *Regs)

Update updates the registry and reflect cache with entries from o.

func Wrap

func Wrap(m Mut, t typ.Type) *typ.Wrap

Types

type Any

type Any struct{ Val }

func (*Any) As

func (w *Any) As(t typ.Type) (Val, error)

func (*Any) Assign

func (w *Any) Assign(v Val) error

func (*Any) MarshalJSON

func (w *Any) MarshalJSON() ([]byte, error)

func (*Any) Mut

func (w *Any) Mut() Mut

func (*Any) New

func (w *Any) New() Mut

func (*Any) Nil

func (w *Any) Nil() bool

func (*Any) Parse

func (w *Any) Parse(a ast.Ast) (err error)

func (*Any) Print

func (w *Any) Print(p *bfr.P) error

func (*Any) Ptr

func (w *Any) Ptr() interface{}

func (*Any) String

func (w *Any) String() string

func (*Any) Type

func (w *Any) Type() typ.Type

func (*Any) UnmarshalJSON

func (w *Any) UnmarshalJSON(b []byte) error

func (*Any) Unwrap

func (w *Any) Unwrap() Val

func (*Any) Value

func (w *Any) Value() Val

func (*Any) Zero

func (w *Any) Zero() bool

type AnyPrx

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

AnyPrx proxies to an interface value and manage a literal that represents that interface value.

func (*AnyPrx) As

func (x *AnyPrx) As(t typ.Type) (Val, error)

func (*AnyPrx) Assign

func (x *AnyPrx) Assign(v Val) (err error)

func (*AnyPrx) MarshalJSON

func (x *AnyPrx) MarshalJSON() ([]byte, error)

func (*AnyPrx) Mut

func (x *AnyPrx) Mut() Mut

func (*AnyPrx) New

func (x *AnyPrx) New() Mut

func (*AnyPrx) NewWith

func (x *AnyPrx) NewWith(v reflect.Value) Mut

func (*AnyPrx) Nil

func (x *AnyPrx) Nil() bool

func (*AnyPrx) Parse

func (x *AnyPrx) Parse(a ast.Ast) (err error)

func (*AnyPrx) Print

func (x *AnyPrx) Print(b *bfr.P) error

func (*AnyPrx) Ptr

func (x *AnyPrx) Ptr() interface{}

func (*AnyPrx) Reflect

func (x *AnyPrx) Reflect() reflect.Value

func (*AnyPrx) String

func (x *AnyPrx) String() string

func (*AnyPrx) Type

func (x *AnyPrx) Type() typ.Type

func (*AnyPrx) UnmarshalJSON

func (x *AnyPrx) UnmarshalJSON(b []byte) error

func (*AnyPrx) Unwrap

func (x *AnyPrx) Unwrap() Val

func (*AnyPrx) Value

func (x *AnyPrx) Value() Val

func (*AnyPrx) Zero

func (x *AnyPrx) Zero() bool

type Appender

type Appender interface {
	Idxr
	Append(...Val) error
}

Appender is the interface for indexer values supporting append.

type Bool

type Bool bool

func ToBool

func ToBool(v Val) (b Bool, err error)

func (Bool) As

func (v Bool) As(t typ.Type) (Val, error)

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

func (Bool) Mut

func (v Bool) Mut() Mut

func (Bool) Nil

func (v Bool) Nil() bool

func (Bool) Print

func (v Bool) Print(p *bfr.P) error

func (Bool) String

func (v Bool) String() string

func (Bool) Type

func (Bool) Type() typ.Type

func (Bool) Value

func (v Bool) Value() Val

func (Bool) Zero

func (v Bool) Zero() bool

type BoolMut

type BoolMut bool

func (*BoolMut) As

func (v *BoolMut) As(t typ.Type) (Val, error)

func (*BoolMut) Assign

func (v *BoolMut) Assign(p Val) error

func (*BoolMut) MarshalJSON

func (v *BoolMut) MarshalJSON() ([]byte, error)

func (*BoolMut) Mut

func (v *BoolMut) Mut() Mut

func (*BoolMut) New

func (*BoolMut) New() Mut

func (*BoolMut) Nil

func (v *BoolMut) Nil() bool

func (*BoolMut) Parse

func (v *BoolMut) Parse(a ast.Ast) error

func (*BoolMut) Print

func (v *BoolMut) Print(p *bfr.P) error

func (*BoolMut) Ptr

func (v *BoolMut) Ptr() interface{}

func (*BoolMut) String

func (v *BoolMut) String() string

func (*BoolMut) Type

func (*BoolMut) Type() typ.Type

func (*BoolMut) Value

func (v *BoolMut) Value() Val

func (*BoolMut) Zero

func (v *BoolMut) Zero() bool

type Char

type Char string

func (Char) As

func (s Char) As(t typ.Type) (Val, error)

func (Char) Len

func (s Char) Len() int

func (Char) MarshalJSON

func (s Char) MarshalJSON() ([]byte, error)

func (Char) Mut

func (s Char) Mut() Mut

func (Char) Nil

func (s Char) Nil() bool

func (Char) Print

func (s Char) Print(p *bfr.P) error

func (Char) String

func (s Char) String() string

func (Char) Type

func (Char) Type() typ.Type

func (Char) Value

func (s Char) Value() Val

func (Char) Zero

func (s Char) Zero() bool

type CharMut

type CharMut string

func (*CharMut) As

func (s *CharMut) As(t typ.Type) (Val, error)

func (*CharMut) Assign

func (s *CharMut) Assign(p Val) error

func (*CharMut) Len

func (s *CharMut) Len() int

func (*CharMut) MarshalJSON

func (s *CharMut) MarshalJSON() ([]byte, error)

func (*CharMut) Mut

func (s *CharMut) Mut() Mut

func (*CharMut) New

func (*CharMut) New() Mut

func (*CharMut) Nil

func (s *CharMut) Nil() bool

func (*CharMut) Parse

func (s *CharMut) Parse(a ast.Ast) error

func (*CharMut) Print

func (s *CharMut) Print(p *bfr.P) error

func (*CharMut) Ptr

func (s *CharMut) Ptr() interface{}

func (*CharMut) String

func (s *CharMut) String() string

func (*CharMut) Type

func (*CharMut) Type() typ.Type

func (*CharMut) Value

func (s *CharMut) Value() Val

func (*CharMut) Zero

func (s *CharMut) Zero() bool

type Delta

type Delta Keyed

Delta is a list of path edits that describe a transformation from one value to another. Each element has an edit key and value. The key describes the edit path and the kind of edit. Special chars are path separators and dollar './$' in the whole path '+*-' in the suffix. If the key contains a dollar sign as segment, the edit value is a list of segment values before the any edit data. The minus suffix means we want to delete a dict key. One star or plus suffix means we have either a nested delta if the edit data is a keyr or list ops if the edit data is a list. If the first star or plus is followed by a star again, then it is a delta ops edit data.

func Diff

func Diff(a, b Val) (Delta, error)

Diff returns the delta between values a and b or an error. The delta applied to a results in b. The simplest and correct answer is always to return b. We however do make some effort to find a simpler set of changes, but do not guarantee to return the shortest edit path.

func (Delta) String

func (d Delta) String() string

type Dict

type Dict struct {
	Typ typ.Type
	Keyed
}

func NewDict

func NewDict(el typ.Type, ks ...KeyVal) *Dict

func (*Dict) As

func (d *Dict) As(t typ.Type) (Val, error)

func (*Dict) Key

func (d *Dict) Key(k string) (Val, error)

func (*Dict) Mut

func (d *Dict) Mut() Mut

func (*Dict) New

func (d *Dict) New() Mut

func (*Dict) Nil

func (d *Dict) Nil() bool

func (*Dict) Ptr

func (d *Dict) Ptr() interface{}

func (*Dict) Type

func (d *Dict) Type() typ.Type

func (*Dict) Value

func (d *Dict) Value() Val

type EditFunc

type EditFunc func(v Val) (Val, error)

EditFunc edits and returns v, a new value, SkipCont, BreakIter or any other error.

type Idxr

type Idxr interface {
	Mut
	Len() int
	// Idx returns the literal of the element at idx or an error.
	Idx(idx int) (Val, error)
	// SetIdx sets the element value at idx to v and returns the indexer or an error.
	SetIdx(idx int, v Val) error
	// IterIdx iterates over elements, calling iter with the elements index and value.
	// If iter returns an error the iteration is aborted.
	IterIdx(iter func(int, Val) error) error
}

Idxr is the interface for indexer values.

type Int

type Int int64

func ToInt

func ToInt(v Val) (n Int, err error)

func (Int) As

func (i Int) As(t typ.Type) (Val, error)

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

func (Int) Mut

func (i Int) Mut() Mut

func (Int) Nil

func (i Int) Nil() bool

func (Int) Print

func (i Int) Print(p *bfr.P) error

func (Int) String

func (i Int) String() string

func (Int) Type

func (Int) Type() typ.Type

func (Int) Value

func (i Int) Value() Val

func (Int) Zero

func (i Int) Zero() bool

type IntMut

type IntMut int64

func (*IntMut) As

func (i *IntMut) As(t typ.Type) (Val, error)

func (*IntMut) Assign

func (i *IntMut) Assign(p Val) error

func (*IntMut) MarshalJSON

func (i *IntMut) MarshalJSON() ([]byte, error)

func (*IntMut) Mut

func (i *IntMut) Mut() Mut

func (*IntMut) New

func (*IntMut) New() Mut

func (*IntMut) Nil

func (i *IntMut) Nil() bool

func (*IntMut) Parse

func (i *IntMut) Parse(a ast.Ast) error

func (*IntMut) Print

func (i *IntMut) Print(p *bfr.P) error

func (*IntMut) Ptr

func (i *IntMut) Ptr() interface{}

func (*IntMut) String

func (i *IntMut) String() string

func (*IntMut) Type

func (*IntMut) Type() typ.Type

func (*IntMut) Value

func (i *IntMut) Value() Val

func (*IntMut) Zero

func (i *IntMut) Zero() bool

type IntPrx

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

func (*IntPrx) As

func (x *IntPrx) As(t typ.Type) (Val, error)

func (*IntPrx) Assign

func (x *IntPrx) Assign(v Val) error

func (*IntPrx) MarshalJSON

func (x *IntPrx) MarshalJSON() ([]byte, error)

func (*IntPrx) Mut

func (x *IntPrx) Mut() Mut

func (*IntPrx) New

func (x *IntPrx) New() Mut

func (*IntPrx) NewWith

func (x *IntPrx) NewWith(v reflect.Value) Mut

func (*IntPrx) Nil

func (x *IntPrx) Nil() bool

func (*IntPrx) Parse

func (x *IntPrx) Parse(a ast.Ast) error

func (*IntPrx) Print

func (x *IntPrx) Print(p *bfr.P) error

func (*IntPrx) Ptr

func (x *IntPrx) Ptr() interface{}

func (*IntPrx) Reflect

func (x *IntPrx) Reflect() reflect.Value

func (*IntPrx) String

func (x *IntPrx) String() string

func (*IntPrx) Type

func (x *IntPrx) Type() typ.Type

func (*IntPrx) UnmarshalJSON

func (x *IntPrx) UnmarshalJSON(b []byte) error

func (*IntPrx) Value

func (x *IntPrx) Value() Val

func (*IntPrx) Zero

func (x *IntPrx) Zero() bool

type KeyVal

type KeyVal struct {
	Key string
	Val
}

type Keyed

type Keyed []KeyVal

func (*Keyed) As

func (d *Keyed) As(t typ.Type) (Val, error)

func (*Keyed) Assign

func (d *Keyed) Assign(p Val) error

func (*Keyed) Idx

func (d *Keyed) Idx(i int) (Val, error)

func (*Keyed) IterIdx

func (d *Keyed) IterIdx(it func(int, Val) error) error

func (*Keyed) IterKey

func (d *Keyed) IterKey(it func(string, Val) error) error

func (*Keyed) Key

func (d *Keyed) Key(k string) (Val, error)

func (*Keyed) Keys

func (d *Keyed) Keys() []string

func (*Keyed) Len

func (d *Keyed) Len() int

func (Keyed) MarshalJSON

func (d Keyed) MarshalJSON() ([]byte, error)

func (*Keyed) Mut

func (d *Keyed) Mut() Mut

func (*Keyed) New

func (d *Keyed) New() Mut

func (*Keyed) Nil

func (d *Keyed) Nil() bool

func (*Keyed) Parse

func (d *Keyed) Parse(a ast.Ast) error

func (Keyed) Print

func (d Keyed) Print(p *bfr.P) (err error)

func (*Keyed) Ptr

func (d *Keyed) Ptr() interface{}

func (*Keyed) SetIdx

func (d *Keyed) SetIdx(i int, el Val) error

func (*Keyed) SetKey

func (d *Keyed) SetKey(k string, el Val) error

func (Keyed) String

func (d Keyed) String() string

func (Keyed) Type

func (d Keyed) Type() typ.Type

func (*Keyed) UnmarshalJSON

func (d *Keyed) UnmarshalJSON(b []byte) error

func (*Keyed) Value

func (d *Keyed) Value() Val

func (*Keyed) Zero

func (d *Keyed) Zero() bool

type Keyr

type Keyr interface {
	Mut
	Len() int
	// Keys returns a string slice of all keys.
	Keys() []string
	// Key returns the value of the element with key or an error.
	Key(key string) (Val, error)
	// SetKey sets the elements value with key to v and returns the keyer or an error.
	SetKey(key string, v Val) error
	// IterKey iterates over elements, calling iter with the elements key and value.
	// If iter returns an error the iteration is aborted.
	IterKey(iter func(string, Val) error) error
}

Keyr is the interface for keyer values.

type Lenr

type Lenr interface {
	Val
	Len() int
}

Lenr is the common interface of value that have a length.

type List

type List struct {
	Typ typ.Type
	Vals
}

func NewList

func NewList(el typ.Type, vs ...Val) *List

func (*List) As

func (l *List) As(t typ.Type) (Val, error)

func (*List) Mut

func (l *List) Mut() Mut

func (*List) New

func (l *List) New() Mut

func (*List) Nil

func (l *List) Nil() bool

func (*List) Ptr

func (l *List) Ptr() interface{}

func (*List) Type

func (l *List) Type() typ.Type

func (*List) Value

func (l *List) Value() Val

type ListOp

type ListOp struct {
	N int
	V Vals
}

ListOp represents a list operation used for list diff edits. N > 0 means retain N elements and N < 0 means delete -N elements and N == 0 means insert V.

type ListOps

type ListOps []ListOp

func (ListOps) Len

func (ops ListOps) Len() int

func (ListOps) Op

func (ops ListOps) Op(i int) (int, Val)

func (ListOps) Swap

func (ops ListOps) Swap(i, j int)

type ListPrx

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

func (*ListPrx) Append

func (x *ListPrx) Append(vs ...Val) (err error)

func (*ListPrx) As

func (x *ListPrx) As(t typ.Type) (Val, error)

func (*ListPrx) Assign

func (x *ListPrx) Assign(v Val) (err error)

func (*ListPrx) Idx

func (x *ListPrx) Idx(i int) (res Val, err error)

func (*ListPrx) IterIdx

func (x *ListPrx) IterIdx(it func(int, Val) error) error

func (*ListPrx) Len

func (x *ListPrx) Len() int

func (*ListPrx) MarshalJSON

func (x *ListPrx) MarshalJSON() ([]byte, error)

func (*ListPrx) Mut

func (x *ListPrx) Mut() Mut

func (*ListPrx) New

func (x *ListPrx) New() Mut

func (*ListPrx) NewWith

func (x *ListPrx) NewWith(v reflect.Value) Mut

func (*ListPrx) Nil

func (x *ListPrx) Nil() bool

func (*ListPrx) Parse

func (x *ListPrx) Parse(a ast.Ast) error

func (*ListPrx) Print

func (x *ListPrx) Print(p *bfr.P) error

func (*ListPrx) Ptr

func (x *ListPrx) Ptr() interface{}

func (*ListPrx) Reflect

func (x *ListPrx) Reflect() reflect.Value

func (*ListPrx) SetIdx

func (x *ListPrx) SetIdx(i int, v Val) (err error)

func (*ListPrx) String

func (x *ListPrx) String() string

func (*ListPrx) Type

func (x *ListPrx) Type() typ.Type

func (*ListPrx) UnmarshalJSON

func (x *ListPrx) UnmarshalJSON(b []byte) error

func (*ListPrx) Value

func (x *ListPrx) Value() Val

func (*ListPrx) Zero

func (x *ListPrx) Zero() bool

type Map

type Map struct {
	Typ typ.Type
	M   map[string]Val
}

func NewMap

func NewMap(el typ.Type) *Map

func (*Map) As

func (h *Map) As(t typ.Type) (Val, error)

func (*Map) Assign

func (h *Map) Assign(p Val) error

func (*Map) IterKey

func (h *Map) IterKey(it func(string, Val) error) error

func (*Map) Key

func (h *Map) Key(k string) (Val, error)

func (*Map) Keys

func (h *Map) Keys() []string

func (*Map) Len

func (h *Map) Len() int

func (*Map) MarshalJSON

func (h *Map) MarshalJSON() ([]byte, error)

func (*Map) Mut

func (h *Map) Mut() Mut

func (*Map) New

func (h *Map) New() Mut

func (*Map) Nil

func (h *Map) Nil() bool

func (*Map) Parse

func (h *Map) Parse(a ast.Ast) error

func (*Map) Print

func (h *Map) Print(p *bfr.P) (err error)

func (*Map) Ptr

func (h *Map) Ptr() interface{}

func (*Map) SetKey

func (h *Map) SetKey(k string, el Val) error

func (*Map) String

func (h *Map) String() string

func (*Map) Type

func (h *Map) Type() typ.Type

func (*Map) UnmarshalJSON

func (h *Map) UnmarshalJSON(b []byte) error

func (*Map) Value

func (h *Map) Value() Val

func (*Map) Zero

func (h *Map) Zero() bool

type MapPrx

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

func (*MapPrx) As

func (x *MapPrx) As(t typ.Type) (Val, error)

func (*MapPrx) Assign

func (x *MapPrx) Assign(v Val) error

func (*MapPrx) IterKey

func (x *MapPrx) IterKey(it func(string, Val) error) error

func (*MapPrx) Key

func (x *MapPrx) Key(k string) (Val, error)

func (*MapPrx) Keys

func (x *MapPrx) Keys() []string

func (*MapPrx) Len

func (x *MapPrx) Len() int

func (*MapPrx) MarshalJSON

func (x *MapPrx) MarshalJSON() ([]byte, error)

func (*MapPrx) Mut

func (x *MapPrx) Mut() Mut

func (*MapPrx) New

func (x *MapPrx) New() Mut

func (*MapPrx) NewWith

func (x *MapPrx) NewWith(v reflect.Value) Mut

func (*MapPrx) Nil

func (x *MapPrx) Nil() bool

func (*MapPrx) Parse

func (x *MapPrx) Parse(a ast.Ast) error

func (*MapPrx) Print

func (x *MapPrx) Print(p *bfr.P) error

func (*MapPrx) Ptr

func (x *MapPrx) Ptr() interface{}

func (*MapPrx) Reflect

func (x *MapPrx) Reflect() reflect.Value

func (*MapPrx) SetKey

func (x *MapPrx) SetKey(k string, v Val) (err error)

func (*MapPrx) String

func (x *MapPrx) String() string

func (*MapPrx) Type

func (x *MapPrx) Type() typ.Type

func (*MapPrx) UnmarshalJSON

func (x *MapPrx) UnmarshalJSON(b []byte) error

func (*MapPrx) Value

func (x *MapPrx) Value() Val

func (*MapPrx) Zero

func (x *MapPrx) Zero() bool

type Mut

type Mut = typ.LitMut

Mut is the common interface of all mutable literal values. Mutable values should have an UnmarshalJSON method unless the base type is natively supported.

func Apply

func Apply(mut Mut, d Delta) (Mut, error)

Apply applies edits d to mutable a or returns an error.

func CreatePath

func CreatePath(mut Mut, path cor.Path, val Val) (_ Mut, err error)

CreatePath creates an element of root at path to val or returns an error. It resizes and creates missing intermediate container values using the registry.

func MustProxy

func MustProxy(reg Reg, ptr interface{}) Mut

MustProxy returns a proxy value for ptr or panics.

func ParseMut

func ParseMut(a ast.Ast) (Mut, error)

ParseMut parses a as mutable value and returns it or an error. If the null symbol is parsed nil mutable is returned.

func Proxy

func Proxy(reg Reg, ptr interface{}) (Mut, error)

Proxy returns a proxy value for ptr or an error.

func Zero

func Zero(t typ.Type) Mut

Zero returns a mutable assignable to a value of type t or null.

func ZeroWrap

func ZeroWrap(t typ.Type) Mut

type MutReg

type MutReg map[string]Mut

MutReg stores a map of custom mutable implementations by reference.

func (*MutReg) AddFrom

func (mr *MutReg) AddFrom(o MutReg)

AddFrom updates the registry and reflect cache with entries from o.

func (MutReg) Each

func (mr MutReg) Each(f func(string, Mut) error) error

func (MutReg) SetRef

func (mr MutReg) SetRef(ref string, mut Mut) error

SetRef registers type and optionally a mutable implementation for ref.

func (MutReg) Zero

func (mr MutReg) Zero(t typ.Type) Mut

Zero returns a mutable zero value for t. It provides registered mutables for name types and falls back to the default zero function.

func (MutReg) ZeroWrap

func (mr MutReg) ZeroWrap(t typ.Type) Mut

type Null

type Null = typ.Null

type Num

type Num float64

func (Num) As

func (i Num) As(t typ.Type) (Val, error)

func (Num) MarshalJSON

func (i Num) MarshalJSON() ([]byte, error)

func (Num) Mut

func (i Num) Mut() Mut

func (Num) Nil

func (i Num) Nil() bool

func (Num) Print

func (i Num) Print(p *bfr.P) error

func (Num) String

func (i Num) String() string

func (Num) Type

func (Num) Type() typ.Type

func (Num) Value

func (i Num) Value() Val

func (Num) Zero

func (i Num) Zero() bool

type NumMut

type NumMut float64

func (*NumMut) As

func (i *NumMut) As(t typ.Type) (Val, error)

func (*NumMut) Assign

func (i *NumMut) Assign(p Val) error

func (*NumMut) MarshalJSON

func (i *NumMut) MarshalJSON() ([]byte, error)

func (*NumMut) Mut

func (i *NumMut) Mut() Mut

func (*NumMut) New

func (*NumMut) New() Mut

func (*NumMut) Nil

func (i *NumMut) Nil() bool

func (*NumMut) Parse

func (i *NumMut) Parse(a ast.Ast) error

func (*NumMut) Print

func (i *NumMut) Print(p *bfr.P) error

func (*NumMut) Ptr

func (i *NumMut) Ptr() interface{}

func (*NumMut) String

func (i *NumMut) String() string

func (*NumMut) Type

func (*NumMut) Type() typ.Type

func (*NumMut) Value

func (i *NumMut) Value() Val

func (*NumMut) Zero

func (i *NumMut) Zero() bool

type Obj

type Obj struct {
	Typ  typ.Type
	Vals []Val
}

func MakeObj

func MakeObj(kvs []KeyVal) *Obj

func NewObj

func NewObj(t typ.Type) (*Obj, error)

func (*Obj) As

func (s *Obj) As(t typ.Type) (Val, error)

func (*Obj) Assign

func (s *Obj) Assign(p Val) error

func (*Obj) Idx

func (s *Obj) Idx(i int) (Val, error)

func (*Obj) IterIdx

func (s *Obj) IterIdx(it func(int, Val) error) error

func (*Obj) IterKey

func (s *Obj) IterKey(it func(string, Val) error) error

func (*Obj) Key

func (s *Obj) Key(k string) (Val, error)

func (*Obj) Keys

func (s *Obj) Keys() []string

func (*Obj) Len

func (s *Obj) Len() int

func (*Obj) MarshalJSON

func (s *Obj) MarshalJSON() ([]byte, error)

func (*Obj) Mut

func (s *Obj) Mut() Mut

func (*Obj) New

func (s *Obj) New() Mut

func (*Obj) Nil

func (s *Obj) Nil() bool

func (*Obj) Parse

func (s *Obj) Parse(a ast.Ast) error

func (*Obj) Print

func (s *Obj) Print(p *bfr.P) error

func (*Obj) Ptr

func (s *Obj) Ptr() interface{}

func (*Obj) SetIdx

func (s *Obj) SetIdx(idx int, el Val) error

func (*Obj) SetKey

func (s *Obj) SetKey(k string, el Val) error

func (*Obj) String

func (s *Obj) String() string

func (*Obj) Type

func (s *Obj) Type() typ.Type

func (*Obj) UnmarshalJSON

func (s *Obj) UnmarshalJSON(b []byte) error

func (*Obj) Value

func (s *Obj) Value() Val

func (*Obj) Zero

func (s *Obj) Zero() bool

type ObjPrx

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

func (*ObjPrx) As

func (x *ObjPrx) As(t typ.Type) (Val, error)

func (*ObjPrx) Assign

func (x *ObjPrx) Assign(v Val) (err error)

func (*ObjPrx) Idx

func (x *ObjPrx) Idx(i int) (Val, error)

func (*ObjPrx) IterIdx

func (x *ObjPrx) IterIdx(it func(int, Val) error) error

func (*ObjPrx) IterKey

func (x *ObjPrx) IterKey(it func(string, Val) error) error

func (*ObjPrx) Key

func (x *ObjPrx) Key(k string) (Val, error)

func (*ObjPrx) Keys

func (x *ObjPrx) Keys() []string

func (*ObjPrx) Len

func (x *ObjPrx) Len() int

func (*ObjPrx) MarshalJSON

func (x *ObjPrx) MarshalJSON() ([]byte, error)

func (*ObjPrx) Mut

func (x *ObjPrx) Mut() Mut

func (*ObjPrx) New

func (x *ObjPrx) New() Mut

func (*ObjPrx) NewWith

func (x *ObjPrx) NewWith(v reflect.Value) Mut

func (*ObjPrx) Nil

func (x *ObjPrx) Nil() bool

func (*ObjPrx) Parse

func (x *ObjPrx) Parse(a ast.Ast) error

func (*ObjPrx) Print

func (x *ObjPrx) Print(p *bfr.P) error

func (*ObjPrx) Ptr

func (x *ObjPrx) Ptr() interface{}

func (*ObjPrx) Reflect

func (x *ObjPrx) Reflect() reflect.Value

func (*ObjPrx) SetIdx

func (x *ObjPrx) SetIdx(i int, v Val) error

func (*ObjPrx) SetKey

func (x *ObjPrx) SetKey(k string, v Val) error

func (*ObjPrx) String

func (x *ObjPrx) String() string

func (*ObjPrx) Type

func (x *ObjPrx) Type() typ.Type

func (*ObjPrx) UnmarshalJSON

func (x *ObjPrx) UnmarshalJSON(b []byte) error

func (*ObjPrx) Value

func (x *ObjPrx) Value() Val

func (*ObjPrx) Zero

func (x *ObjPrx) Zero() bool

type Ops

type Ops interface {
	Len() int
	Op(int) (int, Val)
	Swap(int, int)
}

Ops is an abstract diff operation interface implemented by ListOps, StrOps and RawOps.

type OptPrx

type OptPrx struct {
	typ.LitMut

	Null bool
	// contains filtered or unexported fields
}

OptPrx convers a corner case using primary mutable values to null pointers. If we proxy (*bool)(nil) we provide a wrapped *Bool as mutable and keep nil for null values. This narrow usecase lets us asume we have always a value backing value and ptr.

func (*OptPrx) As

func (o *OptPrx) As(t typ.Type) (Val, error)

func (*OptPrx) Assign

func (o *OptPrx) Assign(v Val) error

func (*OptPrx) MarshalJSON

func (o *OptPrx) MarshalJSON() ([]byte, error)

func (*OptPrx) Mut

func (o *OptPrx) Mut() Mut

func (*OptPrx) New

func (o *OptPrx) New() Mut

func (*OptPrx) Nil

func (o *OptPrx) Nil() bool

func (*OptPrx) Parse

func (o *OptPrx) Parse(a ast.Ast) error

func (*OptPrx) Print

func (o *OptPrx) Print(p *bfr.P) error

func (*OptPrx) String

func (o *OptPrx) String() string

func (*OptPrx) Type

func (o *OptPrx) Type() typ.Type

func (*OptPrx) UnmarshalJSON

func (o *OptPrx) UnmarshalJSON(b []byte) error

func (*OptPrx) Unwrap

func (o *OptPrx) Unwrap() Val

func (*OptPrx) Value

func (o *OptPrx) Value() Val

func (*OptPrx) Zero

func (o *OptPrx) Zero() bool

type Prx

type Prx interface {
	Mut
	// Reflect returns the reflect value pointed to by this proxy.
	Reflect() reflect.Value
	// NewWith returns a new proxy instance with ptr as value.
	// This method is used internally for proxy caching and should only be called with pointer
	// values known to be compatible with this proxy implementation.
	NewWith(ptr reflect.Value) Mut
}

Prx is the interface for all reflection based mutable values.

type PrxReg

type PrxReg struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PrxReg holds process-shared reflection and proxy information

func (*PrxReg) AddFrom

func (pr *PrxReg) AddFrom(o *PrxReg)

AddFrom updates the cache with entries from o.

func (*PrxReg) ProxyValue

func (c *PrxReg) ProxyValue(ptr reflect.Value) (mut Mut, err error)

ProxyValue returns a proxy value for the reflect value ptr or an error.

func (*PrxReg) Reflect

func (pr *PrxReg) Reflect(t reflect.Type) (typ.Type, error)

Reflect returns the xelf type for the reflect type or an error.

func (*PrxReg) ReflectStruct

func (pr *PrxReg) ReflectStruct(t reflect.Type) (nfo typInfo, err error)

type Raw

type Raw []byte

func ToRaw

func ToRaw(v Val) (r Raw, err error)

func (Raw) As

func (r Raw) As(t typ.Type) (Val, error)

func (Raw) Len

func (r Raw) Len() int

func (Raw) MarshalJSON

func (r Raw) MarshalJSON() ([]byte, error)

func (Raw) Mut

func (r Raw) Mut() Mut

func (Raw) Nil

func (r Raw) Nil() bool

func (Raw) Print

func (r Raw) Print(p *bfr.P) error

func (Raw) String

func (r Raw) String() string

func (Raw) Type

func (Raw) Type() typ.Type

func (*Raw) UnmarshalJSON

func (r *Raw) UnmarshalJSON(b []byte) error

func (Raw) Value

func (r Raw) Value() Val

func (Raw) Zero

func (r Raw) Zero() bool

type RawMut

type RawMut []byte

func (*RawMut) As

func (r *RawMut) As(t typ.Type) (Val, error)

func (*RawMut) Assign

func (r *RawMut) Assign(p Val) error

func (*RawMut) Len

func (r *RawMut) Len() int

func (*RawMut) MarshalJSON

func (r *RawMut) MarshalJSON() ([]byte, error)

func (*RawMut) Mut

func (r *RawMut) Mut() Mut

func (*RawMut) New

func (*RawMut) New() Mut

func (*RawMut) Nil

func (r *RawMut) Nil() bool

func (*RawMut) Parse

func (r *RawMut) Parse(a ast.Ast) error

func (*RawMut) Print

func (r *RawMut) Print(p *bfr.P) error

func (*RawMut) Ptr

func (r *RawMut) Ptr() interface{}

func (*RawMut) String

func (r *RawMut) String() string

func (*RawMut) Type

func (*RawMut) Type() typ.Type

func (*RawMut) UnmarshalJSON

func (r *RawMut) UnmarshalJSON(b []byte) error

func (*RawMut) Value

func (r *RawMut) Value() Val

func (*RawMut) Zero

func (r *RawMut) Zero() bool

type RawOp

type RawOp struct {
	N int
	V Raw
}

RawOp represents a string operation used for raw diff edits. N > 0 means retain N bytes and N < 0 means delete -N bytes and N == 0 means insert V.

type RawOps

type RawOps []RawOp

func (RawOps) Len

func (ops RawOps) Len() int

func (RawOps) Op

func (ops RawOps) Op(i int) (int, Val)

func (RawOps) Swap

func (ops RawOps) Swap(i, j int)

type Real

type Real float64

func ToReal

func ToReal(v Val) (n Real, err error)

func (Real) As

func (r Real) As(t typ.Type) (Val, error)

func (Real) MarshalJSON

func (r Real) MarshalJSON() ([]byte, error)

func (Real) Mut

func (r Real) Mut() Mut

func (Real) Nil

func (r Real) Nil() bool

func (Real) Print

func (r Real) Print(p *bfr.P) error

func (Real) String

func (r Real) String() string

func (Real) Type

func (Real) Type() typ.Type

func (Real) Value

func (r Real) Value() Val

func (Real) Zero

func (r Real) Zero() bool

type RealMut

type RealMut float64

func (*RealMut) As

func (r *RealMut) As(t typ.Type) (Val, error)

func (*RealMut) Assign

func (r *RealMut) Assign(p Val) error

func (*RealMut) MarshalJSON

func (r *RealMut) MarshalJSON() ([]byte, error)

func (*RealMut) Mut

func (r *RealMut) Mut() Mut

func (*RealMut) New

func (*RealMut) New() Mut

func (*RealMut) Nil

func (r *RealMut) Nil() bool

func (*RealMut) Parse

func (r *RealMut) Parse(a ast.Ast) error

func (*RealMut) Print

func (r *RealMut) Print(p *bfr.P) error

func (*RealMut) Ptr

func (r *RealMut) Ptr() interface{}

func (*RealMut) String

func (r *RealMut) String() string

func (*RealMut) Type

func (*RealMut) Type() typ.Type

func (*RealMut) Value

func (r *RealMut) Value() Val

func (*RealMut) Zero

func (r *RealMut) Zero() bool

type RealPrx

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

func (*RealPrx) As

func (x *RealPrx) As(t typ.Type) (Val, error)

func (*RealPrx) Assign

func (x *RealPrx) Assign(v Val) error

func (*RealPrx) MarshalJSON

func (x *RealPrx) MarshalJSON() ([]byte, error)

func (*RealPrx) Mut

func (x *RealPrx) Mut() Mut

func (*RealPrx) New

func (x *RealPrx) New() Mut

func (*RealPrx) NewWith

func (x *RealPrx) NewWith(v reflect.Value) Mut

func (*RealPrx) Nil

func (x *RealPrx) Nil() bool

func (*RealPrx) Parse

func (x *RealPrx) Parse(a ast.Ast) error

func (*RealPrx) Print

func (x *RealPrx) Print(p *bfr.P) error

func (*RealPrx) Ptr

func (x *RealPrx) Ptr() interface{}

func (*RealPrx) Reflect

func (x *RealPrx) Reflect() reflect.Value

func (*RealPrx) String

func (x *RealPrx) String() string

func (*RealPrx) Type

func (x *RealPrx) Type() typ.Type

func (*RealPrx) UnmarshalJSON

func (x *RealPrx) UnmarshalJSON(b []byte) error

func (*RealPrx) Value

func (x *RealPrx) Value() Val

func (*RealPrx) Zero

func (x *RealPrx) Zero() bool

type Reg

type Reg interface {
	Reflect(rt reflect.Type) (typ.Type, error)
	ProxyValue(ptr reflect.Value) (Mut, error)
}

Reg is a registry interface for a reflection and proxy cache

type Regs

type Regs struct {
	*PrxReg
	MutReg
}

Regs embeds both PrxReg and MutReg to make it easier to provide and pass around. It implements the Reg interface by embedding PrxReg.

func DefaultRegs

func DefaultRegs(rs *Regs) *Regs

Default applies sensible defaults to rs and returns it.

func GlobalRegs

func GlobalRegs() *Regs

GlobalRegs returns the global default registry.

func NewRegs

func NewRegs() *Regs

NewRegs returns a new instance with a pristine PrxReg.

type Span

type Span time.Duration

func ToSpan

func ToSpan(v Val) (s Span, err error)

func (Span) As

func (s Span) As(t typ.Type) (Val, error)

func (Span) MarshalJSON

func (s Span) MarshalJSON() ([]byte, error)

func (Span) Mut

func (s Span) Mut() Mut

func (Span) Nil

func (s Span) Nil() bool

func (Span) Print

func (s Span) Print(p *bfr.P) error

func (Span) Seconds

func (s Span) Seconds() float64

func (Span) String

func (s Span) String() string

func (Span) Type

func (Span) Type() typ.Type

func (*Span) UnmarshalJSON

func (s *Span) UnmarshalJSON(b []byte) error

func (Span) Value

func (s Span) Value() Val

func (Span) Zero

func (s Span) Zero() bool

type SpanMut

type SpanMut time.Duration

func (*SpanMut) As

func (s *SpanMut) As(t typ.Type) (Val, error)

func (*SpanMut) Assign

func (s *SpanMut) Assign(p Val) error

func (*SpanMut) MarshalJSON

func (s *SpanMut) MarshalJSON() ([]byte, error)

func (*SpanMut) Mut

func (s *SpanMut) Mut() Mut

func (*SpanMut) New

func (*SpanMut) New() Mut

func (*SpanMut) Nil

func (s *SpanMut) Nil() bool

func (*SpanMut) Parse

func (s *SpanMut) Parse(a ast.Ast) error

func (*SpanMut) Print

func (s *SpanMut) Print(p *bfr.P) error

func (*SpanMut) Ptr

func (s *SpanMut) Ptr() interface{}

func (*SpanMut) String

func (s *SpanMut) String() string

func (*SpanMut) Type

func (*SpanMut) Type() typ.Type

func (*SpanMut) UnmarshalJSON

func (s *SpanMut) UnmarshalJSON(b []byte) error

func (*SpanMut) Value

func (s *SpanMut) Value() Val

func (*SpanMut) Zero

func (s *SpanMut) Zero() bool

type Str

type Str string

func ToStr

func ToStr(v Val) (s Str, err error)

func (Str) As

func (s Str) As(t typ.Type) (Val, error)

func (Str) Len

func (s Str) Len() int

func (Str) MarshalJSON

func (s Str) MarshalJSON() ([]byte, error)

func (Str) Mut

func (s Str) Mut() Mut

func (Str) Nil

func (s Str) Nil() bool

func (Str) Print

func (s Str) Print(p *bfr.P) error

func (Str) String

func (s Str) String() string

func (Str) Type

func (Str) Type() typ.Type

func (Str) Value

func (s Str) Value() Val

func (Str) Zero

func (s Str) Zero() bool

type StrMut

type StrMut string

func (*StrMut) As

func (s *StrMut) As(t typ.Type) (Val, error)

func (*StrMut) Assign

func (s *StrMut) Assign(p Val) error

func (*StrMut) Len

func (s *StrMut) Len() int

func (*StrMut) MarshalJSON

func (s *StrMut) MarshalJSON() ([]byte, error)

func (*StrMut) Mut

func (s *StrMut) Mut() Mut

func (*StrMut) New

func (*StrMut) New() Mut

func (*StrMut) Nil

func (s *StrMut) Nil() bool

func (*StrMut) Parse

func (s *StrMut) Parse(a ast.Ast) error

func (*StrMut) Print

func (s *StrMut) Print(p *bfr.P) error

func (*StrMut) Ptr

func (s *StrMut) Ptr() interface{}

func (*StrMut) String

func (s *StrMut) String() string

func (*StrMut) Type

func (*StrMut) Type() typ.Type

func (*StrMut) Value

func (s *StrMut) Value() Val

func (*StrMut) Zero

func (s *StrMut) Zero() bool

type StrOp

type StrOp struct {
	N int
	V Str
}

StrOp represents a string operation used for str diff edits. N > 0 means retain N runes and N < 0 means delete -N runes and N == 0 means insert V.

type StrOps

type StrOps []StrOp

func (StrOps) Len

func (ops StrOps) Len() int

func (StrOps) Op

func (ops StrOps) Op(i int) (int, Val)

func (StrOps) Swap

func (ops StrOps) Swap(i, j int)

type Time

type Time time.Time

func Now

func Now() Time

Now returns a new lit time value truncated to millisecond precision.

func ToTime

func ToTime(v Val) (t Time, err error)

func (Time) After

func (t Time) After(o Time) bool

func (Time) As

func (t Time) As(n typ.Type) (Val, error)

func (Time) Equal

func (t Time) Equal(o Time) bool

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) Mut

func (t Time) Mut() Mut

func (Time) Nil

func (t Time) Nil() bool

func (Time) Print

func (t Time) Print(p *bfr.P) error

func (Time) String

func (t Time) String() string

func (Time) Type

func (Time) Type() typ.Type

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

func (Time) Value

func (t Time) Value() Val

func (Time) Zero

func (t Time) Zero() bool

type TimeMut

type TimeMut time.Time

func (*TimeMut) As

func (t *TimeMut) As(n typ.Type) (Val, error)

func (*TimeMut) Assign

func (t *TimeMut) Assign(p Val) error

func (*TimeMut) MarshalJSON

func (t *TimeMut) MarshalJSON() ([]byte, error)

func (*TimeMut) Mut

func (t *TimeMut) Mut() Mut

func (*TimeMut) New

func (*TimeMut) New() Mut

func (*TimeMut) Nil

func (t *TimeMut) Nil() bool

func (*TimeMut) Parse

func (t *TimeMut) Parse(a ast.Ast) error

func (*TimeMut) Print

func (t *TimeMut) Print(p *bfr.P) error

func (*TimeMut) Ptr

func (t *TimeMut) Ptr() interface{}

func (*TimeMut) String

func (t *TimeMut) String() string

func (*TimeMut) Type

func (*TimeMut) Type() typ.Type

func (*TimeMut) UnmarshalJSON

func (t *TimeMut) UnmarshalJSON(b []byte) error

func (*TimeMut) Value

func (t *TimeMut) Value() Val

func (*TimeMut) Zero

func (t *TimeMut) Zero() bool

type UUID

type UUID [16]byte

func NewUUID

func NewUUID() UUID

NewUUID returns a new random lit uuid v4 value.

func ToUUID

func ToUUID(v Val) (u UUID, err error)

func (UUID) As

func (u UUID) As(t typ.Type) (Val, error)

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

func (UUID) Mut

func (u UUID) Mut() Mut

func (UUID) Nil

func (u UUID) Nil() bool

func (UUID) Print

func (u UUID) Print(p *bfr.P) error

func (UUID) String

func (u UUID) String() string

func (UUID) Type

func (UUID) Type() typ.Type

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(b []byte) error

func (UUID) Value

func (u UUID) Value() Val

func (UUID) Zero

func (u UUID) Zero() bool

type UUIDMut

type UUIDMut [16]byte

func (*UUIDMut) As

func (u *UUIDMut) As(t typ.Type) (Val, error)

func (*UUIDMut) Assign

func (u *UUIDMut) Assign(p Val) error

func (*UUIDMut) MarshalJSON

func (u *UUIDMut) MarshalJSON() ([]byte, error)

func (*UUIDMut) Mut

func (u *UUIDMut) Mut() Mut

func (*UUIDMut) New

func (*UUIDMut) New() Mut

func (*UUIDMut) Nil

func (u *UUIDMut) Nil() bool

func (*UUIDMut) Parse

func (u *UUIDMut) Parse(a ast.Ast) error

func (*UUIDMut) Print

func (u *UUIDMut) Print(p *bfr.P) error

func (*UUIDMut) Ptr

func (u *UUIDMut) Ptr() interface{}

func (*UUIDMut) String

func (u *UUIDMut) String() string

func (*UUIDMut) Type

func (*UUIDMut) Type() typ.Type

func (*UUIDMut) UnmarshalJSON

func (u *UUIDMut) UnmarshalJSON(b []byte) error

func (*UUIDMut) Value

func (u *UUIDMut) Value() Val

func (*UUIDMut) Zero

func (u *UUIDMut) Zero() bool

type Val

type Val = typ.LitVal

Val is the common interface of all literal values.

func Clone

func Clone(v Val) (Val, error)

Clone deep copies v or returns an error. It uses the same value implementations, but may turn none-mutable primitive values into a mutable representation.

func Edit

func Edit(v Val, f EditFunc) (r Val, err error)

Edit edits v and returns the result or an error. Function f is never called with nil.

func EditTypes

func EditTypes(v Val, f typ.EditFunc) (Val, error)

func Parse

func Parse(str string) (Val, error)

Parse parses str and returns a generic value or an error.

func ParseVal

func ParseVal(a ast.Ast) (v Val, err error)

ParseVal parses a as generic value and returns it or an error.

func Read

func Read(r io.Reader, name string) (Val, error)

Read parses named reader r and returns a generic value or an error.

func Select

func Select(val Val, path string) (Val, error)

Select reads path and returns the selected value from val or an error.

func SelectIdx

func SelectIdx(val Val, idx int) (res Val, err error)

func SelectKey

func SelectKey(val Val, key string) (Val, error)

func SelectPath

func SelectPath(val Val, path cor.Path) (_ Val, err error)

SelectPath returns the selected value at path from val or an error.

func Unwrap

func Unwrap(v Val) Val

type Vals

type Vals []Val

func SelectList

func SelectList(val Val, path cor.Path) (Vals, error)

func (*Vals) Append

func (v *Vals) Append(n ...Val) error

func (*Vals) As

func (v *Vals) As(t typ.Type) (Val, error)

func (*Vals) Assign

func (v *Vals) Assign(p Val) error

func (Vals) Idx

func (v Vals) Idx(i int) (res Val, err error)

func (Vals) IterIdx

func (v Vals) IterIdx(it func(int, Val) error) error

func (Vals) Len

func (v Vals) Len() int

func (Vals) MarshalJSON

func (v Vals) MarshalJSON() ([]byte, error)

func (*Vals) Mut

func (v *Vals) Mut() Mut

func (*Vals) New

func (*Vals) New() Mut

func (*Vals) Nil

func (v *Vals) Nil() bool

func (*Vals) Parse

func (v *Vals) Parse(a ast.Ast) (err error)

func (Vals) Print

func (v Vals) Print(p *bfr.P) (err error)

func (*Vals) Ptr

func (v *Vals) Ptr() interface{}

func (*Vals) SetIdx

func (v *Vals) SetIdx(i int, el Val) (err error)

func (Vals) String

func (v Vals) String() string

func (Vals) Type

func (v Vals) Type() typ.Type

func (*Vals) UnmarshalJSON

func (v *Vals) UnmarshalJSON(b []byte) error

func (*Vals) Value

func (v *Vals) Value() Val

func (*Vals) Zero

func (v *Vals) Zero() bool

type Wrapper

type Wrapper interface{ Unwrap() Val }

Jump to

Keyboard shortcuts

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