binaryreader

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package binaryreader provides a convenient reader to decode (big endian) binary content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader holds a byte slice and provide convenient methods to interpret its content.

func NewReader

func NewReader(data []byte) *Reader

NewReader returns a reader filled with `data`.

func NewReaderAt

func NewReaderAt(data []byte, offset uint32) (*Reader, error)

NewReaderAt returns a reader filled with `data[offset:]`.

func (*Reader) Byte

func (r *Reader) Byte() (byte, error)

Byte reads one byte and advances. The only error possible is reaching the end of the slice.

func (*Reader) Data

func (r *Reader) Data() []byte

Data returns the remaining (unread) slice.

func (*Reader) FixedSizes

func (r *Reader) FixedSizes(count, size int) ([]byte, error)

FixedSizes return a slice with length count*size, and advances

func (*Reader) Int16s

func (r *Reader) Int16s(count int) ([]int16, error)

Int16s reads a slice of int16 with length `count` and advances.

func (*Reader) Read

func (r *Reader) Read(out []byte) (int, error)

func (*Reader) ReadStruct

func (r *Reader) ReadStruct(out interface{}) error

ReadStruct calls binary.Read and advances. The only error possible is reaching the end of the slice.

func (*Reader) SetPos

func (r *Reader) SetPos(pos int)

SetPos seeks from the start, delaying potential bound checking.

func (*Reader) Skip

func (r *Reader) Skip(count int)

Skip advances from `count` bytes, delaying potential bound checking.

func (*Reader) Uint16

func (r *Reader) Uint16() (uint16, error)

Uint16 reads one uint16 and advances. The only error possible is reaching the end of the slice.

func (*Reader) Uint16s

func (r *Reader) Uint16s(count int) ([]uint16, error)

Uint16s reads a slice of uint16 with length `count` and advances.

func (*Reader) Uint32

func (r *Reader) Uint32() (uint32, error)

Uint32 reads one uint32 and advances. The only error possible is reaching the end of the slice.

func (*Reader) Uint32s

func (r *Reader) Uint32s(count int) ([]uint32, error)

Uint32s reads a slice of uint32 with length `count` and advances.

Jump to

Keyboard shortcuts

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