binpacker: github.com/zhuangsirui/binpacker Index | Files

package binpacker

import "github.com/zhuangsirui/binpacker"

Index

Package Files

packer.go unpacker.go util.go

func AddUint16Perfix Uses

func AddUint16Perfix(bytes []byte) []byte

AddUint16Perfix add 2 bytes as uint16 prefixes for bytes.

func AddUint32Perfix Uses

func AddUint32Perfix(bytes []byte) []byte

AddUint32Perfix add 4 bytes as uint32 prefixes for bytes.

func AddUint64Perfix Uses

func AddUint64Perfix(bytes []byte) []byte

AddUint64Perfix add 8 bytes as uint64 prefixes for bytes.

type Packer Uses

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

Packer is a binary packer helps you pack data into an io.Writer.

func NewPacker Uses

func NewPacker(endian binary.ByteOrder, writer io.Writer) *Packer

NewPacker returns a *Packer hold an io.Writer. User must provide the byte order explicitly.

func (*Packer) Error Uses

func (p *Packer) Error() error

Error returns an error if any errors exists

func (*Packer) PushByte Uses

func (p *Packer) PushByte(b byte) *Packer

PushByte write a single byte into writer.

func (*Packer) PushBytes Uses

func (p *Packer) PushBytes(bytes []byte) *Packer

PushBytes write a bytes array into writer.

func (*Packer) PushFloat32 Uses

func (p *Packer) PushFloat32(i float32) *Packer

PushFloat32 write a float32 into writer.

func (*Packer) PushFloat64 Uses

func (p *Packer) PushFloat64(i float64) *Packer

PushFloat64 write a float64 into writer.

func (*Packer) PushInt16 Uses

func (p *Packer) PushInt16(i int16) *Packer

PushUint16 write a int16 into writer.

func (*Packer) PushInt32 Uses

func (p *Packer) PushInt32(i int32) *Packer

PushInt32 write a int32 into writer.

func (*Packer) PushInt64 Uses

func (p *Packer) PushInt64(i int64) *Packer

PushInt64 write a int64 into writer.

func (*Packer) PushString Uses

func (p *Packer) PushString(s string) *Packer

PushString write a string into writer.

func (*Packer) PushUint16 Uses

func (p *Packer) PushUint16(i uint16) *Packer

PushUint16 write a uint16 into writer.

func (*Packer) PushUint32 Uses

func (p *Packer) PushUint32(i uint32) *Packer

PushUint32 write a uint32 into writer.

func (*Packer) PushUint64 Uses

func (p *Packer) PushUint64(i uint64) *Packer

PushUint64 write a uint64 into writer.

func (*Packer) PushUint8 Uses

func (p *Packer) PushUint8(i uint8) *Packer

PushUint8 write a uint8 into writer.

type Unpacker Uses

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

Unpacker helps you unpack binary data from an io.Reader.

func NewUnpacker Uses

func NewUnpacker(endian binary.ByteOrder, reader io.Reader) *Unpacker

NewUnpacker returns a *Unpacker which hold an io.Reader. User must provide the byte order explicitly.

func (*Unpacker) BytesWithUint16Perfix Uses

func (u *Unpacker) BytesWithUint16Perfix(bytes *[]byte) *Unpacker

func (*Unpacker) BytesWithUint16Prefix Uses

func (u *Unpacker) BytesWithUint16Prefix(bytes *[]byte) *Unpacker

BytesWithUint16Prefix read 2 bytes as bytes length, then read N bytes and set it to bytes.

func (*Unpacker) BytesWithUint32Perfix Uses

func (u *Unpacker) BytesWithUint32Perfix(bytes *[]byte) *Unpacker

func (*Unpacker) BytesWithUint32Prefix Uses

func (u *Unpacker) BytesWithUint32Prefix(bytes *[]byte) *Unpacker

BytesWithUint32Prefix read 4 bytes as bytes length, then read N bytes and set it to bytes.

func (*Unpacker) BytesWithUint64Perfix Uses

func (u *Unpacker) BytesWithUint64Perfix(bytes *[]byte) *Unpacker

func (*Unpacker) BytesWithUint64Prefix Uses

func (u *Unpacker) BytesWithUint64Prefix(bytes *[]byte) *Unpacker

BytesWithUint64Prefix read 8 bytes as bytes length, then read N bytes and set it to bytes.

func (*Unpacker) Error Uses

func (u *Unpacker) Error() error

Error returns an error if any errors exists

func (*Unpacker) FetchByte Uses

func (u *Unpacker) FetchByte(b *byte) *Unpacker

FetchByte fetch the first byte in io.Reader and set to b.

func (*Unpacker) FetchBytes Uses

func (u *Unpacker) FetchBytes(n uint64, bytes *[]byte) *Unpacker

FetchBytes read n bytes and set to bytes.

func (*Unpacker) FetchFloat32 Uses

func (u *Unpacker) FetchFloat32(i *float32) *Unpacker

FetchFloat32 read 4 bytes, convert it to float32 and set it to i.

func (*Unpacker) FetchFloat64 Uses

func (u *Unpacker) FetchFloat64(i *float64) *Unpacker

FetchFloat64 read 8 bytes, convert it to float64 and set it to i.

