vars

package
v0.0.0-...-e8daaa7 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalSubstitute

func EvalSubstitute(s string, varValue VarValue) string

func ToString

func ToString(value any) string

Types

type Bracket

type Bracket struct {
	Left  byte
	Right byte
}

func PairBracket

func PairBracket(left byte) *Bracket

type GenFn

type GenFn func() interface{}

type Literal

type Literal struct{ V string }

func (Literal) Eval

func (l Literal) Eval(VarValue) string

type MapGenValue

type MapGenValue struct {
	GenMap     map[string]func(params string) GenFn
	Map        map[string]GenFn
	MissedVars map[string]bool
	Vars       map[string]interface{}
}

func NewMapGenValue

func NewMapGenValue(m map[string]func(params string) GenFn) *MapGenValue

func (*MapGenValue) GetValue

func (m *MapGenValue) GetValue(name, params, expr string) interface{}

func (*MapGenValue) Value

func (m *MapGenValue) Value(name, params, expr string) interface{}

type Part

type Part interface {
	Eval(varValue VarValue) string
}

type Parts

type Parts []Part

func ParseSubstitute

func ParseSubstitute(s string) (parts Parts)

func (Parts) Eval

func (l Parts) Eval(varValue VarValue) string

type Sub

type Sub interface {
	IsVar() bool
}

type SubTxt

type SubTxt struct {
	Val string
}

func (SubTxt) IsVar

func (s SubTxt) IsVar() bool

type SubVar

type SubVar struct {
	Name   string
	Params string
	Expr   string
}

func (SubVar) IsVar

func (s SubVar) IsVar() bool

type Subs

type Subs []Sub

func ParseExpr

func ParseExpr(src string) Subs

func (Subs) CountVars

func (s Subs) CountVars() (count int)

func (Subs) Eval

func (s Subs) Eval(valuer Valuer) (any, error)

type Valuer

type Valuer interface {
	Value(name, params, expr string) (any, error)
}

type ValuerHandler

type ValuerHandler func(name, params string) (any, error)

func (ValuerHandler) Value

func (f ValuerHandler) Value(name, params string) (any, error)

type Var

type Var struct {
	Name string
	Expr string
}

func (Var) Eval

func (l Var) Eval(varValue VarValue) string

type VarValue

type VarValue interface {
	GetValue(name, params, expr string) interface{}
}

type VarValueHandler

type VarValueHandler func(name, params, expr string) interface{}

func (VarValueHandler) GetValue

func (v VarValueHandler) GetValue(name, params, expr string) interface{}

Jump to

Keyboard shortcuts

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