types

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilXError = NewXError(nil)

NilXError is the nil error value

View Source
var XBooleanFalse = NewXBoolean(false)

XBooleanFalse is the false boolean value

View Source
var XBooleanTrue = NewXBoolean(true)

XBooleanTrue is the true boolean value

View Source
var XDateTimeZero = NewXDateTime(time.Time{})

XDateTimeZero is the zero time value

View Source
var XNumberZero = NewXNumber(decimal.Zero)

XNumberZero is the zero number value

View Source
var XTextEmpty = NewXText("")

XTextEmpty is the empty text value

Functions

func Describe added in v0.10.1

func Describe(x XValue) string

Describe returns a representation of the given value for use in error messages

func Equals added in v0.9.4

func Equals(env utils.Environment, x1 XValue, x2 XValue) bool

Equals checks for equality between the two give values

func IsEmpty added in v0.9.2

func IsEmpty(x XValue) bool

IsEmpty determines if the given value is empty

func IsXError

func IsXError(x XValue) bool

IsXError returns whether the given value is an error value

func ToXBoolean added in v0.9.4

func ToXBoolean(env utils.Environment, x XValue) (XBoolean, XError)

ToXBoolean converts the given value to a boolean

func ToXDateTime added in v0.9.4

func ToXDateTime(env utils.Environment, x XValue) (XDateTime, XError)

ToXDateTime converts the given value to a time or returns an error if that isn't possible

func ToXDateTimeWithTimeFill added in v0.15.1

func ToXDateTimeWithTimeFill(env utils.Environment, x XValue) (XDateTime, XError)

ToXDateTimeWithTimeFill converts the given value to a time or returns an error if that isn't possible

func ToXJSON

func ToXJSON(env utils.Environment, x XValue) (XText, XError)

ToXJSON converts the given value to a JSON string

func ToXNumber

func ToXNumber(env utils.Environment, x XValue) (XNumber, XError)

ToXNumber converts the given value to a number or returns an error if that isn't possible

func ToXText added in v0.9.0

func ToXText(env utils.Environment, x XValue) (XText, XError)

ToXText converts the given value to a string

Types

type XArray

type XArray interface {
	XPrimitive
	XIndexable

	Append(XValue)
}

XArray is an array primitive in Excellent expressions

func NewXArray

func NewXArray(values ...XValue) XArray

NewXArray returns a new array with the given items

type XBoolean added in v0.9.0

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

XBoolean is a boolean true or false

func NewXBoolean added in v0.9.0

func NewXBoolean(value bool) XBoolean

NewXBoolean creates a new boolean value

func (XBoolean) Compare added in v0.9.0

func (x XBoolean) Compare(other XBoolean) int

Compare compares this bool to another

func (XBoolean) Describe added in v0.10.1

func (x XBoolean) Describe() string

Describe returns a representation of this type for error messages

func (XBoolean) Equals added in v0.9.4

func (x XBoolean) Equals(other XBoolean) bool

Equals determines equality for this type

func (XBoolean) MarshalJSON added in v0.9.0

func (x XBoolean) MarshalJSON() ([]byte, error)

MarshalJSON is called when a struct containing this type is marshaled

func (XBoolean) Native added in v0.9.0

func (x XBoolean) Native() bool

Native returns the native value of this type

func (XBoolean) Reduce added in v0.9.0

func (x XBoolean) Reduce(env utils.Environment) XPrimitive

Reduce returns the primitive version of this type (i.e. itself)

func (XBoolean) String added in v0.9.0

func (x XBoolean) String() string

String returns the native string representation of this type

func (XBoolean) ToXBoolean added in v0.9.0

func (x XBoolean) ToXBoolean(env utils.Environment) XBoolean

ToXBoolean converts this type to a bool

func (XBoolean) ToXJSON added in v0.9.0

func (x XBoolean) ToXJSON(env utils.Environment) XText

ToXJSON is called when this type is passed to @(json(...))

func (XBoolean) ToXText added in v0.9.0

func (x XBoolean) ToXText(env utils.Environment) XText

ToXText converts this type to text

func (*XBoolean) UnmarshalJSON added in v0.9.0

func (x *XBoolean) UnmarshalJSON(data []byte) error

UnmarshalJSON is called when a struct containing this type is unmarshaled

type XDateTime added in v0.9.0

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

XDateTime is a datetime value

func NewXDateTime added in v0.9.0

func NewXDateTime(value time.Time) XDateTime

NewXDateTime creates a new date

func (XDateTime) Compare added in v0.9.0

func (x XDateTime) Compare(other XDateTime) int

Compare compares this date to another

func (XDateTime) Describe added in v0.10.1