func (*Unpacker) FetchInt16 Uses

func (u *Unpacker) FetchInt16(i *int16) *Unpacker

FetchInt16 read 2 bytes, convert it to int16 and set it to i.

func (*Unpacker) FetchInt32 Uses

func (u *Unpacker) FetchInt32(i *int32) *Unpacker

FetchInt32 read 4 bytes, convert it to int32 and set it to i.

func (*Unpacker) FetchInt64 Uses

func (u *Unpacker) FetchInt64(i *int64) *Unpacker

FetchInt64 read 8 bytes, convert it to int64 and set it to i.

func (*Unpacker) FetchString Uses

func (u *Unpacker) FetchString(n uint64, s *string) *Unpacker

FetchString read n bytes, convert it to string and set t to s.

func (*Unpacker) FetchUint16 Uses

func (u *Unpacker) FetchUint16(i *uint16) *Unpacker

FetchUint16 read 2 bytes, convert it to uint16 and set it to i.

func (*Unpacker) FetchUint32 Uses

func (u *Unpacker) FetchUint32(i *uint32) *Unpacker

FetchUint32 read 4 bytes, convert it to uint32 and set it to i.

func (*Unpacker) FetchUint64 Uses

func (u *Unpacker) FetchUint64(i *uint64) *Unpacker

FetchUint64 read 8 bytes, convert it to uint64 and set it to i.

func (*Unpacker) FetchUint8 Uses

func (u *Unpacker) FetchUint8(i *uint8) *Unpacker

FetchUint8 read 1 byte, convert it to uint8 and set it to i.

func (*Unpacker) ShiftByte Uses

func (u *Unpacker) ShiftByte() (byte, error)

ShiftByte fetch the first byte in io.Reader. Returns a byte and an error if exists.

func (*Unpacker) ShiftBytes Uses

func (u *Unpacker) ShiftBytes(_n uint64) ([]byte, error)

ShiftBytes fetch n bytes in io.Reader. Returns a byte array and an error if exists.

func (*Unpacker) ShiftFloat32 Uses

func (u *Unpacker) ShiftFloat32() (float32, error)

ShiftFloat32 fetch 4 bytes in io.Reader and convert it to float32.

func (*Unpacker) ShiftFloat64 Uses

func (u *Unpacker) ShiftFloat64() (float64, error)

ShiftFloat64 fetch 8 bytes in io.Reader and convert it to float64.

func (*Unpacker) ShiftInt16 Uses

func (u *Unpacker) ShiftInt16() (int16, error)

ShiftInt16 fetch 2 bytes in io.Reader and convert it to int16.

func (*Unpacker) ShiftInt32 Uses

func (u *Unpacker) ShiftInt32() (int32, error)

ShiftInt32 fetch 4 bytes in io.Reader and convert it to int32.

func (*Unpacker) ShiftInt64 Uses

func (u *Unpacker) ShiftInt64() (int64, error)

ShiftInt64 fetch 8 bytes in io.Reader and convert it to int64.

func (*Unpacker) ShiftString Uses

func (u *Unpacker) ShiftString(n uint64) (string, error)

ShiftString fetch n bytes, convert it to string. Returns string and an error.

func (*Unpacker) ShiftUint16 Uses

func (u *Unpacker) ShiftUint16() (uint16, error)

ShiftUint16 fetch 2 bytes in io.Reader and convert it to uint16.

func (*Unpacker) ShiftUint32 Uses

func (u *Unpacker) ShiftUint32() (uint32, error)

ShiftUint32 fetch 4 bytes in io.Reader and convert it to uint32.

func (*Unpacker) ShiftUint64 Uses

func (u *Unpacker) ShiftUint64() (uint64, error)

ShiftUint64 fetch 8 bytes in io.Reader and convert it to uint64.

func (*Unpacker) ShiftUint8 Uses

func (u *Unpacker) ShiftUint8() (uint8, error)

ShiftUint8 fetch 1 byte in io.Reader and covert it to uint8

func (*Unpacker) StringWithUint16Perfix Uses

func (u *Unpacker) StringWithUint16Perfix(s *string) *Unpacker

func (*Unpacker) StringWithUint16Prefix Uses

func (u *Unpacker) StringWithUint16Prefix(s *string) *Unpacker

StringWithUint16Prefix read 2 bytes as string length, then read N bytes, convert it to string and set it to s.

func (*Unpacker) StringWithUint32Perfix Uses

func (u *Unpacker) StringWithUint32Perfix(s *string) *Unpacker

func (*Unpacker) StringWithUint32Prefix Uses

func (u *Unpacker) StringWithUint32Prefix(s *string) *Unpacker

StringWithUint32Prefix read 4 bytes as string length, then read N bytes, convert it to string and set it to s.

func (*Unpacker) StringWithUint64Perfix Uses

func (u *Unpacker) StringWithUint64Perfix(s *string) *Unpacker

func (*Unpacker) StringWithUint64Prefix Uses

func (u *Unpacker) StringWithUint64Prefix(s *string) *Unpacker

StringWithUint64Prefix read 8 bytes as string length, then read N bytes, convert it to string and set it to s.

Package binpacker imports 5 packages (graph) and is imported by 1 packages. Updated 2017-10-16. Refresh now. Tools for package owners.