tosca

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadFieldModeDefault       = 0
	ReadFieldModeList          = 1
	ReadFieldModeSequencedList = 2
	ReadFieldModeItem          = 3
)

Variables

View Source
var PrimitiveTypeValidators = map[string]reflection.TypeValidator{
	"boolean":     reflection.IsBool,
	"integer":     reflection.IsInt,
	"float":       reflection.IsFloat,
	"string":      reflection.IsString,
	"!!timestamp": reflection.IsTime,
	"list":        reflection.IsSliceOfStruct,
	"map":         reflection.IsMap,
}
View Source
var PrimitiveTypeZeroes = map[string]interface{}{
	"boolean":     false,
	"integer":     0,
	"float":       0.0,
	"string":      "",
	"!!timestamp": time.Time{},
	"list":        ard.List{},
	"map":         make(ard.Map),
}

Functions

func GetCanonicalName

func GetCanonicalName(entityPtr interface{}) string

func GetEntityTypeName

func GetEntityTypeName(type_ reflect.Type) string

From "name" tag

func GetKey

func GetKey(entityPtr interface{}) string

From Mappable interface

func GetMetadata

func GetMetadata(entityPtr interface{}) (map[string]string, bool)

From HasMetadata interface

func GetParent

func GetParent(entityPtr interface{}) (interface{}, bool)

From Hierarchical interface

func PrimitiveTypeName

func PrimitiveTypeName(value interface{}) string

func ValidateRequiredFields

func ValidateRequiredFields(entityPtr interface{}) bool

From "require" tags

Types

type Context

type Context struct {
	Parent             *Context
	Name               string
	Path               ard.Path
	URL                urlpkg.URL
	Data               interface{} // ARD
	Locator            ard.Locator
	CanonicalNamespace *string
	Namespace          Namespace
	ScriptletNamespace ScriptletNamespace
	Hierarchy          *Hierarchy
	Problems           *problems.Problems
	Quirks             []string
	Grammar            *Grammar
	ReadOverrides      map[string]string
}

func GetContext

func GetContext(entityPtr interface{}) *Context

From Contextual interface

func NewContext

func NewContext(quirks []string) *Context

func (*Context) Clone

func (self *Context) Clone(data interface{}) *Context

func (*Context) EmbedScriptlet

func (self *Context) EmbedScriptlet(name string, scriptlet string)

func (*Context) FieldChild

func (self *Context) FieldChild(name interface{}, data interface{}) *Context

func (*Context) FieldChildren

func (self *Context) FieldChildren() []*Context

func (*Context) FormatBadData

func (self *Context) FormatBadData() string

func (*Context) GetAncestor

func (self *Context) GetAncestor(generation int) *Context

func (*Context) GetCanonicalNamespace

func (self *Context) GetCanonicalNamespace() *string

func (*Context) GetFieldChild

func (self *Context) GetFieldChild(name string) (*Context, bool)

func (*Context) GetLocation

func (self *Context) GetLocation() (int, int)

func (*Context) GetRequiredFieldChild

func (self *Context) GetRequiredFieldChild(name string) (*Context, bool)

func (*Context) HasQuirk

func (self *Context) HasQuirk(quirk string) bool

func (*Context) ImportScriptlet

func (self *Context) ImportScriptlet(name string, path string)

func (*Context) Is

func (self *Context) Is(typeNames ...string) bool

func (*Context) ListChild

func (self *Context) ListChild(index int, data interface{}) *Context

func (*Context) MapChild

func (self *Context) MapChild(name interface{}, data interface{}) *Context

func (*Context) NewFunctionCall

func (self *Context) NewFunctionCall(name string, arguments []interface{}) *FunctionCall

func (*Context) NewImportContext

func (self *Context) NewImportContext(url urlpkg.URL) *Context

func (*Context) ReadBoolean

func (self *Context) ReadBoolean() *bool

func (*Context) ReadFields

func (self *Context) ReadFields(entityPtr interface{}) []string

From "read" tags

func (*Context) ReadFloat

func (self *Context) ReadFloat() *float64

func (*Context) ReadInteger

func (self *Context) ReadInteger() *int64

func (*Context) ReadListItems

func (self *Context) ReadListItems(read Reader, process Processor) bool

func (*Context) ReadMapItems

func (self *Context) ReadMapItems(read Reader, process Processor) bool

