preprocessor

package
v0.0.0-...-215933a Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnresolvable = errors.New("field is unresolvable")

ErrUnresolvable indicates that a field exists but is unresolvable due to nil references

Functions

func DesugarCall

func DesugarCall(g *graph.Graph, call string) (string, error)

DesugarCall takes a call in the form of "a.b.c.d" and returns a desugared string that will work with the language extension provided by calling .Language()

func EvalMember

func EvalMember(name string, obj interface{}) (reflect.Value, error)

EvalMember gets a member from a stuct, dereferencing pointers as necessary

func EvalTerms

func EvalTerms(obj interface{}, terms ...string) (interface{}, error)

EvalTerms acts as a left fold over a list of term accessors

func Find

func Find(slice []string, f func(string) bool) (string, bool)

Find returns the first element of the string slice for which f returns true

func HasField

func HasField(obj interface{}, fieldName string) bool

HasField returns true if the provided struct has the defined field

func HasMethod

func HasMethod(obj interface{}, methodName string) bool

HasMethod returns true if the provided struct supports the defined method

func HasPath

func HasPath(obj interface{}, terms ...string) error

HasPath returns true of the set of terms can resolve to a value

func Inits

func Inits(in []string) [][]string

Inits returns a list of heads of the string, e.g. [1,2,3] -> [[1,2,3],[1,2],[1]]

func JoinTerms

func JoinTerms(s []string) string

JoinTerms takes a list of terms and joins them with '.'

func ListFields

func ListFields(obj interface{}) ([]string, error)

ListFields returns a list of fields for the struct

func LookupCanonicalFieldName

func LookupCanonicalFieldName(t reflect.Type, term string) (string, error)

LookupCanonicalFieldName takes a type and an arbitrarily cased field name and returns the field name with a case that matches the actual field.

func MkCallPipeline

func MkCallPipeline(s string) string

MkCallPipeline transforms a term group (b.c.d) into a pipeline (b | c | d)

func Prefixes

func Prefixes(in string) (out []string)

Prefixes returns a set of prefixes for a string, e.g. "a.b.c.d" will yield []string{"a.b.c.d","a.b.c","a.b.","a"}

func SplitTerms

func SplitTerms(in string) []string

SplitTerms takes a string and splits it on '.'

func VertexSplit

func VertexSplit(g *graph.Graph, s string) (string, string, bool)

VertexSplit takes a graph with a set of vertexes and a string, and returns the longest vertex id from the graph and the remainder of the string. If no matching vertex is found 'false' is returned.

Types

type Preprocessor

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

Preprocessor is a template preprocessor

func New

func New(g *graph.Graph) *Preprocessor

New creates a new preprocessor for the specified graph

Jump to

Keyboard shortcuts

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