-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_int.go
54 lines (50 loc) · 857 Bytes
/
number_int.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 Int(value int) Value {
if value == 0 {
return Zero
} else {
return func(buf *Buffer) (err error) {
buf.AppendInt(value)
return nil
}
}
}
func NullableInt(ref *int) Value {
if ref == nil {
return Null
} else {
return Int(*ref)
}
}
func BindInt(ref *int) Value {
if ref == nil {
return produceError(ErrNilReference)
} else {
return func(buf *Buffer) error {
if *ref == 0 {
buf.AppendByte(valueNumberZero)
} else {
buf.AppendInt(*ref)
}
return nil
}
}
}
func BindNullableInt(ref **int) 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.AppendInt(**ref)
}
}
return nil
}
}
}