reader

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 4 Imported by: 0

Documentation

Overview

Package reader provides the stream readers used by the jbig2 segments decoder. It defines the StreamReader interface that allows to read bit, bits, byte, bytes, integers change and get the stream position, align the bits.

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 is the bit reader implementation. Implements io.Reader, io.ByteReader, io.Seeker interfaces.

func New

func New(data []byte) *Reader

New creates a new reader.Reader using the byte slice data as input.

func (*Reader) Align

func (r *Reader) Align() (skipped byte)

Align implements StreamReader interface.

func (*Reader) BitPosition

func (r *Reader) BitPosition() int

BitPosition implements StreamReader inteface.

func (*Reader) ConsumeRemainingBits

func (r *Reader) ConsumeRemainingBits()

ConsumeRemainingBits consumes the remaining bits from the given reader.

func (*Reader) Length

func (r *Reader) Length() uint64

Length implements StreamReader interface.

func (*Reader) Mark

func (r *Reader) Mark()

Mark implements StreamReader interface.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read implements io.Reader interface.

func (*Reader) ReadBit

func (r *Reader) ReadBit() (bit int, err error)

ReadBit implements StreamReader interface.

func (*Reader) ReadBits

func (r *Reader) ReadBits(n byte) (u uint64, err error)

ReadBits implements StreamReader interface.

func (*Reader) ReadBool

func (r *Reader) ReadBool() (bool, error)

ReadBool implements StreamReader interface.

func (*Reader) ReadByte

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

ReadByte implements io.ByteReader.

func (*Reader) ReadUint32

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

ReadUint32 implements StreamReader interface.

func (*Reader) Reset

func (r *Reader) Reset()

Reset implements StreamReader interface.

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

func (*Reader) StreamPosition

func (r *Reader) StreamPosition() int64

StreamPosition implements StreamReader interface.

type StreamReader

type StreamReader interface {
	io.Reader
	io.ByteReader
	io.Seeker

	// Align resets the bits position of the given reader.
	// It returns how many bits left were skipped.
	Align() byte
	// BitPosition gets the current bit position.
	BitPosition() int
	// Mark marks a position in the stream to be returned to by a subsequent call to 'Reset'.
	Mark()
	// Length returns the length of the total data used by the reader.
	Length() uint64

	// ReadBit reads the next binary value from the current cache.
	// Equivalent of ReadBool method but returns an integer.
	ReadBit() (int, error)
	// ReadBits reads the bits of size 'n' from the reader.
	ReadBits(n byte) (uint64, error)
	// ReadBool reads the next binary value from the current cache.
	ReadBool() (bool, error)
	// ReadUint32 reads the unsigned uint32 from the reader.
	ReadUint32() (uint32, error)

	// Reset returns the stream pointer to its previous position, including the bit offset,
	// at the time of the most recent unmatched call to mark.
	Reset()
	// StreamPosition gets the stream position of the stream reader.
	StreamPosition() int64
}

StreamReader is the interface that allows to read bit, bits, byte, bytes, integers change and get the stream position, align the bits.

type SubstreamReader

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

SubstreamReader is the wrapper over the Reader's parts that is allowed only to operate on the selected data space.

func NewSubstreamReader

func NewSubstreamReader(r StreamReader, offset, length uint64) (*SubstreamReader, error)

NewSubstreamReader creates new SubStreamReader for the provided wrapped StreamReader 'r' with defined 'offset' and 'length'.

func (*SubstreamReader) Align

func (s *SubstreamReader) Align() (skipped byte)

Align implements StreamReader interface.

func (*SubstreamReader) BitPosition

func (s *SubstreamReader) BitPosition() int

BitPosition implements StreamReader interface.

func (*SubstreamReader) Length

func (s *SubstreamReader) Length() uint64

Length implements StreamReader interface.

func (*SubstreamReader) Mark

func (s *SubstreamReader) Mark()

Mark implements StreamReader interface.

func (*SubstreamReader) Offset

func (s *SubstreamReader) Offset() uint64

Offset returns current SubstreamReader offset.

func (*SubstreamReader) Read

func (s *SubstreamReader) Read(b []byte) (n int, err error)

Read implements io.Reader interface.

func (*SubstreamReader) ReadBit

func (s *SubstreamReader) ReadBit() (bit int, err error)

ReadBit implements StreamReader interface.

func (*SubstreamReader) ReadBits

func (s *SubstreamReader) ReadBits(n byte) (u uint64, err error)

ReadBits implements StreamReader interface.

func (*SubstreamReader) ReadBool

func (s *SubstreamReader) ReadBool() (bool, error)

ReadBool implements StreamReader interface.

func (*SubstreamReader) ReadByte

func (s *SubstreamReader) ReadByte() (byte, error)

ReadByte implements io.ByteReader.

func (*SubstreamReader) ReadUint32

func (s *SubstreamReader) ReadUint32() (uint32, error)

ReadUint32 implements Streamreader interface.

func (*SubstreamReader) Reset

func (s *SubstreamReader) Reset()

Reset implements StreamReader interface.

func (*SubstreamReader) Seek

func (s *SubstreamReader) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

func (*SubstreamReader) StreamPosition

func (s *SubstreamReader) StreamPosition() int64

StreamPosition implements StreamReader interface.

Jump to

Keyboard shortcuts

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