/
gbinary.go
134 lines (102 loc) · 2.48 KB
/
gbinary.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// Package gbinary provides useful API for handling binary/bytes data.
//
// Note that package gbinary encodes the data using LittleEndian in default.
package gbinary
func Encode(values ...interface{}) []byte {
return LeEncode(values...)
}
func EncodeByLength(length int, values ...interface{}) []byte {
return LeEncodeByLength(length, values...)
}
func Decode(b []byte, values ...interface{}) error {
return LeDecode(b, values...)
}
func EncodeString(s string) []byte {
return LeEncodeString(s)
}
func DecodeToString(b []byte) string {
return LeDecodeToString(b)
}
func EncodeBool(b bool) []byte {
return LeEncodeBool(b)
}
func EncodeInt(i int) []byte {
return LeEncodeInt(i)
}
func EncodeUint(i uint) []byte {
return LeEncodeUint(i)
}
func EncodeInt8(i int8) []byte {
return LeEncodeInt8(i)
}
func EncodeUint8(i uint8) []byte {
return LeEncodeUint8(i)
}
func EncodeInt16(i int16) []byte {
return LeEncodeInt16(i)
}
func EncodeUint16(i uint16) []byte {
return LeEncodeUint16(i)
}
func EncodeInt32(i int32) []byte {
return LeEncodeInt32(i)
}
func EncodeUint32(i uint32) []byte {
return LeEncodeUint32(i)
}
func EncodeInt64(i int64) []byte {
return LeEncodeInt64(i)
}
func EncodeUint64(i uint64) []byte {
return LeEncodeUint64(i)
}
func EncodeFloat32(f float32) []byte {
return LeEncodeFloat32(f)
}
func EncodeFloat64(f float64) []byte {
return LeEncodeFloat64(f)
}
func DecodeToInt(b []byte) int {
return LeDecodeToInt(b)
}
func DecodeToUint(b []byte) uint {
return LeDecodeToUint(b)
}
func DecodeToBool(b []byte) bool {
return LeDecodeToBool(b)
}
func DecodeToInt8(b []byte) int8 {
return LeDecodeToInt8(b)
}
func DecodeToUint8(b []byte) uint8 {
return LeDecodeToUint8(b)
}
func DecodeToInt16(b []byte) int16 {
return LeDecodeToInt16(b)
}
func DecodeToUint16(b []byte) uint16 {
return LeDecodeToUint16(b)
}
func DecodeToInt32(b []byte) int32 {
return LeDecodeToInt32(b)
}
func DecodeToUint32(b []byte) uint32 {
return LeDecodeToUint32(b)
}
func DecodeToInt64(b []byte) int64 {
return LeDecodeToInt64(b)
}
func DecodeToUint64(b []byte) uint64 {
return LeDecodeToUint64(b)
}
func DecodeToFloat32(b []byte) float32 {
return LeDecodeToFloat32(b)
}
func DecodeToFloat64(b []byte) float64 {
return LeDecodeToFloat64(b)
}