hipathsys

package
v0.0.0-...-83c2f6f Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BooleanDataType = iota + LiteralDataType
	IntegerDataType
	DecimalDataType
	StringDataType
	DateDataType
	DateTimeDataType
	TimeDataType
	QuantityDataType
)
View Source
const NamespaceName = "System"

Variables

View Source
var (
	DecimalZero    = NewDecimalInt(0)
	DecimalOne     = NewDecimalInt(1)
	DecimalTwo     = NewDecimalInt(2)
	DecimalThree   = NewDecimalInt(3)
	DecimalDotFive = NewDecimalFloat64(.5)
	DecimalE       = NewDecimalFloat64(math.E)
)
View Source
var (
	DefaultQuantityUnit = NewQuantityUnitWithUCUM("1")

	EmptyQuantityUnit = NewQuantityUnitWithUCUM("")

	SecondQuantityUnit = NewQuantityUnit("second", "seconds", "s")
	MinuteQuantityUnit = NewQuantityUnit("minute", "minutes", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 60))
	HourQuantityUnit = NewQuantityUnit("hour", "hours", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 60*60))
	DayQuantityUnit = NewQuantityUnit("day", "days", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 24*60*60))
	WeekQuantityUnit = NewQuantityUnit("week", "weeks", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 7*24*60*60))
	MonthQuantityUnit = NewQuantityUnit("month", "months", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 30*24*60*60))
	YearQuantityUnit = NewQuantityUnit("year", "years", "",
		NewQuantityUnitBase(SecondQuantityUnit, true, 365*24*60*60),
		NewQuantityUnitBase(MonthQuantityUnit, true, 12))
	MillisecondQuantityUnit = NewQuantityUnit("millisecond", "milliseconds", "ms",
		NewQuantityUnitBase(SecondQuantityUnit, true, .001))
	NanosecondQuantityUnit = NewQuantityUnit("nanosecond", "nanoseconds", "ns",
		NewQuantityUnitBase(SecondQuantityUnit, true, .000000001))
	UCUMMinuteQuantityUnit = NewQuantityUnit("", "", "min",
		NewQuantityUnitBase(SecondQuantityUnit, false, 60))
	UCUMHourQuantityUnit = NewQuantityUnit("", "", "h",
		NewQuantityUnitBase(SecondQuantityUnit, false, 60*60))
	UCUMDayQuantityUnit = NewQuantityUnit("", "", "d",
		NewQuantityUnitBase(SecondQuantityUnit, false, 24*60*60))
	UCUMWeekQuantityUnit = NewQuantityUnit("", "", "wk",
		NewQuantityUnitBase(SecondQuantityUnit, false, 7*24*60*60))
	UCUMMonthQuantityUnit = NewQuantityUnit("", "", "mo",
		NewQuantityUnitBase(SecondQuantityUnit, false, 30*24*60*60))
	UCUMYearQuantityUnit = NewQuantityUnit("", "", "a",
		NewQuantityUnitBase(SecondQuantityUnit, false, 365*24*60*60))
)
View Source
var BooleanTypeSpec = newAnyTypeSpec("Boolean")
View Source
var DecimalTypeSpec = newAnyTypeSpec("Decimal")
View Source
var EmptyCol = NewEmptyCol()
View Source
var EmptyString = newString("", nil)
View Source
var IntegerTypeSpec = newAnyTypeSpec("Integer")
View Source
var QuantityTypeSpec = newAnyTypeSpec("Quantity")
View Source
var StringTypeSpec = newAnyTypeSpec("String")
View Source
var UCUMSystemURI = NewString("http://unitsofmeasure.org")
View Source
var UndefinedTypeSpec = NewTypeSpecWithBase(nil, nil)

Functions

func CastModelType

func CastModelType(adapter ModelAdapter, node interface{}, name FQTypeNameAccessor) (interface{}, error)

func DecimalValueFloat64

func DecimalValueFloat64(node interface{}) interface{}

func Equal

func Equal(n1 AnyAccessor, n2 AnyAccessor) bool

