kmgType

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateTimeReflectType = reflect.TypeOf((*time.Time)(nil)).Elem()

Functions

func IsEnumExist

func IsEnumExist(enum StringEnum) bool

func IsEnumExistString

func IsEnumExistString(enum StringEnum, s string) bool

Types

type ArrayType

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

path -> array index(number)

func (*ArrayType) DeleteByPath

func (t *ArrayType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (*ArrayType) GetElemByString

func (t *ArrayType) GetElemByString(v reflect.Value, k string) (ev reflect.Value, et KmgType, err error)

func (ArrayType) GetReflectType

func (t ArrayType) GetReflectType() reflect.Type

func (ArrayType) SaveByPath

func (t ArrayType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

type BoolType

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

func (BoolType) DeleteByPath

func (t BoolType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (BoolType) FromString

func (t BoolType) FromString(value string) (reflect.Value, error)

func (BoolType) GetReflectType

func (t BoolType) GetReflectType() reflect.Type

func (BoolType) SaveByPath

func (t BoolType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

func (*BoolType) SaveScale

func (t *BoolType) SaveScale(v reflect.Value, value string) error

func (*BoolType) ToString

func (t *BoolType) ToString(v reflect.Value) string

type Context

type Context struct {
	RootType  KmgType
	RootValue reflect.Value
}

func NewContext

func NewContext(ptr interface{}) (*Context, error)

func (*Context) DeleteByPath

func (m *Context) DeleteByPath(path Path) (err error)

func (*Context) GetElemByPath

func (m *Context) GetElemByPath(p Path) (v reflect.Value, t KmgType, err error)

func (*Context) SaveByPath

func (m *Context) SaveByPath(path Path, value string) (err error)

type DateTimeType

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

func (DateTimeType) DeleteByPath

func (t DateTimeType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (DateTimeType) FromString

func (t DateTimeType) FromString(value string) (reflect.Value, error)

func (DateTimeType) GetReflectType

func (t DateTimeType) GetReflectType() reflect.Type

func (DateTimeType) SaveByPath

func (t DateTimeType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

func (*DateTimeType) SaveScale

func (t *DateTimeType) SaveScale(v reflect.Value, value string) error

func (*DateTimeType) ToString

func (t *DateTimeType) ToString(v reflect.Value) string

type EditableByPathInterface

type EditableByPathInterface interface {
	// v must not be nil, v.IsValid must be true
	// every type must consider reflect.Value.CanSet()
	// every type in the path except least one(include ptr),must eat a path.
	// try best to create all path, if it is not exist.
	// if this value can set its own value,set it,if this value can not set its own value,replace v with a new value
	SaveByPath(v *reflect.Value, path Path, value string) (err error)
	DeleteByPath(v *reflect.Value, path Path) (err error)
}

type FloatType

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

func (FloatType) DeleteByPath

func (t FloatType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (FloatType) FromString

func (t FloatType) FromString(value string) (reflect.Value, error)

func (FloatType) GetReflectType

func (t FloatType) GetReflectType() reflect.Type

func (FloatType) SaveByPath

func (t FloatType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

func (*FloatType) SaveScale

func (t *FloatType) SaveScale(v reflect.Value, value string) error

func (*FloatType) ToString

func (t *FloatType) ToString(v reflect.Value) string

type FromStringInterface

type FromStringInterface interface {
	FromString(s string) (reflect.Value, error)
}

type GetElemByStringAndReflectTypeGetterInterface

type GetElemByStringAndReflectTypeGetterInterface interface {
	GetElemByStringInterface
	ReflectTypeGetter
}

type GetElemByStringInterface

type GetElemByStringInterface interface {
	GetElemByString(v reflect.Value, k string) (reflect.Value, KmgType, error)
}

array slice struct map

type IntType

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

func (IntType) DeleteByPath

func (t IntType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (IntType) FromString

func (t IntType) FromString(value string) (reflect.Value, error)

func (IntType) GetReflectType

func (t IntType) GetReflectType() reflect.Type

func (IntType) SaveByPath

func (t IntType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

func (*IntType) SaveScale

func (t *IntType) SaveScale(v reflect.Value, value string) error

func (*IntType) ToString

func (t *IntType) ToString(v reflect.Value) string

type KmgType

type KmgType interface {
	EditableByPathInterface
	ReflectTypeGetter
}

func TypeOf

func TypeOf(rt reflect.Type) (KmgType, error)

type KmgTypeAndToStringInterface

type KmgTypeAndToStringInterface interface {
	KmgType
	ToStringInterface
}

type MapType

type MapType struct {
	KeyStringConverter StringConverterInterface
	KeyType            KmgType
	ElemType           KmgType
	// contains filtered or unexported fields
}

path -> key(Key type) key can be bool,string,stringEnum,int,float, map elem CanSet() will be false even if map CanSet false , SetMapIndex will success if elem change(can not set),map must use SetMapIndex to set it..

func (*MapType) DeleteByPath

func (t *MapType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (*MapType) GetElemByString

func (t *MapType) GetElemByString(v reflect.Value, k string) (ev reflect.Value, et KmgType, err error)

func (MapType) GetReflectType

func (t MapType) GetReflectType() reflect.Type

func (*MapType) Init

func (t *MapType) Init() (err error)

func (*MapType) SaveByPath

func (t *MapType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

type Path

type Path []string

a path to a type in whole type system

func ParsePath

func ParsePath(ps string) Path

func (Path) String

func (p Path) String() string

type PtrType

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

path -> pass to RefType

func (*PtrType) DeleteByPath

func (t *PtrType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (*PtrType) GetElemByString

func (t *PtrType) GetElemByString(v reflect.Value, k string) (ev reflect.Value, et KmgType, err error)

func (PtrType) GetReflectType

func (t PtrType) GetReflectType() reflect.Type

func (*PtrType) SaveByPath

func (t *PtrType) SaveByPath(inV *reflect.Value, path Path, value string) error

type ReflectTypeGetter

type ReflectTypeGetter interface {
	GetReflectType() reflect.Type
}

type SaveScaleInterface

type SaveScaleInterface interface {
	SaveScale(v reflect.Value, value string) error
}

bool datetime fkref float int string stringEnum

type SliceType

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

path -> slice index(number)

func (*SliceType) DeleteByPath

func (t *SliceType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (*SliceType) GetElemByString

func (t *SliceType) GetElemByString(v reflect.Value, k string) (ev reflect.Value, et KmgType, err error)

func (SliceType) GetReflectType

func (t SliceType) GetReflectType() reflect.Type

func (*SliceType) SaveByPath

func (t *SliceType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

type StringConverterInterface

type StringConverterInterface interface {
	FromStringInterface
	ToStringInterface
}

type StringEnum

type StringEnum interface {
	GetEnumList() []string //GetEnumList get all list of this type enum ,should only depend on type
}

type StringType

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

func (StringType) DeleteByPath

func (t StringType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (StringType) FromString

func (t StringType) FromString(value string) (reflect.Value, error)

func (StringType) GetReflectType

func (t StringType) GetReflectType() reflect.Type

func (StringType) SaveByPath

func (t StringType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

func (*StringType) SaveScale

func (t *StringType) SaveScale(v reflect.Value, value string) error

func (*StringType) ToString

func (t *StringType) ToString(v reflect.Value) string

type StructType

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

path -> field name TODO embed field

func (*StructType) DeleteByPath

func (t *StructType) DeleteByPath(v *reflect.Value, path Path) (err error)

func (*StructType) GetElemByString

func (t *StructType) GetElemByString(v reflect.Value, k string) (ev reflect.Value, et KmgType, err error)

func (StructType) GetReflectType

func (t StructType) GetReflectType() reflect.Type

func (StructType) SaveByPath

func (t StructType) SaveByPath(v *reflect.Value, path Path, value string) (err error)

type ToStringInterface

type ToStringInterface interface {
	ToString(v reflect.Value) string //is caller responsibility to ensure v is callee Type
}

Jump to

Keyboard shortcuts

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