iedc-go/obj.go
2017-08-23 02:05:47 +00:00

57 lines
967 B
Go

package hotime
//对象封装方便取用
type Obj struct {
Data interface{}
baseContext
}
func (this *Obj) Put(data interface{}) {
this.Data = data
}
func (this *Obj) ToInt(err ...Error) int {
if len(err) != 0 {
this.Error = err[0]
}
return ObjToInt(this.Data, &this.Error)
}
func (this *Obj) ToInt64(err ...Error) int64 {
if len(err) != 0 {
this.Error = err[0]
}
return ObjToInt64(this.Data, &this.Error)
}
func (this *Obj) ToFloat64(err ...Error) float64 {
if len(err) != 0 {
this.Error = err[0]
}
return ObjToFloat64(this.Data, &this.Error)
}
func (this *Obj) ToStr() string {
return ObjToStr(this.Data)
}
func (this *Obj) ToMap(err ...Error) Map {
if len(err) != 0 {
this.Error = err[0]
}
return ObjToMap(this.Data, &this.Error)
}
func (this *Obj) ToSlice(err ...Error) Slice {
if len(err) != 0 {
this.Error = err[0]
}
return ObjToSlice(this.Data, &this.Error)
}
func (this *Obj) ToObj() interface{} {
return this.Data
}