func Equivalent

func Equivalent(n1 AnyAccessor, n2 AnyAccessor) bool

func FQTypeNameEqual

func FQTypeNameEqual(t1 FQTypeNameAccessor, t2 FQTypeNameAccessor) bool

func HasModelType

func HasModelType(adapter ModelAdapter, node interface{}, name FQTypeNameAccessor) bool

func IntegerValue

func IntegerValue(node interface{}) interface{}

func IsCalendarDurationUnit

func IsCalendarDurationUnit(unit QuantityUnitAccessor) bool

func IsCol

func IsCol(node interface{}) bool

func ModelEqual

func ModelEqual(adapter ModelAdapter, node1 interface{}, node2 interface{}) bool

func ModelEquivalent

func ModelEquivalent(adapter ModelAdapter, node1 interface{}, node2 interface{}) bool

func NormalizedStringEqual

func NormalizedStringEqual(value1 string, value2 string) bool

func SystemAnyEqual

func SystemAnyEqual(node1 AnyAccessor, node2 interface{}) bool

func SystemAnyTypeEqual

func SystemAnyTypeEqual(node1 AnyAccessor, node2 interface{}) bool

func TemporalPrecisionEqual

func TemporalPrecisionEqual(t1 TemporalAccessor, t2 TemporalAccessor) bool

func TypeEqual

func TypeEqual(n1 AnyAccessor, n2 AnyAccessor) bool

Types

type AnyAccessor

type AnyAccessor interface {
	DataType() DataTypes
	TypeSpec() TypeSpecAccessor
	TypeInfo() TypeInfoAccessor
	Source() interface{}
	Equal(node interface{}) bool
	Equivalent(node interface{}) bool
}

type ArithmeticApplier

type ArithmeticApplier interface {
	Calc(operand DecimalValueAccessor, op ArithmeticOps) (DecimalValueAccessor, error)
	Abs() DecimalValueAccessor
}

type ArithmeticOps

type ArithmeticOps byte
const (
	AdditionOp       ArithmeticOps = '+'
	SubtractionOp    ArithmeticOps = '-'
	MultiplicationOp ArithmeticOps = '*'
	DivisionOp       ArithmeticOps = '/'
	DivOp            ArithmeticOps = 'D'
	ModOp            ArithmeticOps = 'M'
)

type BaseFunction

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

func NewBaseFunction

func NewBaseFunction(name string, evaluatorParam int, minParams int, maxParams int) BaseFunction

func (*BaseFunction) EvaluatorParam

func (f *BaseFunction) EvaluatorParam() int

func (*BaseFunction) MaxParams

func (f *BaseFunction) MaxParams() int

func (*BaseFunction) MinParams

func (f *BaseFunction) MinParams() int

func (*BaseFunction) Name

func (f *BaseFunction) Name() string

type BooleanAccessor

type BooleanAccessor interface {
	AnyAccessor
	Comparator
	Stringifier
	Negator
	Bool() bool
}

func BooleanOf

func BooleanOf(value bool) BooleanAccessor

func NewBoolean

func NewBoolean(value bool) BooleanAccessor

func NewBooleanWithSource

func NewBooleanWithSource(value bool, source interface{}) BooleanAccessor

func ParseBoolean

func ParseBoolean(value string) (BooleanAccessor, error)

type ClassInfoAccessor

type ClassInfoAccessor interface {
	TypeInfoAccessor
	Name() StringAccessor
	BaseType() StringAccessor
	Element() ColAccessor
}

func NewClassInfo

func NewClassInfo(namespace StringAccessor, name StringAccessor, baseType StringAccessor, element ColAccessor) ClassInfoAccessor

type ClassInfoElementAccessor

type ClassInfoElementAccessor interface {
	TypeInfoElementAccessor
}

func NewClassInfoElement

func NewClassInfoElement(name StringAccessor, typeName StringAccessor, oneBased BooleanAccessor) ClassInfoElementAccessor

type ColAccessor