func (*Context) ReadSequencedListItems

func (self *Context) ReadSequencedListItems(read Reader, process Processor) bool

func (*Context) ReadString

func (self *Context) ReadString() *string

func (*Context) ReadStringList

func (self *Context) ReadStringList() *[]string

func (*Context) ReadStringListFixed

func (self *Context) ReadStringListFixed(length int) *[]string

func (*Context) ReadStringMap

func (self *Context) ReadStringMap() *map[string]interface{}

func (*Context) ReadStringOrStringList

func (self *Context) ReadStringOrStringList() *[]string

func (*Context) ReadStringStringMap

func (self *Context) ReadStringStringMap() *map[string]string

func (*Context) Report

func (self *Context) Report(skip int, message string) bool

func (*Context) ReportCopyLoop

func (self *Context) ReportCopyLoop(name string) bool

func (*Context) ReportError

func (self *Context) ReportError(err error) bool

func (*Context) ReportFieldMalformedSequencedList

func (self *Context) ReportFieldMalformedSequencedList() bool

func (*Context) ReportFieldMissing

func (self *Context) ReportFieldMissing() bool

func (*Context) ReportFieldReferenceNotFound

func (self *Context) ReportFieldReferenceNotFound(types ...reflect.Type) bool

func (*Context) ReportFieldUnsupported

func (self *Context) ReportFieldUnsupported() bool

func (*Context) ReportFieldUnsupportedValue

func (self *Context) ReportFieldUnsupportedValue() bool

func (*Context) ReportImportIncompatible

func (self *Context) ReportImportIncompatible(url urlpkg.URL) bool

func (*Context) ReportImportLoop

func (self *Context) ReportImportLoop(url urlpkg.URL) bool

func (*Context) ReportInSection

func (self *Context) ReportInSection(skip int, message string, row int, column int) bool

func (*Context) ReportIncompatible

func (self *Context) ReportIncompatible(name string, target string, kind string) bool

func (*Context) ReportIncompatibleExtension

func (self *Context) ReportIncompatibleExtension(extension string, requiredExtensions []string) bool

func (*Context) ReportIncompatibleType

func (self *Context) ReportIncompatibleType(type_ interface{}, parentType interface{}) bool

func (*Context) ReportIncompatibleTypeInSet added in v0.11.0

func (self *Context) ReportIncompatibleTypeInSet(type_ interface{}) bool

func (*Context) ReportInheritanceLoop

func (self *Context) ReportInheritanceLoop(parentType interface{}) bool

func (*Context) ReportMapKeyReused

func (self *Context) ReportMapKeyReused(key string) bool

func (*Context) ReportMissingEntrySchema

func (self *Context) ReportMissingEntrySchema(kind string) bool

func (*Context) ReportNameAmbiguous

func (self *Context) ReportNameAmbiguous(type_ reflect.Type, name string, entityPtrs ...interface{}) bool

func (*Context) ReportNotInRange

func (self *Context) ReportNotInRange(name string, value uint64, lower uint64, upper uint64) bool

func (*Context) ReportPath

func (self *Context) ReportPath(skip int, message string) bool

func (*Context) ReportPathf

func (self *Context) ReportPathf(skip int, f string, arg ...interface{}) bool

func (*Context) ReportPrimitiveType

func (self *Context) ReportPrimitiveType() bool

func (*Context) ReportProblematic

func (self *Context) ReportProblematic(skip int, problematic problems.Problematic) bool

func (*Context) ReportPropertyRequired

func (self *Context) ReportPropertyRequired(kind string) bool

func (*Context) ReportReferenceAmbiguous

func (self *Context) ReportReferenceAmbiguous(kind string, entityPtr interface{}) bool

func (*Context) ReportReferenceNotFound

func (self *Context) ReportReferenceNotFound(kind string, entityPtr interface{}) bool

func (*Context) ReportRepositoryInaccessible

func (self *Context) ReportRepositoryInaccessible(repositoryName string) bool

func (*Context) ReportReservedMetadata

func (self *Context) ReportReservedMetadata() bool

func (*Context) ReportTypeIncomplete

func (self *Context) ReportTypeIncomplete(parentType interface{}) bool

func (*Context) ReportUndeclared

func (self *Context) ReportUndeclared(kind string) bool

func (*Context) ReportUnknown

