-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_uint.go
54 lines (50 loc) · 869 Bytes
/
number_uint.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
package pjn
func Uint(value uint) Value {
if value == 0 {
return Zero
} else {
return func(buf *Buffer) (err error) {
buf.AppendUint(value)
return nil
}
}
}
func NullableUint(ref *uint) Value {
if ref == nil {
return Null
} else {
return Uint(*ref)
}
}
func BindUint(ref *uint) Value {
if ref == nil {
return produceError(ErrNilReference)
} else {
return func(buf *Buffer) error {
if *ref == 0 {
buf.AppendByte(valueNumberZero)
} else {
buf.AppendUint(*ref)
}
return nil
}
}
}
func BindNullableUint(ref **uint) Value {
if ref == nil {
return produceError(ErrNilReference)
} else {
return func(buf *Buffer) error {
if *ref == nil {
buf.AppendBytes(valueNull)
} else {
if **ref == 0 {
buf.AppendByte(valueNumberZero)
} else {
buf.AppendUint(**ref)
}
}
return nil
}
}
}