type ColAccessor interface {
	AnyAccessor
	ItemTypeSpec() TypeSpecAccessor
	Empty() bool
	Count() int
	Get(i int) interface{}
	Contains(item interface{}) bool
}

func NewColDelegate

func NewColDelegate(col ColAccessor) ColAccessor

func NewEmptyCol

func NewEmptyCol() ColAccessor

func NewEmptyColWithSource

func NewEmptyColWithSource(source interface{}) ColAccessor

func NewSysArrayCol

func NewSysArrayCol(itemTypeSpec TypeSpecAccessor, items []interface{}) ColAccessor

type ColModifier

type ColModifier interface {
	ColAccessor
	Add(item interface{})
	AddUnique(item interface{}) bool
	AddAll(collection ColAccessor) int
	AddAllUnique(collection ColAccessor) int
}

func NewCol

func NewCol(adapter ModelAdapter) ColModifier

func NewColWithItem

func NewColWithItem(adapter ModelAdapter, item interface{}) ColModifier

func NewColWithSource

func NewColWithSource(adapter ModelAdapter, source interface{}) ColModifier

func NewColWithSpec

func NewColWithSpec(adapter ModelAdapter, itemTypeSpec TypeSpecAccessor) ColModifier

type Comparator

type Comparator interface {
	AnyAccessor
	Compare(comparator Comparator) (int, OperatorStatus)
}

type ContextAccessor

type ContextAccessor interface {
	EnvVar(name string) (interface{}, bool)
	ContextNode() interface{}
	ModelAdapter() ModelAdapter
	NewCol() ColModifier
	NewColWithItem(item interface{}) ColModifier
	Tracer() Tracer
}

type DataTypes

type DataTypes int
const ColDataType DataTypes = 0x0002
const LiteralDataType DataTypes = 0x0200
const UndefinedDataType DataTypes = 0x0001

type DateAccessor

type DateAccessor interface {
	DateTemporalAccessor
	Year() int
	Month() int
	Day() int
}

func NewDate

func NewDate(value time.Time) DateAccessor

func NewDateWithSource

func NewDateWithSource(value time.Time, source interface{}) DateAccessor

func NewDateYMD

func NewDateYMD(year int, month int, day int) DateAccessor

func NewDateYMDWithPrecision

func NewDateYMDWithPrecision(year, month, day int, precision DateTimePrecisions) DateAccessor

func NewDateYMDWithPrecisionAndSource

func NewDateYMDWithPrecisionAndSource(year, month, day int, precision DateTimePrecisions, source interface{}) DateAccessor

func NewDateYMDWithSource

func NewDateYMDWithSource(year int, month int, day int, source interface{}) DateAccessor

func ParseDate

func ParseDate(value string) (DateAccessor, error)

func ParseDateWithSource

func ParseDateWithSource(value string, source interface{}) (DateAccessor, error)

type DateTemporalAccessor

type DateTemporalAccessor interface {
	TemporalAccessor
	Time() time.Time
	Year() int
	Month() int
	Day() int
	Date() DateAccessor
	DateTime() DateTimeAccessor
}

type DateTimeAccessor

type DateTimeAccessor interface {
	DateTemporalAccessor
	Hour() int
	Minute() int
	Second() int
	Nanosecond() int
	Location() *time.Location
}

func NewDateTime

func NewDateTime(value time.Time) DateTimeAccessor

func NewDateTimeWithSource

func NewDateTimeWithSource(value time.Time, source interface{}) DateTimeAccessor

func NewDateTimeYMDHMSNWithPrecision

func NewDateTimeYMDHMSNWithPrecision(year, month, day, hour, minute, second, nanosecond int, loc *time.Location, precision DateTimePrecisions) DateTimeAccessor

func NewDateTimeYMDHMSNWithPrecisionAndSource

func NewDateTimeYMDHMSNWithPrecisionAndSource(year, month, day, hour, minute, second, nanosecond int, loc *time.Location, precision DateTimePrecisions, source interface{}) DateTimeAccessor

func ParseDateTime

func ParseDateTime(value string) (DateTimeAccessor, error)

func ParseDateTimeWithSource

