-
Notifications
You must be signed in to change notification settings - Fork 1
/
value.go
95 lines (73 loc) · 1.48 KB
/
value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package reflekt
import (
"reflect"
"github.com/davecgh/go-spew/spew"
)
type (
Value struct {
v interface{}
r *reflect.Value
}
)
func NewValue(v interface{}) *Value {
return &Value{v: v}
}
func (this *Value) Dump() string {
return spew.Sdump(this.v)
}
func (this *Value) Set(v interface{}) {
this.v = v
this.r = nil
}
func (this *Value) Reflect() *reflect.Value {
if this.r == nil {
r := reflect.ValueOf(this.v)
this.r = &r
}
return this.r
}
func (this *Value) Interface() interface{} {
return this.v
}
func (this *Value) Interfaces() []interface{} {
return AsInterfaces(this.v)
}
func (this *Value) InterfaceMap() map[string]interface{} {
return AsInterfaceMap(this.v)
}
func (this *Value) Int() int {
return AsInt(this.v)
}
func (this *Value) Ints() []int {
return AsInts(this.v)
}
func (this *Value) IntMap() map[string]int {
return AsIntMap(this.v)
}
func (this *Value) Float() float64 {
return AsFloat(this.v)
}
func (this *Value) Floats() []float64 {
return AsFloats(this.v)
}
func (this *Value) FloatMap() map[string]float64 {
return AsFloatMap(this.v)
}
func (this *Value) Bool() bool {
return AsBool(this.v)
}
func (this *Value) Bools() []bool {
return AsBools(this.v)
}
func (this *Value) BoolMap() map[string]bool {
return AsBoolMap(this.v)
}
func (this *Value) String() string {
return AsString(this.v)
}
func (this *Value) Strings() []string {
return AsStrings(this.v)
}
func (this *Value) StringMap() map[string]string {
return AsStringMap(this.v)
}