bytes

package
v0.0.0-...-e9436ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBuffOverflow = fmt.Errorf("剩余的缓存空间不足")

Functions

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

*

  • 拼接byte数组

func BytesToString

func BytesToString(p []byte) string

*

  • []byte转string
  • string(byteVar[:]) 由于golang中并不是像C一样遇到'\0'就自动结尾,所以需要手工转换一下

Types

type BigEndianStreamImpl

type BigEndianStreamImpl struct {
	// contains filtered or unexported fields
}

func NewBigEndianStream

func NewBigEndianStream(buff []byte) *BigEndianStreamImpl

func (*BigEndianStreamImpl) CleanBuff

func (impl *BigEndianStreamImpl) CleanBuff() error

*

  • 将已经读取过的数据从缓存中清除

func (*BigEndianStreamImpl) CopyBuff

func (impl *BigEndianStreamImpl) CopyBuff(b []byte) error

func (*BigEndianStreamImpl) Data

func (impl *BigEndianStreamImpl) Data() []byte

func (*BigEndianStreamImpl) Length

func (impl *BigEndianStreamImpl) Length() int

func (*BigEndianStreamImpl) PeekBuff

func (impl *BigEndianStreamImpl) PeekBuff(size int) (buff []byte, err error)

*

  • 从缓存中预读取指定字节数据不修改pos

func (*BigEndianStreamImpl) ReadBuff

func (impl *BigEndianStreamImpl) ReadBuff(size int) (buff []byte, err error)

func (*BigEndianStreamImpl) ReadByte

func (impl *BigEndianStreamImpl) ReadByte() (b byte, err error)

func (*BigEndianStreamImpl) ReadUint16

func (impl *BigEndianStreamImpl) ReadUint16() (b uint16, err error)

func (*BigEndianStreamImpl) ReadUint32

func (impl *BigEndianStreamImpl) ReadUint32() (b uint32, err error)

func (*BigEndianStreamImpl) ReadUint64

func (impl *BigEndianStreamImpl) ReadUint64() (b uint64, err error)

func (*BigEndianStreamImpl) Reset

func (impl *BigEndianStreamImpl) Reset(buff []byte)

func (*BigEndianStreamImpl) Right

func (impl *BigEndianStreamImpl) Right() int

func (*BigEndianStreamImpl) Size

func (impl *BigEndianStreamImpl) Size() int

func (*BigEndianStreamImpl) WriteBuff

func (impl *BigEndianStreamImpl) WriteBuff(buff []byte) error

func (*BigEndianStreamImpl) WriteByte

func (impl *BigEndianStreamImpl) WriteByte(b byte) error

func (*BigEndianStreamImpl) WriteUint16

func (impl *BigEndianStreamImpl) WriteUint16(b uint16) error

func (*BigEndianStreamImpl) WriteUint32

func (impl *BigEndianStreamImpl) WriteUint32(b uint32) error

func (*BigEndianStreamImpl) WriteUint64

func (impl *BigEndianStreamImpl) WriteUint64(b uint64) error

type IReadStream

type IReadStream interface {
	Size() int   // 缓存空间大小
	Length() int // 已使用的长度
	Right() int  // 剩余空间大小
	Reset([]byte)
	Data() []byte
	ReadByte() (b byte, err error)
	ReadUint16() (b uint16, err error)
	ReadUint32() (b uint32, err error)
	ReadUint64() (b uint64, err error)
	ReadBuff(size int) (b []byte, err error)
	PeekBuff(size int) (buff []byte, err error)
	CopyBuff(b []byte) error
}

type IWriteStream

type IWriteStream interface {
	Size() int   // 缓存空间大小
	Length() int // 已使用的长度
	Right() int  // 剩余空间大小
	Reset([]byte)
	Data() []byte
	WriteByte(b byte) error
	WriteUint16(b uint16) error
	WriteUint32(b uint32) error
	WriteUint64(b uint64) error
	WriteBuff(b []byte) error
	CleanBuff() error // 清楚已经读取过的内容以便节省空间
}

type LittleEndianStreamImpl

type LittleEndianStreamImpl struct {
	// contains filtered or unexported fields
}

func NewLittleEndianStream

func NewLittleEndianStream(buff []byte) *LittleEndianStreamImpl

func (*LittleEndianStreamImpl) CleanBuff

func (impl *LittleEndianStreamImpl) CleanBuff() error

*

  • 将已经读取过的数据从缓存中清除

func (*LittleEndianStreamImpl) CopyBuff

func (impl *LittleEndianStreamImpl) CopyBuff(b []byte) error

func (*LittleEndianStreamImpl) Data

func (impl *LittleEndianStreamImpl) Data() []byte

func (*LittleEndianStreamImpl) Length

func (impl *LittleEndianStreamImpl) Length() int

func (*LittleEndianStreamImpl) PeekBuff

func (impl *LittleEndianStreamImpl) PeekBuff(size int) (buff []byte, err error)

*

  • 从缓存中预读取指定字节数据不修改pos

func (*LittleEndianStreamImpl) ReadBuff

func (impl *LittleEndianStreamImpl) ReadBuff(size int) (buff []byte, err error)

func (*LittleEndianStreamImpl) ReadByte

func (impl *LittleEndianStreamImpl) ReadByte() (b byte, err error)

func (*LittleEndianStreamImpl) ReadUint16

func (impl *LittleEndianStreamImpl) ReadUint16() (b uint16, err error)

func (*LittleEndianStreamImpl) ReadUint32

func (impl *LittleEndianStreamImpl) ReadUint32() (b uint32, err error)

func (*LittleEndianStreamImpl) ReadUint64

func (impl *LittleEndianStreamImpl) ReadUint64() (b uint64, err error)

func (*LittleEndianStreamImpl) Reset

func (impl *LittleEndianStreamImpl) Reset(buff []byte)

func (*LittleEndianStreamImpl) Right

func (impl *LittleEndianStreamImpl) Right() int

剩余空间大小

func (*LittleEndianStreamImpl) Size

func (impl *LittleEndianStreamImpl) Size() int

func (*LittleEndianStreamImpl) WriteBuff

func (impl *LittleEndianStreamImpl) WriteBuff(buff []byte) error

func (*LittleEndianStreamImpl) WriteByte

func (impl *LittleEndianStreamImpl) WriteByte(b byte) error

func (*LittleEndianStreamImpl) WriteUint16

func (impl *LittleEndianStreamImpl) WriteUint16(b uint16) error

func (*LittleEndianStreamImpl) WriteUint32

func (impl *LittleEndianStreamImpl) WriteUint32(b uint32) error

func (*LittleEndianStreamImpl) WriteUint64

func (impl *LittleEndianStreamImpl) WriteUint64(b uint64) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL