types

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolValue

type BoolValue struct {
	V bool
}

BoolValue is a literal boolean value.

func (BoolValue) Equals

func (v BoolValue) Equals(q Value) bool

func (BoolValue) LessThan

func (v BoolValue) LessThan(q Value) bool

func (BoolValue) String

func (v BoolValue) String() string

func (BoolValue) Value

func (v BoolValue) Value() interface{}

type CollectionValue

type CollectionValue interface {
	Value
	Contains(Value) bool
	Elements() []Value
}

type FloatValue

type FloatValue struct {
	V float64
}

FloatValue is a literal floating point value.

func (FloatValue) Equals

func (v FloatValue) Equals(q Value) bool

func (FloatValue) LessThan

func (v FloatValue) LessThan(q Value) bool

func (FloatValue) String

func (v FloatValue) String() string

func (FloatValue) Value

func (v FloatValue) Value() interface{}

type Inferrer

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

Inferrer is used to infer data types from string representations and retrieve the coresponding appropriately-typed Value.

func (Inferrer) CollectionReferences

func (i Inferrer) CollectionReferences(enabled bool) Inferrer

CollectionReferences allows the Infer method to identify map (options["foo"]) and list references (arg[0]), returning MapElementValue and ListElementValue values, respectively. An argument that isn't a string or integer will cause an error to be returned (unless strict strings is false).

func (Inferrer) ComplexTypes

func (i Inferrer) ComplexTypes(enabled bool) Inferrer

Setting ComplexTypes is a helper function that enables the Infer method to identify literal lists ([ "foo", "bar" ]), collection references (options["foo"]), and regular expressions (/^foo$/).

func (Inferrer) Infer

func (i Inferrer) Infer(str string) (Value, error)

Infer accepts a string, attempts to determine its type, and based on the outcome returns an appropriate Value value. if strictStrings is true unquoted values that aren't obviously another type will return an error; if not then they will be treated as strings with a "quote flavor" of null ('\u0000). If basicsTypes is set then only the "basic" types (bool, float, int, string) will be returned.

func (Inferrer) InferAll

func (i Inferrer) InferAll(strs []string) ([]Value, error)

func (Inferrer) LiteralLists

func (i Inferrer) LiteralLists(enabled bool) Inferrer

LiteralLists allows the Infer method to infer list literals (["foo, "bar"]). Lists may include regular expressions, but may not include other complex types.

func (Inferrer) RegularExpressions

func (i Inferrer) RegularExpressions(enabled bool) Inferrer

RegularExpressions allows regular expressions (/^foo$/) to be inferred.

func (Inferrer) StrictStrings

func (i Inferrer) StrictStrings(enabled bool) Inferrer

StrictStrings requires strings to be wrapped in single or double quotes (smart quotes are automatically converted to double quotes), and unknown values are returned as an UnknownValue. If not set, unquoted values that aren't clearly recognizable as another type are returned as StringValue values with a Quote value of \u0000 (null character).

type IntValue

type IntValue struct {
	V int
}

IntValue is a literal integer value.

func (IntValue) Equals

func (v IntValue) Equals(q Value) bool

func (IntValue) LessThan

func (v IntValue) LessThan(q Value) bool

func (IntValue) String

func (v IntValue) String() string

func (IntValue) Value

func (v IntValue) Value() interface{}

type ListElementValue

type ListElementValue struct {
	V     ListValue
	Index int
}

ListElementValue

func (ListElementValue) Equals

func (v ListElementValue) Equals(q Value) bool

func (ListElementValue) LessThan

func (v ListElementValue) LessThan(q Value) bool

func (ListElementValue) String

func (v ListElementValue) String() string

func (ListElementValue) Value

func (v ListElementValue) Value() interface{}

type ListValue

type ListValue struct {
	V    []Value
	Name string
}

ListValue

func (ListValue) Contains

func (v ListValue) Contains(q Value) bool

func (ListValue) Elements

func (v ListValue) Elements() []Value

func (ListValue) Equals

func (v ListValue) Equals(q Value) bool

func (ListValue) LessThan

func (v ListValue) LessThan(q Value) bool

func (ListValue) String

func (v ListValue) String() string

func (ListValue) Value

func (v ListValue) Value() interface{}

type MapElementValue

type MapElementValue struct {
	V   MapValue
	Key string
}

MapElementValue

func (MapElementValue) Equals

func (v MapElementValue) Equals(q Value) bool

func (MapElementValue) LessThan

func (v MapElementValue) LessThan(q Value) bool

func (MapElementValue) String

func (v MapElementValue) String() string

func (MapElementValue) Value

func (v MapElementValue) Value() interface{}

type MapValue

type MapValue struct {
	V    map[string]Value
	Name string
}

MapValue

func (MapValue) Contains

func (v MapValue) Contains(q Value) bool

Contains returns true if q is a StringValue and that key exists in the map.

func (MapValue) Elements

func (v MapValue) Elements() []Value

func (MapValue) Equals

func (v MapValue) Equals(q Value) bool

func (MapValue) LessThan

func (v MapValue) LessThan(q Value) bool

func (MapValue) String

func (v MapValue) String() string

func (MapValue) Value

func (v MapValue) Value() interface{}

type NullValue

type NullValue struct{}

NullValue

func (NullValue) Equals

func (v NullValue) Equals(q Value) bool

func (NullValue) LessThan

func (v NullValue) LessThan(q Value) bool

func (NullValue) String

func (v NullValue) String() string

func (NullValue) Value

func (v NullValue) Value() interface{}

type RegexValue

type RegexValue struct {
	V string
}

RegexValue describes a regular expression.

func (RegexValue) Equals

func (v RegexValue) Equals(q Value) bool

func (RegexValue) LessThan

func (v RegexValue) LessThan(q Value) bool

func (RegexValue) Pattern

func (v RegexValue) Pattern() (*regexp.Regexp, error)

func (RegexValue) String

func (v RegexValue) String() string

func (RegexValue) Value

func (v RegexValue) Value() interface{}

type StringValue

type StringValue struct {
	V     string
	Quote rune
}

StringValue is a literal string value.

func (StringValue) Equals

func (v StringValue) Equals(q Value) bool

func (StringValue) LessThan

func (v StringValue) LessThan(q Value) bool

func (StringValue) String

func (v StringValue) String() string

func (StringValue) Value

func (v StringValue) Value() interface{}

type UnknownValue

type UnknownValue struct {
	V string
}

UnknownValue is returned by Parse when it can't determine a value type solely by looking at it. This could indicate a function, named collection(arg, option), or other named entity.

func (UnknownValue) Equals

func (v UnknownValue) Equals(q Value) bool

func (UnknownValue) LessThan

func (v UnknownValue) LessThan(q Value) bool

func (UnknownValue) String

func (v UnknownValue) String() string

func (UnknownValue) Value

func (v UnknownValue) Value() interface{}

type Value

type Value interface {
	Equals(Value) bool
	LessThan(Value) bool
	Value() interface{}
	String() string
}

Jump to

Keyboard shortcuts

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