package binaryreader

import "github.com/benoitkugler/textlayout/fonts/binaryreader"

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

Index

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.

Source Files

reader.go

Version
v0.3.1 (latest)
Published
Nov 14, 2024
Platform
linux/amd64
Imports
4 packages
Last checked
5 days ago

Tools for package owners.