Documentation
¶
Index ¶
- Variables
- func BoolToBytes(value bool) byte
- func Concat(slices ...[]byte) []byte
- func Equals(bytes1 []byte, bytes2 []byte) bool
- func Int16ToBytes(value int16) []byte
- func Int32ToBytes(value int32) []byte
- func Int64ToBytes(value int64) []byte
- func Int8ToBytes(value int8) byte
- func IntToBytes(value int) []byte
- func StartsWith(srcBytes []byte, prefixBytes []byte) bool
- func StringToBytes(str string) []byte
- func ToBoolean(b byte) bool
- func ToInt(bys []byte) int
- func ToInt16(b []byte) int16
- func ToInt32(b []byte) int32
- func ToInt64(b []byte) int64
- func ToInt8(b byte) int8
- func ToString(bytes []byte) string
- type Bytes
- func (b *Bytes) Concat(key []byte) *Bytes
- func (b *Bytes) ConcatBytes(key Bytes) *Bytes
- func (b *Bytes) CopyTo(buffer []byte, offset int, size int) int
- func (b *Bytes) Equals(obj interface{}) bool
- func (b *Bytes) GetDirectBytes() []byte
- func (b *Bytes) Size() int
- func (b *Bytes) ToBase58() string
- func (b *Bytes) ToBytes() []byte
- func (b *Bytes) ToString() string
- func (b *Bytes) ToUTF8String() string
- func (b *Bytes) WriteTo(out io.Writer) int
- type BytesSerializable
- type NumberMask
- func (mask *NumberMask) Equals(mask2 NumberMask) bool
- func (mask *NumberMask) GenerateMask(number int64) []byte
- func (mask *NumberMask) GetBoundarySize(headerLength int32) int64
- func (mask *NumberMask) GetMaskLength(number int64) int32
- func (mask *NumberMask) ResolveMaskLength(headByte byte) (int32, error)
- func (mask *NumberMask) ResolveMaskedNumber(markBytes []byte) (int64, error)
- func (mask *NumberMask) WriteMask(number int64) []byte
- type Slice
- func (s Slice) GetByte(offset int) (byte, error)
- func (s Slice) GetBytesCopy(offset, size int) ([]byte, error)
- func (s Slice) GetInt16(offset int) (int16, error)
- func (s Slice) GetInt32(offset int) (int32, error)
- func (s Slice) GetInt64(offset int) (int64, error)
- func (s Slice) GetSlice(offset, size int) (*Slice, error)
- func (s Slice) GetString() string
- func (s Slice) IsEmpty() bool
- func (s Slice) ToBytes() []byte
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EMPTY_BYTES = NewBytes([]byte{}) MAX_CACHE = int32(256) INT32_BYTES [256]Bytes LONG_BYTES [256]Bytes )
View Source
var ( NUMBERMASK_NONE = NumberMask{} NUMBERMASK_TINY = newNumberMask("TINY", 0) // TINY编码 NUMBERMASK_SHORT = newNumberMask("SHORT", 1) // SHORT编码 NUMBERMASK_NORMAL = newNumberMask("NORMAL", 2) // NORMAL编码 NUMBERMASK_LONG = newNumberMask("LONG", 3) // LONG编码 )
View Source
var ( DEFAULT_CHARSET = "UTF-8" MAX_BUFFER_SIZE = 1024 * 1024 * 1024 BUFFER_SIZE = 64 TRUE_BYTE = byte(0x01) FALSE_BYTE = byte(0x00) )
View Source
var EMPTY_SLICE = NewSlice([]byte{})
Functions ¶
func BoolToBytes ¶
func Int16ToBytes ¶
func Int8ToBytes ¶
func IntToBytes ¶
func StartsWith ¶
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
func FromBase58 ¶
func FromString ¶
func NewBytesWithPrefix ¶
func (*Bytes) ConcatBytes ¶
func (*Bytes) ToUTF8String ¶
type BytesSerializable ¶
type BytesSerializable interface { /** * 以字节数组形式获取字节块的副本; * @return byte[] */ ToBytes() []byte }
type NumberMask ¶
type NumberMask struct { Name string // 掩码位的个数 BIT_COUNT byte // 头部长度的最大值 MAX_HEADER_LENGTH int32 // 最大边界值 MAX_BOUNDARY_SIZE int64 // 此常量对于 TINY、SHORT、NORMAL 有效 BOUNDARY_SIZE_0 int64 BOUNDARY_SIZE_1 int64 BOUNDARY_SIZE_2 int64 BOUNDARY_SIZE_3 int64 BOUNDARY_SIZE_4 int64 BOUNDARY_SIZE_5 int64 BOUNDARY_SIZE_6 int64 BOUNDARY_SIZE_7 int64 // contains filtered or unexported fields }
数值掩码;用于以更少的字节空间输出整数的字节数组
func GetNumberMask ¶
func GetNumberMask(name string) NumberMask
func (*NumberMask) Equals ¶
func (mask *NumberMask) Equals(mask2 NumberMask) bool
func (*NumberMask) GenerateMask ¶
func (mask *NumberMask) GenerateMask(number int64) []byte
生成指定数值的掩码 number 要表示的数值;如果值范围超出掩码的有效范围,将引起恐慌
func (*NumberMask) GetBoundarySize ¶
func (mask *NumberMask) GetBoundarySize(headerLength int32) int64
在指定的头部长度下能够表示的数据大小的临界值(不含) headerLength 值范围必须大于 0 ,且小于等于 MAX_HEADER_LENGTH
func (*NumberMask) GetMaskLength ¶
func (mask *NumberMask) GetMaskLength(number int64) int32
获取能够表示指定的数值的掩码长度,即掩码所需的字节数 number 要表示的数值;如果值范围超出掩码的有效范围,将引起恐慌
func (*NumberMask) ResolveMaskLength ¶
func (mask *NumberMask) ResolveMaskLength(headByte byte) (int32, error)
解析掩码的头字节获得该掩码实例的完整长度 headByte 掩码的头字节;即掩码的字节序列的首个字节 返回掩码实例的完整长度 注:在字节流中,对首字节解析获取该值后减 1,可以得到该掩码后续要读取的字节长度
func (*NumberMask) ResolveMaskedNumber ¶
func (mask *NumberMask) ResolveMaskedNumber(markBytes []byte) (int64, error)
从字节中解析掩码表示的数值
func (*NumberMask) WriteMask ¶
func (mask *NumberMask) WriteMask(number int64) []byte
type Slice ¶
Click to show internal directories.
Click to hide internal directories.