func (self *Context) ReportUnknown(kind string) bool

func (*Context) ReportUnknownDataType

func (self *Context) ReportUnknownDataType(dataTypeName string) bool

func (*Context) ReportUnsupportedType

func (self *Context) ReportUnsupportedType() bool

func (*Context) ReportValueMalformed

func (self *Context) ReportValueMalformed(kind string, reason string) bool

func (*Context) ReportValueWrongFormat

func (self *Context) ReportValueWrongFormat(format string) bool

func (*Context) ReportValueWrongLength

func (self *Context) ReportValueWrongLength(kind string, length int) bool

func (*Context) ReportValueWrongType

func (self *Context) ReportValueWrongType(requiredTypeNames ...string) bool

func (*Context) Reportf

func (self *Context) Reportf(skip int, f string, arg ...interface{}) bool

func (*Context) SequencedListChild

func (self *Context) SequencedListChild(index int, name string, data interface{}) *Context

func (*Context) ValidateType

func (self *Context) ValidateType(requiredTypeNames ...string) bool

func (*Context) ValidateUnsupportedFields

func (self *Context) ValidateUnsupportedFields(keys []string)

type Contextual

type Contextual interface {
	GetContext() *Context
}

type EntityPtrs

type EntityPtrs []interface{}

func (EntityPtrs) Len

func (self EntityPtrs) Len() int

func (EntityPtrs) Less

func (self EntityPtrs) Less(i, j int) bool

func (EntityPtrs) Swap

func (self EntityPtrs) Swap(i, j int)

type FunctionCall

type FunctionCall struct {
	Name      string        `json:"name" yaml:"name"`
	Arguments []interface{} `json:"arguments" yaml:"arguments"`
	URL       string        `json:"url,omitempty" yaml:"url,omitempty"`
	Row       int           `json:"row,omitempty" yaml:"row,omitempty"`
	Column    int           `json:"column,omitempty" yaml:"column,omitempty"`
	Path      string        `json:"path,omitempty" yaml:"path,omitempty"`
}

func NewFunctionCall

func NewFunctionCall(name string, arguments []interface{}, url string, row int, column int, path string) *FunctionCall

type Grammar

type Grammar struct {
	Versions GrammarVersions
	Readers  Readers
}

func NewGrammar

func NewGrammar() Grammar

func (*Grammar) RegisterReader

func (self *Grammar) RegisterReader(name string, reader Reader)

func (*Grammar) RegisterVersion

func (self *Grammar) RegisterVersion(keyword string, version string, implicitProfilePath string)

type GrammarVersion

type GrammarVersion struct {
	Version             string
	ImplicitProfilePath string
}

type GrammarVersions

type GrammarVersions map[string][]GrammarVersion

func (GrammarVersions) Add

func (self GrammarVersions) Add(keyword string, version string, implicitProfilePath string)

type HasMetadata

type HasMetadata interface {
	GetMetadata() (map[string]string, bool)
}

type Hierarchical

type Hierarchical interface {
	GetParent() interface{}
}

type Hierarchy

type Hierarchy struct {
	EntityPtr interface{}
	Parent    *Hierarchy
	Children  []*Hierarchy
}

func NewHierarchy

func NewHierarchy(entityPtr interface{}, hierarchyContext HierarchyContext) *Hierarchy

func (*Hierarchy) Add

func (self *Hierarchy) Add(entityPtr interface{}, parentPtr interface{}, hierarchyContext HierarchyContext, descendants HierarchyDescendants) (*Hierarchy, bool)

func (*Hierarchy) AddChild

func (self *Hierarchy) AddChild(node *Hierarchy)

func (*Hierarchy) AddTo

func (self *Hierarchy) AddTo(entityPtr interface{})

Into "hierarchy" tags

func (*Hierarchy) AddTypeTo

func (self *Hierarchy) AddTypeTo(field reflect.Value, type_ reflect.Type)

func (*Hierarchy) Find

func (self *Hierarchy) Find(entityPtr interface{}) (*Hierarchy, bool)

func (*Hierarchy) GetContext

func (self *Hierarchy) GetContext() *Context

func (*Hierarchy) IsCompatible

func (self *Hierarchy) IsCompatible(baseEntityPtr interface{}, entityPtr interface{}) bool

func (Hierarchy) Len

func (self Hierarchy) Len() int

func (Hierarchy) Less

