heavyfishdesign: github.com/dustismo/heavyfishdesign/dynmap Index | Files

package dynmap

import "github.com/dustismo/heavyfishdesign/dynmap"


Package Files

dynmap.go sort.go typecast.go

func IsDynMapConvertable Uses

func IsDynMapConvertable(value interface{}) bool

Returns true if the given value is a map, dynmap, DynMaper or pointer of one of those types

func Less Uses

func Less(val1, val2 interface{}) bool

big sort func.

func MustBool Uses

func MustBool(value interface{}, def bool) bool

func MustInt Uses

func MustInt(value interface{}, def int) int

func MustString Uses

func MustString(value interface{}, def string) string

func PrettyJSON Uses

func PrettyJSON(obj interface{}) string

attempts to convert the passed in object to a dynmap then JSON, ignoring any errors

func Sort Uses

func Sort(vals []DynMap, sortCol string)

func ToArray Uses

func ToArray(value interface{}) ([]interface{}, bool)

convert the object into an array if possible

func ToBool Uses

func ToBool(value interface{}) (bool, error)

func ToFloat64 Uses

func ToFloat64(value interface{}) (f float64, err error)

func ToInt Uses

func ToInt(value interface{}) (int, error)

func ToInt64 Uses

func ToInt64(value interface{}) (i int64, err error)

func ToMap Uses

func ToMap(value interface{}) (map[string]interface{}, bool)

attempts to convert the given value to a map. returns

func ToSortVal Uses

func ToSortVal(value interface{}) (interface{}, int)

cleans up to one of the types we know about, attempting to convert: the conversion here is not as aggressive as the above methods. Will deference any pointers but strings will not be attempted to be parsed dynmap time int64 bool string

integer returned is the sort order, so bool < int < string < time < map

func ToString Uses

func ToString(value interface{}) string

func ToTime Uses

func ToTime(value interface{}) (tm time.Time, err error)

parse time

type DynMap Uses

