-
Notifications
You must be signed in to change notification settings - Fork 1
/
set.go
87 lines (75 loc) · 2.18 KB
/
set.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
package enc
func (e *Encoder) setByte1Int64(value int64, offset int) int {
e.d[offset] = byte(value)
return offset + 1
}
func (e *Encoder) setByte2Int64(value int64, offset int) int {
e.d[offset+0] = byte(value >> 8)
e.d[offset+1] = byte(value)
return offset + 2
}
func (e *Encoder) setByte4Int64(value int64, offset int) int {
e.d[offset+0] = byte(value >> 24)
e.d[offset+1] = byte(value >> 16)
e.d[offset+2] = byte(value >> 8)
e.d[offset+3] = byte(value)
return offset + 4
}
func (e *Encoder) setByte8Int64(value int64, offset int) int {
e.d[offset] = byte(value >> 56)
e.d[offset+1] = byte(value >> 48)
e.d[offset+2] = byte(value >> 40)
e.d[offset+3] = byte(value >> 32)
e.d[offset+4] = byte(value >> 24)
e.d[offset+5] = byte(value >> 16)
e.d[offset+6] = byte(value >> 8)
e.d[offset+7] = byte(value)
return offset + 8
}
func (e *Encoder) setByte1Uint64(value uint64, offset int) int {
e.d[offset] = byte(value)
return offset + 1
}
func (e *Encoder) setByte2Uint64(value uint64, offset int) int {
e.d[offset] = byte(value >> 8)
e.d[offset+1] = byte(value)
return offset + 2
}
func (e *Encoder) setByte4Uint64(value uint64, offset int) int {
e.d[offset] = byte(value >> 24)
e.d[offset+1] = byte(value >> 16)
e.d[offset+2] = byte(value >> 8)
e.d[offset+3] = byte(value)
return offset + 4
}
func (e *Encoder) setByte8Uint64(value uint64, offset int) int {
e.d[offset] = byte(value >> 56)
e.d[offset+1] = byte(value >> 48)
e.d[offset+2] = byte(value >> 40)
e.d[offset+3] = byte(value >> 32)
e.d[offset+4] = byte(value >> 24)
e.d[offset+5] = byte(value >> 16)
e.d[offset+6] = byte(value >> 8)
e.d[offset+7] = byte(value)
return offset + 8
}
func (e *Encoder) setByte1Int(code, offset int) int {
e.d[offset] = byte(code)
return offset + 1
}
func (e *Encoder) setByte2Int(value int, offset int) int {
e.d[offset] = byte(value >> 8)
e.d[offset+1] = byte(value)
return offset + 2
}
func (e *Encoder) setByte4Int(value int, offset int) int {
e.d[offset] = byte(value >> 24)
e.d[offset+1] = byte(value >> 16)
e.d[offset+2] = byte(value >> 8)
e.d[offset+3] = byte(value)
return offset + 4
}
func (e *Encoder) setByte(b byte, offset int) int {
e.d[offset] = b
return offset + 1
}