cmlmapper

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

README

CML Mapper .

CML mapper is a mapper private to CML

Uses

It gets the required value from the underlying data in the CML pipeline.

Eg. If math1 is defined as : [ 1 2 3 4 "Abc" 6 ] Using this mapper we can directly do $math1[0][2] within the CML Specification to get the desired value.

Implementation Details

There are two main methods : NewExpression and Resolve.

NewExpression takes in a string such as math1[0][2] and converts into an array of "dereferenceStruct" which helps us navigate variable "math1".

Resolve takes in the "dereferenceStruct" and "scope" (which contains the variable) and gives us the dersired value from the variable "math1"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(deStructs []DerefernceStruct, scope data.Scope, value interface{})

func Resolve

func Resolve(deStructs []DerefernceStruct, scope data.Scope) (temp interface{}, err error)

Resolve resolves the value from the data using dereference struct and scope. scope is the collection of the data.

Types

type CmlMapper

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

Eg. If `math1` is defined as : [ 1 2 3

4 "Abc" 6 ]

Using this mapper we can directly do $math1[0][2] within the CML Specification To get the desired value.

type DerefernceStruct

type DerefernceStruct struct {
	Id    string //The id of data i.e. label of the data.
	Index string // The identifier of the value in the data. Eg math[0] or math['sample'] . 0 and 'sample' will be the Index.
}

A struct which helps to navigate the data to find the value.

func NewExpression

func NewExpression(str string) []DerefernceStruct

NewExpression returns the deference struct (which will help to navigate the data to find the value) from the given string.

Jump to

Keyboard shortcuts

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