type DynMap struct {
    Map map[string]interface{} `bson:",inline"`

Dont make this a map type, since we want the option of extending this and adding members.

func Convert Uses

func Convert(obj interface{}) (*DynMap, error)

creates a dynmap from the passed in object, if possible

func New Uses

func New() *DynMap

Creates a new dynmap

func ParseJSON Uses

func ParseJSON(json string) (*DynMap, error)

func ToDynMap Uses

func ToDynMap(value interface{}) (*DynMap, bool)

func Wrap Uses

func Wrap(mp map[string]interface{}) *DynMap

func (DynMap) AddToSlice Uses

func (this DynMap) AddToSlice(key string, mp ...interface{}) error

Adds the item to a slice

func (DynMap) AddToSliceWithDot Uses

func (this DynMap) AddToSliceWithDot(key string, mp ...interface{}) error

Adds the item to a slice

func (*DynMap) Clone Uses

func (dm *DynMap) Clone() *DynMap

Recursive clone

func (DynMap) Contains Uses

func (this DynMap) Contains(key string) bool

func (DynMap) ContainsAll Uses

func (this DynMap) ContainsAll(keys ...string) bool

func (DynMap) ContainsDynMap Uses

func (this DynMap) ContainsDynMap(key string) bool

func (DynMap) ContainsString Uses

func (this DynMap) ContainsString(key string) bool

func (*DynMap) ConvertTo Uses

func (this *DynMap) ConvertTo(val interface{}) error

Attempts to fill the given struct with the values contained in this dynmap.

func (*DynMap) Exists Uses

func (this *DynMap) Exists(key string) bool

func (*DynMap) Flatten Uses

func (this *DynMap) Flatten() map[string]interface{}

flattens this dynmap into a one level map where all keys use the dot operator, and values are not maps (primitives or objects) arrays and slices are indexed by integer for instance key1: ["v1", "v2"] => key1.0:v1, key1.1:v2 Note that the slice syntax is not supported yet by PutWithDot so flattened keys cannot be automatically used to recreate the nested map (todo)

func (*DynMap) Get Uses

func (this *DynMap) Get(key string) (interface{}, bool)

Get's the value. will honor the dot operator if needed. key = 'map.map2' will first attempt to matche the literal key 'map.map2' if no value is present it will look for a sub map at key 'map'

func (DynMap) GetBool Uses

func (this DynMap) GetBool(key string) (bool, bool)

func (DynMap) GetDynMap Uses

func (this DynMap) GetDynMap(key string) (*DynMap, bool)

Gets a dynmap from the requested. This will update the value in the map if the value was not already a dynmap.

func (DynMap) GetDynMapSlice Uses

func (this DynMap) GetDynMapSlice(key string) ([]*DynMap, bool)

gets a slice of dynmaps

func (DynMap) GetFloat64 Uses

func (this DynMap) GetFloat64(key string) (float64, bool)

func (DynMap) GetInt Uses

func (this DynMap) GetInt(key string) (int, bool)

func (DynMap) GetInt64 Uses

func (this DynMap) GetInt64(key string) (int64, bool)

Gets the value at the specified key as an int64. returns -1,false if value not available or is not convertable

func (DynMap) GetIntSlice Uses

func (this DynMap) GetIntSlice(key string) ([]int, bool)

Returns a slice of ints

func (DynMap) GetIntSliceSplit Uses

func (this DynMap) GetIntSliceSplit(key, delim string) ([]int, bool)

gets a slice of ints. if the value is a string it will split by the requested delimiter

func (DynMap) GetString Uses

func (this DynMap) GetString(key string) (string, bool)

Gets a string representation of the value at key

func (DynMap) GetStringSlice Uses

func (this DynMap) GetStringSlice(key string) ([]string, bool)

Returns a slice of strings

func (DynMap) GetStringSliceSplit Uses

func (this DynMap) GetStringSliceSplit(key, delim string) ([]string, bool)

gets a slice of strings. if the value is a string it will split by the requested delimiter

func (DynMap) GetTime Uses

func (this DynMap) GetTime(key string) (time.Time, bool)

func (*DynMap) IsEmpty Uses

func (this *DynMap) IsEmpty() bool

func (*DynMap) Length Uses

func (this *DynMap) Length() int

func (DynMap) MarshalJSON Uses

func (this DynMap) MarshalJSON() ([]byte, error)

func (*DynMap) MarshalUrl Uses

func (this *DynMap) MarshalUrl() (string, error)

encodes this map into a url encoded string. maps are encoded in the rails style (key[key2][key2]=value) TODO: we should sort the keynames so ordering is consistent and then this can be used a cache key

func (*DynMap) Merge Uses

func (this *DynMap) Merge(mp *DynMap) *DynMap

recursively merges the requested dynmap into the current dynmap returns self in order to support chaining.

func (*DynMap) Must Uses

func (this *DynMap) Must(key string, def interface{}) interface{}

func (DynMap) MustBool Uses

func (this DynMap) MustBool(key string, def bool) bool

func (DynMap) MustDynMap Uses

func (this DynMap) MustDynMap(key string, def *DynMap) *DynMap

func (DynMap) MustDynMapSlice Uses

func (this DynMap) MustDynMapSlice(key string, def []*DynMap) []*DynMap

func (DynMap) MustFloat64 Uses

func (this DynMap) MustFloat64(key string, def float64) float64

func (DynMap) MustInt Uses

func (this DynMap) MustInt(key string, def int) int

func (DynMap) MustInt64 Uses

func (this DynMap) MustInt64(key string, def int64) int64

func (DynMap) MustString Uses

func (this DynMap) MustString(key string, def string) string

gets a string. if string is not available in the map, then the default is returned

func (DynMap) MustStringSlice Uses

func (this DynMap) MustStringSlice(key string, def []string) []string

func (DynMap) MustTime Uses

func (this DynMap) MustTime(key string, def time.Time) time.Time

func (*DynMap) Put Uses

func (this *DynMap) Put(key string, value interface{})

Put's a value into the map

func (*DynMap) PutAll Uses

func (this *DynMap) PutAll(mp interface{}) bool

puts all the values from the passed in map into this dynmap the passed in map must be convertable to a DynMap via ToDynMap. returns false if the passed value is not convertable to dynmap

func (*DynMap) PutIfAbsent Uses

func (this *DynMap) PutIfAbsent(key string, value interface{}) (interface{}, bool)

Puts the value into the map if and only if no value exists at the specified key. This does not honor the dot operator on insert.

func (*DynMap) PutIfAbsentWithDot Uses

func (this *DynMap) PutIfAbsentWithDot(key string, value interface{}) (interface{}, bool)

Same as PutIfAbsent but honors the dot operator

func (*DynMap) PutWithDot Uses

func (this *DynMap) PutWithDot(key string, value interface{}) error

puts the value into the map, honoring the dot operator. so PutWithDot("map1.map2.value", 100) would result in: {

map1 : { map2 : { value: 100 }}


func (*DynMap) Remove Uses

func (this *DynMap) Remove(key string) (interface{}, bool)

Remove a mapping

func (*DynMap) RemoveAll Uses

func (dm *DynMap) RemoveAll(key ...string)

func (*DynMap) ToDynMap Uses

func (this *DynMap) ToDynMap() *DynMap

Returns self. Here so that we satisfy the DynMaper interface

func (DynMap) ToJSON Uses

func (this DynMap) ToJSON() string

converts to indented json, throws away any errors this is useful for logging purposes. MarshalJSON should be used for most uses.

func (*DynMap) ToMap Uses

func (this *DynMap) ToMap() map[string]interface{}

Recursively converts this to a regular go map. (will convert any sub maps)

func (*DynMap) UnFlatten Uses

func (dm *DynMap) UnFlatten() (*DynMap, error)

Takes any dot operator keys and makes nested maps returns a new DynMap instance

func (*DynMap) UnmarshalJSON Uses

func (this *DynMap) UnmarshalJSON(bytes []byte) error

func (*DynMap) UnmarshalUrl Uses

func (this *DynMap) UnmarshalUrl(urlstring string) error

Unmarshals a url encoded string. will also parse rails style maps in the form key[key1][key2]=val

func (*DynMap) UnmarshalUrlValues Uses

func (this *DynMap) UnmarshalUrlValues(values url.Values) error

Unmarshals url.Values into the map. Will correctly handle rails style maps in the form key[key1][key2]=val

type DynMapSlice Uses

type DynMapSlice struct {
    // contains filtered or unexported fields

func NewDynMapSlice Uses

func NewDynMapSlice(vals []DynMap, sortCol string) DynMapSlice

func (DynMapSlice) Len Uses

func (dms DynMapSlice) Len() int

func (DynMapSlice) Less Uses

func (dms DynMapSlice) Less(i, j int) bool

func (DynMapSlice) Swap Uses

func (dms DynMapSlice) Swap(i, j int)

type DynMaper Uses

type DynMaper interface {
    ToDynMap() *DynMap

Package dynmap imports 11 packages (graph) and is imported by 6 packages. Updated 2020-06-16. Refresh now. Tools for package owners.