2017-08-04 08:20:59 +00:00
|
|
|
package hotime
|
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
2017-08-04 08:20:59 +00:00
|
|
|
|
|
|
|
type Slice []interface{}
|
|
|
|
|
|
|
|
//获取string
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetString(key int, err ...*Error) string {
|
|
|
|
if len(err) != 0 {
|
2017-08-04 08:20:59 +00:00
|
|
|
err[0].SetError(nil)
|
|
|
|
}
|
|
|
|
return ObjToStr((this)[key])
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取Int
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetInt(key int, err ...*Error) int {
|
|
|
|
v := ObjToInt((this)[key], err...)
|
2017-08-04 08:20:59 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取Int
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetInt64(key int, err ...*Error) int64 {
|
|
|
|
v := ObjToInt64((this)[key], err...)
|
2017-08-04 08:20:59 +00:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-01-23 18:08:25 +00:00
|
|
|
//获取向上取整Int64
|
|
|
|
func (this Slice) GetCeilInt64(key int, err ...*Error) int64 {
|
|
|
|
v := ObjToCeilInt64((this)[key], err...)
|
|
|
|
return v
|
|
|
|
|
|
|
|
}
|
|
|
|
//获取向上取整Int
|
|
|
|
func (this Slice) GetCeilInt(key int, err ...*Error) int {
|
|
|
|
v := ObjToCeilInt((this)[key], err...)
|
|
|
|
return v
|
|
|
|
|
2018-01-28 17:30:47 +00:00
|
|
|
}
|
|
|
|
//获取向上取整float64
|
|
|
|
func (this Slice) GetCeilFloat64(key int, err ...*Error) float64 {
|
|
|
|
v := ObjToCeilFloat64((this)[key], err...)
|
|
|
|
return v
|
|
|
|
|
2018-01-23 18:08:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-04 08:20:59 +00:00
|
|
|
//获取Float64
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetFloat64(key int, err ...*Error) float64 {
|
|
|
|
v := ObjToFloat64((this)[key], err...)
|
2017-08-04 08:20:59 +00:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetSlice(key int, err ...*Error) Slice {
|
|
|
|
v := ObjToSlice((this)[key], err...)
|
2017-08-04 08:20:59 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) GetMap(key int, err ...*Error) Map {
|
2017-08-04 08:20:59 +00:00
|
|
|
//var v Map
|
2017-09-05 07:36:10 +00:00
|
|
|
v := ObjToMap((this)[key], err...)
|
2017-08-04 08:20:59 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) Get(key int, err ...*Error) interface{} {
|
2017-08-04 08:20:59 +00:00
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
if key < len(this) {
|
2017-08-04 08:20:59 +00:00
|
|
|
return this[key]
|
|
|
|
}
|
2017-09-05 07:36:10 +00:00
|
|
|
e := errors.New("没有存储key及对应的数据")
|
|
|
|
if len(err) != 0 {
|
2017-08-04 08:20:59 +00:00
|
|
|
err[0].SetError(e)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-09-05 07:36:10 +00:00
|
|
|
func (this Slice) Put(key int, value interface{}) {
|
|
|
|
this[key] = value
|
2017-08-04 08:20:59 +00:00
|
|
|
}
|
|
|
|
|
2017-10-24 01:31:20 +00:00
|
|
|
func (this Slice) ToJsonString() string {
|
2017-08-04 08:20:59 +00:00
|
|
|
return ObjToStr(this)
|
|
|
|
}
|