-
Notifications
You must be signed in to change notification settings - Fork 1
/
params.go
46 lines (36 loc) · 949 Bytes
/
params.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
package mpack
type Params struct {
raw *Map
}
func NewParams(generic interface{}) *Params {
result := new(Params)
args := NewArray(generic)
result.raw = NewMap(args.Item(0))
return result
}
func (p Params) Version() uint64 {
v, present := p.raw.UintIndex("version")
if !present {
return 0
}
return v
}
// XXX this is pretty dumb...should be able to embed Map in this type???
func (p Params) IntIndex(key interface{}) (int64, bool) {
return p.raw.IntIndex(key)
}
func (p Params) Int32Index(key interface{}) (int32, bool) {
return p.raw.Int32Index(key)
}
func (p Params) UintIndex(key interface{}) (uint64, bool) {
return p.raw.UintIndex(key)
}
func (p Params) FloatIndex(key interface{}) (float64, bool) {
return p.raw.FloatIndex(key)
}
func (p Params) StringIndex(key interface{}) (string, bool) {
return p.raw.StringIndex(key)
}
func (p Params) ArrayIndex(key interface{}) (*Array, bool) {
return p.raw.ArrayIndex(key)
}