bitread

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 4 Imported by: 9

README

gobitread

Provides a bit level reader for go.

GoDoc Build Status codecov Go Report License FOSSA Status

Go Get

go get github.com/markus-wa/gobitread

Example

TODO

License

This project is licensed under the MIT license.

FOSSA Status

Documentation

Overview

Package bitread provides a bit level reader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitReader

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

BitReader wraps an io.Reader and provides methods to read from it on the bit level.

func (*BitReader) ActualPosition

func (r *BitReader) ActualPosition() int

ActualPosition returns the offset from the start in bits.

func (*BitReader) BeginChunk

func (r *BitReader) BeginChunk(n int)

BeginChunk starts a new chunk with n bits. Useful to make sure the position in the bit stream is correct.

func (*BitReader) ChunkFinished

func (r *BitReader) ChunkFinished() bool

ChunkFinished returns true if the current position is at the end of the chunk.

func (*BitReader) Close

func (r *BitReader) Close() error

Close resets the BitReader. Open() may be used again after Close().

func (*BitReader) EndChunk

func (r *BitReader) EndChunk()

EndChunk attempts to 'end' the last chunk. Seeks to the end of the chunk if not already reached. Panics if the chunk boundary was exceeded while reading.

func (*BitReader) LazyPosition

func (r *BitReader) LazyPosition() int

LazyPosition returns the offset at the time of the last time the buffer was refilled.

func (*BitReader) Open

func (r *BitReader) Open(underlying io.Reader, bufferSize int)

Open sets the underlying io.Reader and internal buffer, making the reader ready to use. bufferSize is in bytes, must be a multiple of 8 and > 16.

func (*BitReader) OpenWithBuffer

func (r *BitReader) OpenWithBuffer(underlying io.Reader, buffer []byte)

OpenWithBuffer is like Open but allows to provide the internal byte buffer. Could be useful to pool buffers of short living BitReaders for example. len(buffer) must be a multiple of 8 and > 16.

func (*BitReader) ReadBit

func (r *BitReader) ReadBit() bool

ReadBit reads a single bit.

func (*BitReader) ReadBits

func (r *BitReader) ReadBits(n int) []byte

ReadBits reads n bits into a []byte.

func (*BitReader) ReadBitsToByte

func (r *BitReader) ReadBitsToByte(n int) byte

ReadBitsToByte reads n bits into a byte. Undefined for n > 8.

func (*BitReader) ReadBytes

func (r *BitReader) ReadBytes(n int) []byte

ReadBytes reads n bytes. Ease of use wrapper for ReadBytesInto().

func (*BitReader) ReadBytesInto

func (r *BitReader) ReadBytesInto(out *[]byte, n int)

ReadBytesInto reads n bytes into out. Useful for pooling []byte slices.

func (*BitReader) ReadCString

func (r *BitReader) ReadCString(n int) string

ReadCString reads n bytes as characters into a string. The string is terminated by zero.

func (*BitReader) ReadInt

func (r *BitReader) ReadInt(n int) uint

ReadInt reads the next n bits as an int. Undefined for n > 32.

func (*BitReader) ReadSignedInt

func (r *BitReader) ReadSignedInt(n int) int

ReadSignedInt is like ReadInt but returns signed int. Undefined for n > 32.

func (*BitReader) ReadSingleByte

func (r *BitReader) ReadSingleByte() byte

ReadSingleByte reads one byte. Not called ReadByte as it does not comply with the standard library interface.

func (*BitReader) Skip added in v0.2.0

func (r *BitReader) Skip(n int)

Skip skips n bits.

Jump to

Keyboard shortcuts

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