package binaryreader
import "github.com/benoitkugler/textlayout/fonts/binaryreader"
Package binaryreader provides a convenient reader to decode (big endian) binary content.
Index ¶
- type Reader
- func NewReader(data []byte) *Reader
- func NewReaderAt(data []byte, offset uint32) (*Reader, error)
- func (r *Reader) Byte() (byte, error)
- func (r *Reader) Data() []byte
- func (r *Reader) FixedSizes(count, size int) ([]byte, error)
- func (r *Reader) Int16s(count int) ([]int16, error)
- func (r *Reader) Read(out []byte) (int, error)
- func (r *Reader) ReadStruct(out interface{}) error
- func (r *Reader) SetPos(pos int)
- func (r *Reader) Skip(count int)
- func (r *Reader) Uint16() (uint16, error)
- func (r *Reader) Uint16s(count int) ([]uint16, error)
- func (r *Reader) Uint32() (uint32, error)
- func (r *Reader) Uint32s(count int) ([]uint32, error)
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 ¶
NewReader returns a reader filled with `data`.
func NewReaderAt ¶
NewReaderAt returns a reader filled with `data[offset:]`.
func (*Reader) Byte ¶
Byte reads one byte and advances. The only error possible is reaching the end of the slice.
func (*Reader) Data ¶
Data returns the remaining (unread) slice.
func (*Reader) FixedSizes ¶
FixedSizes return a slice with length count*size, and advances
func (*Reader) Int16s ¶
Int16s reads a slice of int16 with length `count` and advances.
func (*Reader) Read ¶
func (*Reader) ReadStruct ¶
ReadStruct calls binary.Read and advances. The only error possible is reaching the end of the slice.
func (*Reader) SetPos ¶
SetPos seeks from the start, delaying potential bound checking.
func (*Reader) Skip ¶
Skip advances from `count` bytes, delaying potential bound checking.
func (*Reader) Uint16 ¶
Uint16 reads one uint16 and advances. The only error possible is reaching the end of the slice.
func (*Reader) Uint16s ¶
Uint16s reads a slice of uint16 with length `count` and advances.
func (*Reader) Uint32 ¶
Uint32 reads one uint32 and advances. The only error possible is reaching the end of the slice.
func (*Reader) Uint32s ¶
Uint32s reads a slice of uint32 with length `count` and advances.
Source Files ¶
- Version
- v0.3.1 (latest)
- Published
- Nov 14, 2024
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 5 days ago –
Tools for package owners.