func ParseDateTimeWithSource(value string, source interface{}) (DateTimeAccessor, error)

type DateTimePrecisions

type DateTimePrecisions int
const (
	YearDatePrecision DateTimePrecisions = iota
	MonthDatePrecision
	DayDatePrecision
	HourTimePrecision
	MinuteTimePrecision
	SecondTimePrecision
	NanoTimePrecision
)

type DecimalAccessor

type DecimalAccessor interface {
	NumberAccessor
	Primitive() decimal.Decimal
}

func DecimalOfInt

func DecimalOfInt(value int32) DecimalAccessor

func NewDecimal

func NewDecimal(value decimal.Decimal) DecimalAccessor

func NewDecimalFloat64

func NewDecimalFloat64(value float64) DecimalAccessor

func NewDecimalFloat64WithSource

func NewDecimalFloat64WithSource(value float64, source interface{}) DecimalAccessor

func NewDecimalInt

func NewDecimalInt(value int32) DecimalAccessor

func NewDecimalInt64

func NewDecimalInt64(value int64) DecimalAccessor

func NewDecimalInt64WithSource

func NewDecimalInt64WithSource(value int64, source interface{}) DecimalAccessor

func NewDecimalIntWithSource

func NewDecimalIntWithSource(value int32, source interface{}) DecimalAccessor

func NewDecimalWithSource

func NewDecimalWithSource(value decimal.Decimal, source interface{}) DecimalAccessor

func ParseDecimal

func ParseDecimal(value string) (DecimalAccessor, error)

func ParseDecimalWithSource

func ParseDecimalWithSource(value string, source interface{}) (DecimalAccessor, error)

type DecimalValueAccessor

type DecimalValueAccessor interface {
	AnyAccessor
	Value() DecimalAccessor
	WithValue(node NumberAccessor) DecimalValueAccessor
	ArithmeticOpSupported(op ArithmeticOps) bool
}

type Error

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

func NewError

func NewError(msg string, items []*ErrorItem) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Items

func (e *Error) Items() []*ErrorItem

type ErrorItem

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

func NewErrorItem

func NewErrorItem(line int, column int, msg string) *ErrorItem

func (*ErrorItem) Column

func (e *ErrorItem) Column() int

func (*ErrorItem) Line

func (e *ErrorItem) Line() int

func (*ErrorItem) Msg

func (e *ErrorItem) Msg() string

type Evaluator

type Evaluator interface {
	Evaluate(ctx ContextAccessor, node interface{}, loop Looper) (interface{}, error)
}

type FQTypeNameAccessor

type FQTypeNameAccessor interface {
	Anonymous() bool
	HasNamespace() bool
	Namespace() string
	Name() string
	String() string
	Equal(name FQTypeNameAccessor) bool
}

func NewFQTypeName

func NewFQTypeName(name string, namespace string) FQTypeNameAccessor

func NewTypeName

func NewTypeName(name string) FQTypeNameAccessor

func ParseFQTypeName

func ParseFQTypeName(fqName string) (FQTypeNameAccessor, error)

type FunctionExecutor

type FunctionExecutor interface {
	Name() string
	EvaluatorParam() int
	MinParams() int
	MaxParams() int
	Execute(ctx ContextAccessor, node interface{}, args []interface{}, loop Looper) (interface{}, error)
}

type IntegerAccessor

type IntegerAccessor interface {
	NumberAccessor
	Primitive() int32
}

func NewInteger

func NewInteger(value int32) IntegerAccessor

func NewIntegerWithSource

func NewIntegerWithSource(value int32, source interface{}) IntegerAccessor

func ParseInteger

func ParseInteger(value string) (IntegerAccessor, error)

type ListTypeInfoAccessor

type ListTypeInfoAccessor interface {
	TypeInfoAccessor
	ElementType() StringAccessor
}

func NewListTypeInfo

func NewListTypeInfo(elementType StringAccessor) ListTypeInfoAccessor

type Looper

