types

package
v0.0.0-...-7fbf898 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package types contains shared type definitions.

Index

Constants

View Source
const (
	// MaxStackDepth contains the maximum number of nested projector calls that can be made without
	// returning.
	MaxStackDepth = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Variables StackMapInterface

	Output *jsonutil.JSONToken

	TopLevelObjects map[string][]jsonutil.JSONToken
	Registry        *Registry
	// contains filtered or unexported fields
}

A Context stores data about variables and ancestors for a projector invocation.

func NewContext

func NewContext(registry *Registry) *Context

NewContext creates a new context with empty components initialized and ready to go.

func (*Context) PopProjectorFromStack

func (c *Context) PopProjectorFromStack(name string)

PopProjectorFromStack removes one count of the given projector name from the stack trace.

func (*Context) Projector

func (c *Context) Projector() string

Projector returns the latest projector in the stack.

func (*Context) PushProjectorToStack

func (c *Context) PushProjectorToStack(name string) error

PushProjectorToStack adds one count of the given projector name to the stack trace.

func (*Context) String

func (c *Context) String() string

type Projector

type Projector func(arguments []jsonutil.JSONMetaNode, pctx *Context) (jsonutil.JSONToken, error)

Projector is a type alias for the function signature of a projector.

type Registry

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

Registry stores projectors for a mapping config to use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty registry.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of projectors in the registry.

func (*Registry) FindProjector

func (r *Registry) FindProjector(name string) (Projector, error)

FindProjector finds and returns a projector with the given name, or an error if no projector with that name exists.

func (*Registry) RegisterProjector

func (r *Registry) RegisterProjector(name string, projector Projector) error

RegisterProjector adds the given Projector to the registry.

type StackMap

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

StackMap implements StackMapInterface, which acts like a layered stack of maps.

func NewStackMap

func NewStackMap() *StackMap

NewStackMap instantiates a new stack map.

func (*StackMap) Empty

func (s *StackMap) Empty() bool

Empty returns true if the StackMap contains no layers or its sole layer is empty.

func (*StackMap) Get

func (s *StackMap) Get(key string) (*jsonutil.JSONToken, error)

Get reads the value specified by the key, from the latest map going forward.

func (*StackMap) Pop

func (s *StackMap) Pop() (map[string]*jsonutil.JSONToken, error)

Pop removes the latest (last) map from the stack.

func (*StackMap) Push

func (s *StackMap) Push()

Push creates a new layer (empty map) in the stack.

func (*StackMap) Set

func (s *StackMap) Set(key string, value *jsonutil.JSONToken) error

Set stores the key-value pair specified as parameters to the latest map.

func (*StackMap) String

func (s *StackMap) String() string

String returns a pretty printed, human readable string representation of this StackMap.

type StackMapInterface

type StackMapInterface interface {
	Push()
	Pop() (map[string]*jsonutil.JSONToken, error)
	Set(key string, value *jsonutil.JSONToken) error
	Get(key string) (*jsonutil.JSONToken, error)
	String() string
	Empty() bool
}

StackMapInterface defines a layered map, that allows a new map layer to be pushed, have values added to it, then be popped and have only those values disappear from the overall map. Get() calls will scan all maps starting at the top of the stack and return the first found values.

Directories

Path Synopsis
Package registerall contains registerAll function that registers builtin function into projectors
Package registerall contains registerAll function that registers builtin function into projectors

Jump to

Keyboard shortcuts

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