func (x XDateTime) Describe() string

Describe returns a representation of this type for error messages

func (XDateTime) Equals added in v0.9.4

func (x XDateTime) Equals(other XDateTime) bool

Equals determines equality for this type

func (XDateTime) MarshalJSON added in v0.9.0

func (x XDateTime) MarshalJSON() ([]byte, error)

MarshalJSON is called when a struct containing this type is marshaled

func (XDateTime) Native added in v0.9.0

func (x XDateTime) Native() time.Time

Native returns the native value of this type

func (XDateTime) Reduce added in v0.9.0

func (x XDateTime) Reduce(env utils.Environment) XPrimitive

Reduce returns the primitive version of this type (i.e. itself)

func (XDateTime) String added in v0.9.0

func (x XDateTime) String() string

String returns the native string representation of this type

func (XDateTime) ToXBoolean added in v0.9.0

func (x XDateTime) ToXBoolean(env utils.Environment) XBoolean

ToXBoolean converts this type to a bool

func (XDateTime) ToXJSON added in v0.9.0

func (x XDateTime) ToXJSON(env utils.Environment) XText

ToXJSON is called when this type is passed to @(json(...))

func (XDateTime) ToXText added in v0.9.0

func (x XDateTime) ToXText(env utils.Environment) XText

ToXText converts this type to text

func (*XDateTime) UnmarshalJSON added in v0.9.0