type Looper interface {
	Evaluator() Evaluator
	This() interface{}
	Index() int
	IncIndex(this interface{}) int
	Total() interface{}
	SetTotal(total interface{})
}

func NewLoop

func NewLoop(evaluator Evaluator) Looper

func NewLoopWithIndex

func NewLoopWithIndex(evaluator Evaluator, index int) Looper

type ModelAdapter

type ModelAdapter interface {
	AsType(node interface{}, name FQTypeNameAccessor) (interface{}, error)
	CastToSystem(node interface{}) (AnyAccessor, error)
	TypeSpec(node interface{}) TypeSpecAccessor
	Equal(node1 interface{}, node2 interface{}) bool
	Equivalent(node1 interface{}, node2 interface{}) bool
	Navigate(node interface{}, name string) (interface{}, error)
	Children(node interface{}) (ColAccessor, error)
}

type Negator

type Negator interface {
	AnyAccessor
	Negate() AnyAccessor
}

type NumberAccessor

type NumberAccessor interface {
	AnyAccessor
	Comparator
	Stringifier
	DecimalValueAccessor
	Negator
	ArithmeticApplier
	Ceiling() NumberAccessor
	Exp() NumberAccessor
	Floor() NumberAccessor
	Ln() (NumberAccessor, error)
	Log(base NumberAccessor) (NumberAccessor, error)
	Power(exponent NumberAccessor) (NumberAccessor, bool)
	Round(precision int32) (NumberAccessor, error)
	Sqrt() (NumberAccessor, bool)
	Truncate(precision int32) NumberAccessor
	Int() int32
	Int64() int64
	Float32() float32
	Float64() float64
	BigFloat() *big.Float
	Decimal() decimal.Decimal
	One() bool
	Positive() bool
	HasFraction() bool
}

type OperatorStatus

type OperatorStatus int
const (
	Inconvertible OperatorStatus = iota
	Empty
	Evaluated
)

type QuantityAccessor

func NewQuantity

func NewQuantity(value DecimalAccessor, unit StringAccessor) QuantityAccessor

func NewQuantityWithSource

func NewQuantityWithSource(value DecimalAccessor, unit StringAccessor, source interface{}) QuantityAccessor

type QuantityUnitAccessor

type QuantityUnitAccessor interface {
	Singular() StringAccessor
	Plural() StringAccessor
	UCUM() StringAccessor
	Equal(unit QuantityUnitAccessor) bool
	Name(value DecimalAccessor) StringAccessor
	NameWithExp(value DecimalAccessor, exp int) StringAccessor
	RootBase() QuantityUnitBaseAccessor
	HasBase(unit QuantityUnitAccessor, equal bool) bool
	CommonBase(other QuantityUnitAccessor, equal bool) QuantityUnitAccessor
	Factor(other QuantityUnitAccessor, exp int) NumberAccessor
}

func NewQuantityUnit

func NewQuantityUnit(singular, plural, ucum string, bases ...QuantityUnitBaseAccessor) QuantityUnitAccessor

func NewQuantityUnitWithUCUM

func NewQuantityUnitWithUCUM(ucum string) QuantityUnitAccessor

func QuantityUnitByName

func QuantityUnitByName(name string) QuantityUnitAccessor

func QuantityUnitByNameString

func QuantityUnitByNameString(name StringAccessor) QuantityUnitAccessor

func QuantityUnitWithName

func QuantityUnitWithName(name string) (QuantityUnitAccessor, int)

func QuantityUnitWithNameString

func QuantityUnitWithNameString(name StringAccessor) (QuantityUnitAccessor, int)

type QuantityUnitBaseAccessor

type QuantityUnitBaseAccessor interface {
	Unit() QuantityUnitAccessor
	Equal() bool
	Factor() float64
	DecimalFactor() DecimalAccessor
}

func NewQuantityUnitBase

func NewQuantityUnitBase(unit QuantityUnitAccessor, equal bool, factor float64) QuantityUnitBaseAccessor

type SimpleTypeInfoAccessor

type SimpleTypeInfoAccessor interface {
	TypeInfoAccessor
	Name() StringAccessor
	BaseType() StringAccessor
}

