value

package
v0.0.0-...-55990d1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeUnknown = Type("")

Functions

This section is empty.

Types

type Coordinates

type Coordinates []LatLngHeight

func CoordinatesFrom

func CoordinatesFrom(coords []float64) Coordinates

CoordinatesFrom generates a new Coordinates from slice such as [lon, lat, alt, lon, lat, alt, ...]

func (Coordinates) String

func (c Coordinates) String() string

type LatLng

type LatLng struct {
	Lat float64 `json:"lat" mapstructure:"lat"`
	Lng float64 `json:"lng" mapstructure:"lng"`
}

func (*LatLng) Clone

func (l *LatLng) Clone() *LatLng

func (LatLng) String

func (l LatLng) String() string

type LatLngHeight

type LatLngHeight struct {
	Lat    float64 `json:"lat" mapstructure:"lat"`
	Lng    float64 `json:"lng" mapstructure:"lng"`
	Height float64 `json:"height" mapstructure:"height"`
}

func (*LatLngHeight) Clone

func (l *LatLngHeight) Clone() *LatLngHeight

func (LatLngHeight) String

func (l LatLngHeight) String() string

type Optional

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

func NewOptional

func NewOptional(t Type, v *Value) *Optional

func OptionalFrom

func OptionalFrom(v *Value) *Optional

func (*Optional) Cast

func (ov *Optional) Cast(t Type, p TypePropertyMap) *Optional

Cast tries to convert the value to the new type and generates a new Optional.

func (*Optional) Clone

func (ov *Optional) Clone() *Optional

func (*Optional) SetValue

func (ov *Optional) SetValue(v *Value)

func (*Optional) Type

func (ov *Optional) Type() Type

func (*Optional) TypeAndValue

func (ov *Optional) TypeAndValue() (Type, *Value)

func (*Optional) Value

func (ov *Optional) Value() *Value

type Polygon

type Polygon []Coordinates

func PolygonFrom

func PolygonFrom(rings [][]float64) Polygon

func (Polygon) String

func (p Polygon) String() string

type Rect

type Rect struct {
	West  float64 `json:"west" mapstructure:"west"`
	South float64 `json:"south" mapstructure:"south"`
	East  float64 `json:"east" mapstructure:"east"`
	North float64 `json:"north" mapstructure:"north"`
}

func (Rect) String

func (r Rect) String() string

type Type

type Type string
var TypeArray Type = "array"
var TypeBool Type = "bool"
var TypeCoordinates Type = "coordinates"
var TypeLatLng Type = "latlng"
var TypeLatLngHeight Type = "latlngheight"
var TypeNumber Type = "number"
var TypePolygon Type = "polygon"
var TypeRect Type = "rect"
var TypeRef Type = "ref"
var TypeString Type = "string"
var TypeURL Type = "url"

func (Type) Default

func (t Type) Default() bool

func (Type) JSONSchema

func (vt Type) JSONSchema(p TypePropertyMap) map[string]any

func (Type) None

func (t Type) None() *Optional

func (Type) ValueFrom

func (t Type) ValueFrom(i interface{}, p TypePropertyMap) *Value

type TypeProperty

type TypeProperty interface {
	I2V(interface{}) (interface{}, bool)
	V2I(interface{}) (interface{}, bool)
	Validate(interface{}) bool
	String(any) string
	JSONSchema() map[string]any
}

type TypePropertyMap

type TypePropertyMap = map[Type]TypeProperty

type Value

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

func (*Value) Cast

func (v *Value) Cast(t Type, p TypePropertyMap) *Value

func (*Value) Clone

func (v *Value) Clone() *Value

func (*Value) Interface

func (v *Value) Interface() interface{}

Interface converts the value into generic representation

func (*Value) IsEmpty

func (v *Value) IsEmpty() bool

func (*Value) MarshalJSON

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

func (*Value) Some

func (v *Value) Some() *Optional

func (*Value) String

func (v *Value) String() string

func (*Value) Type

func (v *Value) Type() Type

func (*Value) TypeProperty

func (v *Value) TypeProperty() (tp TypeProperty)

func (*Value) Validate

func (v *Value) Validate() bool

func (*Value) Value

func (v *Value) Value() interface{}

func (*Value) ValueArray

func (v *Value) ValueArray() (vv []any, ok bool)

func (*Value) ValueBool

func (v *Value) ValueBool() (vv bool, ok bool)

func (*Value) ValueCoordinates

func (v *Value) ValueCoordinates() (vv Coordinates, ok bool)

func (*Value) ValueLatLng

func (v *Value) ValueLatLng() (vv LatLng, ok bool)

func (*Value) ValueLatLngHeight

func (v *Value) ValueLatLngHeight() (vv LatLngHeight, ok bool)

func (*Value) ValueNumber

func (v *Value) ValueNumber() (vv float64, ok bool)

func (*Value) ValuePolygon

func (v *Value) ValuePolygon() (vv Polygon, ok bool)

func (*Value) ValueRect

func (v *Value) ValueRect() (vv Rect, ok bool)

func (*Value) ValueRef

func (v *Value) ValueRef() (vv string, ok bool)

func (*Value) ValueString

func (v *Value) ValueString() (vv string, ok bool)

func (*Value) ValueURL

func (v *Value) ValueURL() (vv *url.URL, ok bool)

Jump to

Keyboard shortcuts

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