-
Notifications
You must be signed in to change notification settings - Fork 4
/
marker.go
64 lines (51 loc) · 1.18 KB
/
marker.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
package ubjson
// A Marker is a single byte UBJSON marker.
type Marker byte
func (m Marker) String() string {
return string(m)
}
// Value Type Markers
const (
NullMarker Marker = 'Z'
NoOpMarker Marker = 'N'
TrueMarker Marker = 'T'
FalseMarker Marker = 'F'
UInt8Marker Marker = 'U'
Int8Marker Marker = 'i'
Int16Marker Marker = 'I'
Int32Marker Marker = 'l'
Int64Marker Marker = 'L'
Float32Marker Marker = 'd'
Float64Marker Marker = 'D'
HighPrecNumMarker Marker = 'H'
CharMarker Marker = 'C'
StringMarker Marker = 'S'
)
// Container Types Markers
const (
ArrayStartMarker Marker = '['
ObjectStartMarker Marker = '{'
)
// Container Meta-Markers
const (
arrayEndMarker Marker = ']'
objectEndMarker Marker = '}'
countMarker Marker = '#'
typeMarker Marker = '$'
)
// The smallestIntMarker function returns the Marker for the smallest integer
// into which v will fit.
func smallestIntMarker(v int64) Marker {
switch {
case v >= 0 && v <= 255:
return UInt8Marker
case v <= 127 && v >= -128:
return Int8Marker
case v <= 32767 && v >= -32768:
return Int16Marker
case v <= 2147483647 && v >= -2147483648:
return Int32Marker
default:
return Int64Marker
}
}