func NewSimpleTypeInfo

func NewSimpleTypeInfo(namespace StringAccessor, name StringAccessor, baseType StringAccessor) SimpleTypeInfoAccessor

type StringAccessor

type StringAccessor interface {
	AnyAccessor
	Comparator
	Stringifier
	Length() int
}

func NewString

func NewString(value string) StringAccessor

func NewStringWithSource

func NewStringWithSource(value string, source interface{}) StringAccessor

func StringOf

func StringOf(value string) StringAccessor

func StringOfNil

func StringOfNil(value string) StringAccessor

type Stringifier

type Stringifier interface {
	AnyAccessor
	String() string
}

type TemporalAccessor

type TemporalAccessor interface {
	AnyAccessor
	Comparator
	Stringifier
	Precision() DateTimePrecisions
	LowestPrecision() DateTimePrecisions
	Add(quantity QuantityAccessor) (TemporalAccessor, error)
}

type TimeAccessor

type TimeAccessor interface {
	TemporalAccessor
	Hour() int
	Minute() int
	Second() int
	Nanosecond() int
}

func NewTime

func NewTime(value time.Time) TimeAccessor

func NewTimeHMSN

func NewTimeHMSN(hour int, minute int, second int, nanosecond int) TimeAccessor

func NewTimeHMSNWithPrecision

func NewTimeHMSNWithPrecision(hour, minute, second, nanosecond int, precision DateTimePrecisions) TimeAccessor

func NewTimeHMSNWithPrecisionAndSource

func NewTimeHMSNWithPrecisionAndSource(hour, minute, second int, nanosecond int, precision DateTimePrecisions, source interface{}) TimeAccessor

func NewTimeHMSNWithSource

func NewTimeHMSNWithSource(hour int, minute int, second int, nanosecond int, source interface{}) TimeAccessor

func NewTimeWithSource

func NewTimeWithSource(value time.Time, source interface{}) TimeAccessor

func ParseTime

func ParseTime(value string) (TimeAccessor, error)

func ParseTimeWithSource

func ParseTimeWithSource(value string, source interface{}) (TimeAccessor, error)

type Tracer

type Tracer interface {
	Enabled(name string) bool
	Trace(name string, col ColAccessor)
}

type TupleTypeInfoAccessor

type TupleTypeInfoAccessor interface {
	TypeInfoAccessor
	Element() ColAccessor
}

func NewTupleTypeInfo

func NewTupleTypeInfo(namespace StringAccessor, element ColAccessor) TupleTypeInfoAccessor

type TupleTypeInfoElementAccessor

type TupleTypeInfoElementAccessor interface {
	TypeInfoElementAccessor
}

func NewTupleTypeInfoElement

func NewTupleTypeInfoElement(name StringAccessor, typeName StringAccessor, oneBased BooleanAccessor) TupleTypeInfoElementAccessor

type TypeInfoAccessor

type TypeInfoAccessor interface {
	AnyAccessor
	Namespace() StringAccessor
}

type TypeInfoElementAccessor

type TypeInfoElementAccessor interface {
	AnyAccessor
	Name() StringAccessor
	Type() StringAccessor
	OneBased() BooleanAccessor
}

type TypeSpecAccessor

type TypeSpecAccessor interface {
	Anonymous() bool
	Base() TypeSpecAccessor
	FQName() FQTypeNameAccessor
	FQBaseName() FQTypeNameAccessor
	String() string
	EqualType(other TypeSpecAccessor) bool
	ExtendsName(name FQTypeNameAccessor) bool
}

func ModelTypeSpec

func ModelTypeSpec(adapter ModelAdapter, node interface{}) TypeSpecAccessor

func NewTypeSpec

func NewTypeSpec(fqName FQTypeNameAccessor) TypeSpecAccessor

func NewTypeSpecWithBase

func NewTypeSpecWithBase(fqName FQTypeNameAccessor, base TypeSpecAccessor) TypeSpecAccessor

Jump to

Keyboard shortcuts

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