func (x *XDateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON is called when a struct containing this type is unmarshaled

type XError

type XError interface {
	error
	XPrimitive
	Equals(XError) bool
}

XError is an error

func NewXError

func NewXError(err error) XError

NewXError creates a new XError

func NewXErrorf

func NewXErrorf(format string, a ...interface{}) XError

NewXErrorf creates a new XError

func NewXResolveError

func NewXResolveError(resolvable XResolvable, key string) XError

NewXResolveError creates a new XError when a key can't be resolved on an XResolvable

func ToInteger

func ToInteger(env utils.Environment, x XValue) (int, XError)

ToInteger tries to convert the passed in value to an integer or returns an error if that isn't possible

type XIndexable

type XIndexable interface {
	XLengthable

	Index(index int) XValue
}

XIndexable is the interface for types which can be indexed into, e.g. foo.0. Such objects also need to be lengthable so that the engine knows what is a valid index and what isn't.

type XJSON

type XJSON []byte

XJSON is the base type for XJSONObject and XJSONArray

func (XJSON) MarshalJSON

func (x XJSON) MarshalJSON() ([]byte, error)

func (XJSON) Reduce

func (x XJSON) Reduce(env utils.Environment) XPrimitive

func (XJSON) String

func (x XJSON) String() string

String converts this type to native string

func (XJSON) ToXJSON

func (x XJSON) ToXJSON(env utils.Environment) XText

type XJSONArray

type XJSONArray struct {
	XJSON
}

func NewXJSONArray

func NewXJSONArray(data []byte) XJSONArray

func (XJSONArray) Describe added in v0.10.1

func (x XJSONArray) Describe() string

Describe returns a representation of this type for error messages

func (XJSONArray) Index

func (x XJSONArray) Index(index int) XValue

func (XJSONArray) Length

func (x XJSONArray) Length() int

type XJSONObject

type XJSONObject struct {
	XJSON
}

func NewXJSONObject

func NewXJSONObject(data []byte) XJSONObject

func (XJSONObject) Describe added in v0.10.1

func (x XJSONObject) Describe() string

Describe returns a representation of this type for error messages

func (XJSONObject) Length

func (x XJSONObject) Length() int

func (XJSONObject) Resolve

func (x XJSONObject) Resolve(env utils.Environment, key string) XValue

type XLengthable

type XLengthable interface {
	Length() int
}

XLengthable is the interface for types which have a length

type XMap

type XMap interface {
	XPrimitive
	XResolvable
	XLengthable

	Put(string, XValue)
	Keys() []string
}

XMap is a map primitive in Excellent expressions

func NewEmptyXMap added in v0.9.4

func NewEmptyXMap() XMap

NewEmptyXMap returns a new empty map

func NewXMap

func NewXMap(values map[string]XValue) XMap

NewXMap returns a new map with the given items

func ResolveKeys

func ResolveKeys(env utils.Environment, resolvable XResolvable, keys ...string) XMap

ResolveKeys is a utility function that resolves multiple keys on an XResolvable and returns the results as a map

type XNumber

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

XNumber is any whole or fractional number

func NewXNumber

func NewXNumber(value decimal.Decimal) XNumber

NewXNumber creates a new XNumber

func NewXNumberFromInt

func NewXNumberFromInt(value int) XNumber

NewXNumberFromInt creates a new XNumber from the given int

func NewXNumberFromInt64

func NewXNumberFromInt64(value int64) XNumber

NewXNumberFromInt64 creates a new XNumber from the given int

func RequireXNumberFromString

func RequireXNumberFromString(value string) XNumber

RequireXNumberFromString creates a new XNumber from the given string

func (XNumber) Compare

func (x XNumber) Compare(other XNumber) int

Compare compares this number to another

func (XNumber) Describe added in v0.10.1

func (x XNumber) Describe() string

Describe returns a representation of this type for error messages

func (XNumber) Equals

func (x XNumber) Equals(other XNumber) bool

Equals determines equality for this type

func (XNumber) MarshalJSON

func (x XNumber) MarshalJSON() ([]byte, error)

MarshalJSON is called when a struct containing this type is marshaled

func (XNumber) Native

func (x XNumber) Native() decimal.Decimal

Native returns the native value of this type

func (XNumber) Reduce

func (x XNumber) Reduce(env utils.Environment) XPrimitive

Reduce returns the primitive version of this type (i.e. itself)

func (XNumber) String

func (x XNumber) String() string

String returns the native string representation of this type

func (XNumber) ToXBoolean added in v0.9.0

func (x XNumber) ToXBoolean(env utils.Environment) XBoolean

ToXBoolean converts this type to a bool

func (XNumber) ToXJSON

func (x XNumber) ToXJSON(env utils.Environment) XText

ToXJSON is called when this type is passed to @(json(...))

func (XNumber) ToXText added in v0.9.0

func (x XNumber) ToXText(env utils.Environment) XText

ToXText converts this type to text

func (*XNumber) UnmarshalJSON

func (x *XNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON is called when a struct containing this type is unmarshaled

type XPrimitive

type XPrimitive interface {
	XValue
	fmt.Stringer

	ToXText(env utils.Environment) XText
	ToXBoolean(env utils.Environment) XBoolean
}

XPrimitive is the base interface of all Excellent primitive types

func Reduce added in v0.16.0

func Reduce(env utils.Environment, x XValue) XPrimitive

type XResolvable

type XResolvable interface {
	Resolve(env utils.Environment, key string) XValue
}

XResolvable is the interface for types which can be keyed into, e.g. foo.bar

type XText added in v0.9.0

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

XText is a simple tex value

func MustMarshalToXText added in v0.9.0

func MustMarshalToXText(x interface{}) XText

MustMarshalToXText calls json.Marshal in the given value and panics in the case of an error

func NewXText added in v0.9.0

func NewXText(value string) XText

NewXText creates a new text value

func (XText) Compare added in v0.9.0

func (x XText) Compare(other XText) int

Compare compares this string to another

func (XText) Describe added in v0.10.1

func (x XText) Describe() string

Describe returns a representation of this type for error messages

func (XText) Empty added in v0.9.0

func (x XText) Empty() bool

Empty returns whether this is an empty string

func (XText) Equals added in v0.9.0

func (x XText) Equals(other XText) bool

Equals determines equality for this type

func (XText) Length added in v0.9.0

func (x XText) Length() int

Length returns the length of this string

func (XText) MarshalJSON added in v0.9.0

func (x XText) MarshalJSON() ([]byte, error)

MarshalJSON is called when a struct containing this type is marshaled

func (XText) Native added in v0.9.0

func (x XText) Native() string

Native returns the native value of this type

func (XText) Reduce added in v0.9.0

func (x XText) Reduce(env utils.Environment) XPrimitive

Reduce returns the primitive version of this type (i.e. itself)

func (XText) String added in v0.9.0

func (x XText) String() string

String returns the native string representation of this type

func (XText) ToXBoolean added in v0.9.0

func (x XText) ToXBoolean(env utils.Environment) XBoolean

ToXBoolean converts this type to a bool

func (XText) ToXJSON added in v0.9.0

func (x XText) ToXJSON(env utils.Environment) XText

ToXJSON is called when this type is passed to @(json(...))

func (XText) ToXText added in v0.9.0

func (x XText) ToXText(env utils.Environment) XText

ToXText converts this type to text

func (*XText) UnmarshalJSON added in v0.9.0

func (x *XText) UnmarshalJSON(data []byte) error

UnmarshalJSON is called when a struct containing this type is unmarshaled

type XValue

type XValue interface {
	Describe() string
	ToXJSON(env utils.Environment) XText
	Reduce(env utils.Environment) XPrimitive
}

XValue is the base interface of all Excellent types

func JSONToXValue

func JSONToXValue(data []byte) XValue

Jump to

Keyboard shortcuts

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