param

package
v0.0.0-...-e8b1e36 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToJSON

func ToJSON(params ValueMap) (string, error)

func Truncate

func Truncate(s string, maxLength int) string

Types

type Filters

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

func MakeFilters

func MakeFilters(strings []string) (*Filters, error)

func (*Filters) Matches

func (fs *Filters) Matches(obj ValueGetter) (bool, error)

func (*Filters) SetExclusive

func (fs *Filters) SetExclusive(name string, operator Operator, value Value)

SetExclusive sets a filter exclusively, deleting any previous filters with that name

type Operator

type Operator int
const (
	OperatorEqual Operator = iota
	OperatorNotEqual
	OperatorGreaterThan
	OperatorGreaterOrEqual
	OperatorLessThan
	OperatorLessOrEqual
)

type Sorter

type Sorter struct {
	Key        string
	Descending bool
}

func NewSorter

func NewSorter(sortString string) *Sorter

func (*Sorter) LessThan

func (s *Sorter) LessThan(x ValueGetter, y ValueGetter) bool

type Type

type Type string
const (
	TypeInt    Type = "int"
	TypeFloat  Type = "float"
	TypeString Type = "string"
	TypeBool   Type = "bool"
	TypeObject Type = "object"
	TypeNone   Type = "none"

	// hack in nan, +inf and -inf since json doesn't support
	// them natively.
	JsonNaN              = `"[NaN]"`
	JsonPositiveInfinity = `"[+Infinity]"`
	JsonNegativeInfinity = `"[-Infinity]"`
)

type Value

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

func Bool

func Bool(v bool) Value

func Float

func Float(v float64) Value

func Int

func Int(v int64) Value

func None

func None() Value

func Object

func Object(v interface{}) Value

func ParseFromString

func ParseFromString(s string) Value

ParseFromString attempts to turn a string passed to a filter into a value. They aren't valid JSON because they're provided by a human (strings might not have quotes, etc).

func String

func String(v string) Value

func (Value) BoolVal

func (v Value) BoolVal() bool

func (Value) Equal

func (v Value) Equal(other Value) (bool, error)

func (Value) FloatVal

func (v Value) FloatVal() float64

func (Value) GreaterOrEqual

func (v Value) GreaterOrEqual(other Value) (bool, error)

func (Value) GreaterThan

func (v Value) GreaterThan(other Value) (bool, error)

func (Value) IntVal

func (v Value) IntVal() int64

func (Value) IsNone

func (v Value) IsNone() bool

func (Value) LessOrEqual

func (v Value) LessOrEqual(other Value) (bool, error)

func (Value) LessThan

func (v Value) LessThan(other Value) (bool, error)

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

func (Value) NotEqual

func (v Value) NotEqual(other Value) (bool, error)

func (Value) ObjectVal

func (v Value) ObjectVal() interface{}

func (Value) PythonString

func (v Value) PythonString() string

func (Value) ShortString

func (v Value) ShortString(maxLength int, precision int) string

ShortString returns a shorter version of the string, useful for displaying in the user interface when there isn't much space

Small floats will be truncated to precision decimal points. Big floats will be truncated to maxLength Strings will be truncated to maxLength. Everything else is just default.

TODO: some interesting stuff could be done with color here (e.g. "..." and "none" could be dimmed) so maybe this should be lifted out into a generic shortener in the console package.

func (Value) String

func (v Value) String() string

func (Value) StringVal

func (v Value) StringVal() string

func (Value) Type

func (v Value) Type() Type

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(data []byte) error

Note that unlike everywhere else, this function uses a pointer for v. This is because this function needs to modify the struct in place.

type ValueGetter

type ValueGetter interface {
	GetValue(name string) Value
}

type ValueMap

type ValueMap map[string]Value

func FromJSON

func FromJSON(j string) (ValueMap, error)

func (*ValueMap) UnmarshalJSON

func (m *ValueMap) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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