func (self Hierarchy) Less(i, j int) bool

func (*Hierarchy) Lookup

func (self *Hierarchy) Lookup(name string, type_ reflect.Type) (*Hierarchy, bool)

func (*Hierarchy) Merge

func (self *Hierarchy) Merge(node *Hierarchy, hierarchyContext HierarchyContext)

func (*Hierarchy) Print

func (self *Hierarchy) Print(indent int)

Note that the same name could be printed out twice in the hierarchy, even under the same parent! That's because we are printing the local name of the type, and types imported from other files can have the same name (though you would need a namespace_prefix to avoid a namespace error)

func (*Hierarchy) PrintChild

func (self *Hierarchy) PrintChild(indent int, treePrefix terminal.TreePrefix, last bool)

func (*Hierarchy) PrintChildren

func (self *Hierarchy) PrintChildren(indent int, treePrefix terminal.TreePrefix)

func (*Hierarchy) Root

func (self *Hierarchy) Root() *Hierarchy

func (Hierarchy) Swap

func (self Hierarchy) Swap(i, j int)

type HierarchyContext

type HierarchyContext map[interface{}]bool

Keeps track of failed types

type HierarchyDescendants

type HierarchyDescendants []interface{}

type ImportSpec

type ImportSpec struct {
	URL             url.URL
	NameTransformer NameTransformer
	Implicit        bool
}

type Importer

type Importer interface {
	GetImportSpecs() []*ImportSpec
}

type Inherits

type Inherits interface {
	Inherit()
}

type Mappable

type Mappable interface {
	GetKey() string
}

type NameTransformer

type NameTransformer = func(string, interface{}) []string

type Namespace

type Namespace map[reflect.Type]map[string]interface{}

func NewNamespace

func NewNamespace(entityPtr interface{}) Namespace

From "namespace" tags

func (Namespace) Lookup

func (self Namespace) Lookup(name string) (interface{}, bool)

func (Namespace) LookupForType

func (self Namespace) LookupForType(name string, type_ reflect.Type) (interface{}, bool)

func (Namespace) Merge

func (self Namespace) Merge(namespace Namespace, nameTransformer NameTransformer)

func (Namespace) Print

func (self Namespace) Print(indent int)

func (Namespace) Set

func (self Namespace) Set(name string, entityPtr interface{}) (interface{}, bool)

If the name has already been set returns existing entityPtr, true

type PreReadable

type PreReadable interface {
	PreRead()
}

type Processor

type Processor func(interface{})

type ReadField

type ReadField struct {
	FieldName string
	Key       string
	Context   *Context
	Entity    reflect.Value
	Reader    Reader
	Mode      int
	Important bool
	Wildcard  bool
}

func NewReadField

func NewReadField(fieldName string, tag string, context *Context, entity reflect.Value) *ReadField

func (*ReadField) Read

func (self *ReadField) Read()

type Reader

type Reader = func(*Context) interface{}

type Readers

type Readers map[string]Reader

type Scriptlet

type Scriptlet struct {
	Origin                urlpkg.URL `json:"origin" yaml:"origin"`
	Path                  string     `json:"path" yaml:"path"`
	Scriptlet             string     `json:"scriptlet" yaml:"scriptlet"`
	NativeArgumentIndexes []uint     `json:"nativeArgumentIndexes" yaml:"nativeArgumentIndexes"`
}

func (*Scriptlet) Read

func (self *Scriptlet) Read() (string, error)

type ScriptletNamespace

type ScriptletNamespace map[string]*Scriptlet

func (ScriptletNamespace) Merge

func (self ScriptletNamespace) Merge(from ScriptletNamespace)

func (ScriptletNamespace) RegisterScriptlet

func (self ScriptletNamespace) RegisterScriptlet(name string, scriptlet string, nativeArgumentIndexes []uint)

func (ScriptletNamespace) RegisterScriptlets

func (self ScriptletNamespace) RegisterScriptlets(scriptlets map[string]string, nativeArgumentIndexes map[string][]uint, ignore ...string)

type TypesByName

type TypesByName []reflect.Type

func (TypesByName) Len

func (self TypesByName) Len() int

func (TypesByName) Less

func (self TypesByName) Less(i, j int) bool

func (TypesByName) Swap

func (self TypesByName) Swap(i, j int)

Jump to

Keyboard shortcuts

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