Documentation ¶
Index ¶
- Variables
- func Compare(x1 XValue, x2 XValue) int
- func Describe(x XValue) string
- func Equals(x1 XValue, x2 XValue) bool
- func Format(env envs.Environment, x XValue) string
- func IsNil(x XValue) bool
- func IsXError(x XValue) bool
- func Render(x XValue) string
- func SameType(x1 XValue, x2 XValue) bool
- func String(x XValue) string
- func ToXArray(env envs.Environment, x XValue) (*XArray, *XError)
- func ToXBoolean(x XValue) (*XBoolean, *XError)
- func ToXDate(env envs.Environment, x XValue) (*XDate, *XError)
- func ToXDateTime(env envs.Environment, x XValue) (*XDateTime, *XError)
- func ToXDateTimeWithTimeFill(env envs.Environment, x XValue) (*XDateTime, *XError)
- func ToXFunction(x XValue) (*XFunction, *XError)
- func ToXJSON(x XValue) (*XText, *XError)
- func ToXNumber(env envs.Environment, x XValue) (*XNumber, *XError)
- func ToXObject(env envs.Environment, x XValue) (*XObject, *XError)
- func ToXText(env envs.Environment, x XValue) (*XText, *XError)
- func ToXTime(env envs.Environment, x XValue) (*XTime, *XError)
- func Truthy(x XValue) bool
- type XArray
- func (x *XArray) Count() int
- func (x *XArray) Deprecated() string
- func (x *XArray) Describe() string
- func (x *XArray) Equals(o XValue) bool
- func (x *XArray) Format(env envs.Environment) string
- func (x *XArray) Get(index int) XValue
- func (x *XArray) MarshalJSON() ([]byte, error)
- func (x *XArray) Render() string
- func (x *XArray) SetDeprecated(msg string)
- func (x *XArray) String() string
- func (x *XArray) Truthy() bool
- type XBoolean
- func (x *XBoolean) Compare(o XValue) int
- func (x *XBoolean) Deprecated() string
- func (x *XBoolean) Describe() string
- func (x *XBoolean) Equals(o XValue) bool
- func (x *XBoolean) Format(env envs.Environment) string
- func (x *XBoolean) MarshalJSON() ([]byte, error)
- func (x *XBoolean) Native() bool
- func (x *XBoolean) Render() string
- func (x *XBoolean) SetDeprecated(msg string)
- func (x *XBoolean) String() string
- func (x *XBoolean) Truthy() bool
- func (x *XBoolean) UnmarshalJSON(data []byte) error
- type XComparable
- type XCountable
- type XDate
- func (x *XDate) Compare(o XValue) int
- func (x *XDate) Deprecated() string
- func (x *XDate) Describe() string
- func (x *XDate) Equals(o XValue) bool
- func (x *XDate) Format(env envs.Environment) string
- func (x *XDate) FormatCustom(env envs.Environment, layout string) (string, error)
- func (x *XDate) MarshalJSON() ([]byte, error)
- func (x *XDate) Native() dates.Date
- func (x *XDate) Render() string
- func (x *XDate) SetDeprecated(msg string)
- func (x *XDate) String() string
- func (x *XDate) Truthy() bool
- type XDateTime
- func (x *XDateTime) Compare(o XValue) int
- func (x *XDateTime) Date() *XDate
- func (x *XDateTime) Deprecated() string
- func (x *XDateTime) Describe() string
- func (x *XDateTime) Equals(o XValue) bool
- func (x *XDateTime) Format(env envs.Environment) string
- func (x *XDateTime) FormatCustom(env envs.Environment, layout string, tz *time.Location) (string, error)
- func (x *XDateTime) In(tz *time.Location) *XDateTime
- func (x *XDateTime) MarshalJSON() ([]byte, error)
- func (x *XDateTime) Native() time.Time
- func (x *XDateTime) Render() string
- func (x *XDateTime) ReplaceTime(tm *XTime) *XDateTime
- func (x *XDateTime) SetDeprecated(msg string)
- func (x *XDateTime) String() string
- func (x *XDateTime) Time() *XTime
- func (x *XDateTime) Truthy() bool
- func (x *XDateTime) UnmarshalJSON(data []byte) error
- type XError
- func (x *XError) Deprecated() string
- func (x *XError) Describe() string
- func (x *XError) Equals(o XValue) bool
- func (x *XError) Error() string
- func (x *XError) Format(env envs.Environment) string
- func (x *XError) MarshalJSON() ([]byte, error)
- func (x *XError) Native() error
- func (x *XError) Render() string
- func (x *XError) SetDeprecated(msg string)
- func (x *XError) String() string
- func (x *XError) Truthy() bool
- type XFunc
- type XFunction
- func (x *XFunction) Call(env envs.Environment, params []XValue) XValue
- func (x *XFunction) Deprecated() string
- func (x *XFunction) Describe() string
- func (x *XFunction) Equals(o XValue) bool
- func (x *XFunction) Format(env envs.Environment) string
- func (x *XFunction) MarshalJSON() ([]byte, error)
- func (x *XFunction) Name() string
- func (x *XFunction) Render() string
- func (x *XFunction) SetDeprecated(msg string)
- func (x *XFunction) String() string
- func (x *XFunction) Truthy() bool
- type XNumber
- func (x *XNumber) Compare(o XValue) int
- func (x *XNumber) Deprecated() string
- func (x *XNumber) Describe() string
- func (x *XNumber) Equals(o XValue) bool
- func (x *XNumber) Format(env envs.Environment) string
- func (x *XNumber) FormatCustom(format *envs.NumberFormat, places int, groupDigits bool) string
- func (x *XNumber) MarshalJSON() ([]byte, error)
- func (x *XNumber) Native() decimal.Decimal
- func (x *XNumber) Render() string
- func (x *XNumber) SetDeprecated(msg string)
- func (x *XNumber) String() string
- func (x *XNumber) Truthy() bool
- func (x *XNumber) UnmarshalJSON(data []byte) error
- type XObject
- func (x *XObject) Count() int
- func (x *XObject) Default() XValue
- func (x *XObject) Deprecated() string
- func (x *XObject) Describe() string
- func (x *XObject) Equals(o XValue) bool
- func (x *XObject) Format(env envs.Environment) string
- func (x *XObject) Get(key string) (XValue, bool)
- func (x *XObject) MarshalJSON() ([]byte, error)
- func (x *XObject) Properties() []string
- func (x *XObject) Render() string
- func (x *XObject) SetDeprecated(msg string)
- func (x *XObject) SetMarshalOptions(includeDefault, includeDeprecated bool)
- func (x *XObject) String() string
- func (x *XObject) Truthy() bool
- type XText
- func (x *XText) Compare(o XValue) int
- func (x *XText) Deprecated() string
- func (x *XText) Describe() string
- func (x *XText) Empty() bool
- func (x *XText) Equals(o XValue) bool
- func (x *XText) Format(env envs.Environment) string
- func (x *XText) Length() int
- func (x *XText) MarshalJSON() ([]byte, error)
- func (x *XText) Native() string
- func (x *XText) Render() string
- func (x *XText) SetDeprecated(msg string)
- func (x *XText) String() string
- func (x *XText) Truthy() bool
- func (x *XText) UnmarshalJSON(data []byte) error
- type XTime
- func (x *XTime) Compare(o XValue) int
- func (x *XTime) Deprecated() string
- func (x *XTime) Describe() string
- func (x *XTime) Equals(o XValue) bool
- func (x *XTime) Format(env envs.Environment) string
- func (x *XTime) FormatCustom(env envs.Environment, layout string) (string, error)
- func (x *XTime) MarshalJSON() ([]byte, error)
- func (x *XTime) Native() dates.TimeOfDay
- func (x *XTime) Render() string
- func (x *XTime) SetDeprecated(msg string)
- func (x *XTime) String() string
- func (x *XTime) Truthy() bool
- type XValue
Constants ¶
This section is empty.
Variables ¶
var XArrayEmpty = NewXArray()
XArrayEmpty is the empty array
var XBooleanFalse = NewXBoolean(false)
XBooleanFalse is the false boolean value
var XBooleanTrue = NewXBoolean(true)
XBooleanTrue is the true boolean value
var XDateTimeZero = NewXDateTime(envs.ZeroDateTime)
XDateTimeZero is the zero time value
var XDateZero = NewXDate(dates.ZeroDate)
XDateZero is the zero time value
var XNumberZero = NewXNumber(decimal.Zero)
XNumberZero is the zero number value
var XObjectEmpty = NewXObject(map[string]XValue{})
XObjectEmpty is the empty empty
var XTextEmpty = NewXText("")
XTextEmpty is the empty text value
var XTimeZero = NewXTime(dates.ZeroTimeOfDay)
XTimeZero is the zero time value
Functions ¶
func Describe ¶ added in v0.10.1
Describe returns a representation of the given value for use in error messages
func Equals ¶ added in v0.9.4
Equals checks for equality between the two given values. This is only used for testing as x = y specifically means text(x) == text(y)
func Format ¶ added in v0.34.1
func Format(env envs.Environment, x XValue) string
Format returns the pretty text representation
func IsNil ¶ added in v0.202.1
IsNil returns whether the given value is nil... because of golang's love of autoboxing nil pointers into non-nil interfaces, we need to check if interface itself is nil or the underlying pointer is nil.
func String ¶ added in v0.33.8
String returns a representation of the given value for use in debugging
func ToXArray ¶ added in v0.32.0
func ToXArray(env envs.Environment, x XValue) (*XArray, *XError)
ToXArray converts the given value to an array
func ToXBoolean ¶ added in v0.9.4
ToXBoolean converts the given value to a boolean
func ToXDate ¶
func ToXDate(env envs.Environment, x XValue) (*XDate, *XError)
ToXDate converts the given value to a time or returns an error if that isn't possible
func ToXDateTime ¶ added in v0.9.4
func ToXDateTime(env envs.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 envs.Environment, x XValue) (*XDateTime, *XError)
ToXDateTimeWithTimeFill converts the given value to a time or returns an error if that isn't possible
func ToXFunction ¶ added in v0.189.0
ToXFunction converts the given value to a function returns an error if that isn't possible
func ToXNumber ¶
func ToXNumber(env envs.Environment, x XValue) (*XNumber, *XError)
ToXNumber converts the given value to a number or returns an error if that isn't possible
func ToXObject ¶ added in v0.34.0
func ToXObject(env envs.Environment, x XValue) (*XObject, *XError)
ToXObject converts the given value to an object
func ToXText ¶ added in v0.9.0
func ToXText(env envs.Environment, x XValue) (*XText, *XError)
ToXText converts the given value to a string
Types ¶
type XArray ¶
type XArray struct {
// contains filtered or unexported fields
}
XArray is an array of items.
@(array(1, "x", true)) -> [1, x, true] @(array(1, "x", true)[1]) -> x @(count(array(1, "x", true))) -> 3 @(json(array(1, "x", true))) -> [1,"x",true]
@type array
func NewXLazyArray ¶ added in v0.33.8
NewXLazyArray returns a new lazy array with the given source function
func (*XArray) Count ¶ added in v0.34.0
Count is called when the length of this object is requested in an expression
func (*XArray) Deprecated ¶ added in v0.202.0
func (x *XArray) Deprecated() string
func (*XArray) Describe ¶ added in v0.33.8
Describe returns a representation of this type for error messages
func (*XArray) Format ¶ added in v0.34.1
func (x *XArray) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XArray) MarshalJSON ¶ added in v0.33.8
MarshalJSON converts this type to internal JSON
func (*XArray) SetDeprecated ¶ added in v0.202.0
func (x *XArray) SetDeprecated(msg string)
type XBoolean ¶ added in v0.9.0
type XBoolean struct {
// contains filtered or unexported fields
}
XBoolean is a boolean `true` or `false`.
@(true) -> true @(1 = 1) -> true @(1 = 2) -> false @(json(true)) -> true
@type boolean
func NewXBoolean ¶ added in v0.9.0
NewXBoolean creates a new boolean value
func (*XBoolean) Deprecated ¶ added in v0.202.0
func (x *XBoolean) Deprecated() string
func (*XBoolean) Describe ¶ added in v0.10.1
Describe returns a representation of this type for error messages
func (*XBoolean) Format ¶ added in v0.34.1
func (x *XBoolean) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XBoolean) MarshalJSON ¶ added in v0.9.0
MarshalJSON is called when a struct containing this type is marshaled
func (*XBoolean) SetDeprecated ¶ added in v0.202.0
func (x *XBoolean) SetDeprecated(msg string)
func (*XBoolean) String ¶ added in v0.9.0
String returns the native string representation of this type for debugging
func (*XBoolean) UnmarshalJSON ¶ added in v0.9.0
UnmarshalJSON is called when a struct containing this type is unmarshaled
type XComparable ¶ added in v0.139.0
type XComparable interface { // Compare returns -1 if this value is less, 0 if equal, +1 if greater Compare(XValue) int }
XComparable is the interface for types which can be compared
type XCountable ¶ added in v0.34.0
type XCountable interface {
Count() int
}
XCountable is the interface for types which can be counted
type XDate ¶
type XDate struct {
// contains filtered or unexported fields
}
XDate is a Gregorian calendar date value.
@(date_from_parts(2019, 4, 11)) -> 2019-04-11 @(format_date(date_from_parts(2019, 4, 11))) -> 11-04-2019 @(json(date_from_parts(2019, 4, 11))) -> "2019-04-11"
@type date
func (*XDate) Deprecated ¶ added in v0.202.0
func (x *XDate) Deprecated() string
func (*XDate) Describe ¶ added in v0.28.4
Describe returns a representation of this type for error messages
func (*XDate) Format ¶ added in v0.34.1
func (x *XDate) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XDate) FormatCustom ¶ added in v0.34.1
FormatCustom provides customised formatting
func (*XDate) MarshalJSON ¶
MarshalJSON is called when a struct containing this type is marshaled
func (*XDate) SetDeprecated ¶ added in v0.202.0
func (x *XDate) SetDeprecated(msg string)
type XDateTime ¶ added in v0.9.0
type XDateTime struct {
// contains filtered or unexported fields
}
XDateTime is a datetime value.
@(datetime("1979-07-18T10:30:45.123456Z")) -> 1979-07-18T10:30:45.123456Z @(format_datetime(datetime("1979-07-18T10:30:45.123456Z"))) -> 18-07-1979 05:30 @(json(datetime("1979-07-18T10:30:45.123456Z"))) -> "1979-07-18T10:30:45.123456Z"
@type datetime
func NewXDateTime ¶ added in v0.9.0
NewXDateTime creates a new date
func (*XDateTime) Deprecated ¶ added in v0.202.0
func (x *XDateTime) Deprecated() string
func (*XDateTime) Describe ¶ added in v0.10.1
Describe returns a representation of this type for error messages
func (*XDateTime) Format ¶ added in v0.34.1
func (x *XDateTime) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XDateTime) FormatCustom ¶ added in v0.34.1
func (x *XDateTime) FormatCustom(env envs.Environment, layout string, tz *time.Location) (string, error)
FormatCustom provides customised formatting
func (*XDateTime) MarshalJSON ¶ added in v0.9.0
MarshalJSON is called when a struct containing this type is marshaled
func (*XDateTime) ReplaceTime ¶ added in v0.28.0
ReplaceTime returns the a new date time with the time part replaced by the given time
func (*XDateTime) SetDeprecated ¶ added in v0.202.0
func (x *XDateTime) SetDeprecated(msg string)
func (*XDateTime) String ¶ added in v0.9.0
String returns the native string representation of this type
func (*XDateTime) UnmarshalJSON ¶ added in v0.9.0
UnmarshalJSON is called when a struct containing this type is unmarshaled
type XError ¶
type XError struct {
// contains filtered or unexported fields
}
XError is an error
func ToInteger ¶
func ToInteger(env envs.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
func (*XError) Deprecated ¶ added in v0.202.0
func (x *XError) Deprecated() string
func (*XError) Describe ¶ added in v0.202.0
Describe returns a representation of this type for error messages
func (*XError) Format ¶ added in v0.202.0
func (x *XError) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XError) MarshalJSON ¶ added in v0.202.0
MarshalJSON converts this type to JSON
func (*XError) SetDeprecated ¶ added in v0.202.0
func (x *XError) SetDeprecated(msg string)
type XFunction ¶ added in v0.32.0
type XFunction struct {
// contains filtered or unexported fields
}
XFunction is a callable function.
@(upper) -> upper @(array(upper)[0]("abc")) -> ABC @(json(upper)) -> null
@type function
func NewXFunction ¶ added in v0.141.0
NewXFunction creates a new XFunction
func (*XFunction) Call ¶ added in v0.141.0
func (x *XFunction) Call(env envs.Environment, params []XValue) XValue
func (*XFunction) Deprecated ¶ added in v0.202.0
func (x *XFunction) Deprecated() string
func (*XFunction) Describe ¶ added in v0.32.0
Describe returns a representation of this type for error messages
func (*XFunction) Format ¶ added in v0.34.1
func (x *XFunction) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XFunction) MarshalJSON ¶ added in v0.33.8
MarshalJSON converts this type to JSON
func (*XFunction) SetDeprecated ¶ added in v0.202.0
func (x *XFunction) SetDeprecated(msg string)
type XNumber ¶
type XNumber struct {
// contains filtered or unexported fields
}
XNumber is a whole or fractional number.
@(1234) -> 1234 @(1234.5678) -> 1234.5678 @(format_number(1234.5670)) -> 1,234.567 @(json(1234.5678)) -> 1234.5678
@type number
func NewXNumberFromInt ¶
NewXNumberFromInt creates a new XNumber from the given int
func NewXNumberFromInt64 ¶
NewXNumberFromInt64 creates a new XNumber from the given int
func RequireXNumberFromString ¶
RequireXNumberFromString creates a new XNumber from the given string or panics (used for tests)
func (*XNumber) Deprecated ¶ added in v0.202.0
func (x *XNumber) Deprecated() string
func (*XNumber) Describe ¶ added in v0.10.1
Describe returns a representation of this type for error messages
func (*XNumber) Format ¶ added in v0.34.1
func (x *XNumber) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XNumber) FormatCustom ¶ added in v0.34.1
FormatCustom provides customised formatting
func (*XNumber) MarshalJSON ¶
MarshalJSON is called when a struct containing this type is marshaled
func (*XNumber) SetDeprecated ¶ added in v0.202.0
func (x *XNumber) SetDeprecated(msg string)
func (*XNumber) UnmarshalJSON ¶
UnmarshalJSON is called when a struct containing this type is unmarshaled
type XObject ¶ added in v0.34.0
type XObject struct {
// contains filtered or unexported fields
}
XObject is an object with named properties.
@(object("foo", 1, "bar", "x")) -> {bar: x, foo: 1} @(object("foo", 1, "bar", "x").bar) -> x @(object("foo", 1, "bar", "x")["bar"]) -> x @(count(object("foo", 1, "bar", "x"))) -> 2 @(json(object("foo", 1, "bar", "x"))) -> {"bar":"x","foo":1}
@type object
func NewXLazyObject ¶ added in v0.34.0
NewXLazyObject returns a new lazy object with the source function and default
func NewXObject ¶ added in v0.34.0
NewXObject returns a new object with the given properties
func ReadXObject ¶ added in v0.44.0
ReadXObject reads an instance of this type from JSON
func (*XObject) Count ¶ added in v0.34.0
Count is called when the length of this object is requested in an expression
func (*XObject) Deprecated ¶ added in v0.202.0
func (x *XObject) Deprecated() string
func (*XObject) Describe ¶ added in v0.34.0
Describe returns a representation of this type for error messages
func (*XObject) Format ¶ added in v0.34.1
func (x *XObject) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XObject) MarshalJSON ¶ added in v0.34.0
MarshalJSON converts this type to internal JSON
func (*XObject) Properties ¶ added in v0.37.0
Properties returns the sorted property names of this object
func (*XObject) SetDeprecated ¶ added in v0.202.0
func (x *XObject) SetDeprecated(msg string)
func (*XObject) SetMarshalOptions ¶ added in v0.205.0
type XText ¶ added in v0.9.0
type XText struct {
// contains filtered or unexported fields
}
XText is a string of characters.
@("abc") -> abc @(text_length("abc")) -> 3 @(upper("abc")) -> ABC @(json("abc")) -> "abc"
@type text
func (*XText) Deprecated ¶ added in v0.202.0
func (x *XText) Deprecated() string
func (*XText) Describe ¶ added in v0.10.1
Describe returns a representation of this type for error messages
func (*XText) Format ¶ added in v0.34.1
func (x *XText) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XText) MarshalJSON ¶ added in v0.9.0
MarshalJSON is called when a struct containing this type is marshaled
func (*XText) SetDeprecated ¶ added in v0.202.0
func (x *XText) SetDeprecated(msg string)
func (*XText) String ¶ added in v0.9.0
String returns the native string representation of this type for debugging
func (*XText) UnmarshalJSON ¶ added in v0.9.0
UnmarshalJSON is called when a struct containing this type is unmarshaled
type XTime ¶ added in v0.28.0
type XTime struct {
// contains filtered or unexported fields
}
XTime is a time of day.
@(time_from_parts(16, 30, 45)) -> 16:30:45.000000 @(format_time(time_from_parts(16, 30, 45))) -> 16:30 @(json(time_from_parts(16, 30, 45))) -> "16:30:45.000000"
@type time
func (*XTime) Deprecated ¶ added in v0.202.0
func (x *XTime) Deprecated() string
func (*XTime) Describe ¶ added in v0.28.0
Describe returns a representation of this type for error messages
func (*XTime) Format ¶ added in v0.34.1
func (x *XTime) Format(env envs.Environment) string
Format returns the pretty text representation
func (*XTime) FormatCustom ¶ added in v0.34.1
FormatCustom provides customised formatting
func (*XTime) MarshalJSON ¶ added in v0.33.8
MarshalJSON is called when a struct containing this type is marshaled
func (*XTime) SetDeprecated ¶ added in v0.202.0
func (x *XTime) SetDeprecated(msg string)
type XValue ¶
type XValue interface { // How type is rendered in console for debugging fmt.Stringer // How the type JSONifies json.Marshaler // Describe returns a representation for use in error messages Describe() string // Truthy determines truthiness for this type Truthy() bool // Render returns the canonical text representation Render() string // Format returns the pretty text representation Format(env envs.Environment) string // Equals returns true if this value is equal to the given value Equals(XValue) bool // Deprecated returns whether this value is considered deprecated Deprecated() string // Marks this value as considered deprecated SetDeprecated(string) }
XValue is the base interface of all excellent types
func JSONToXValue ¶
JSONToXValue returns an X type from the given JSON