Documentation ¶
Overview ¶
Package bitread provides a bit level reader.
Index ¶
- type BitReader
- func (r *BitReader) ActualPosition() int
- func (r *BitReader) BeginChunk(n int)
- func (r *BitReader) ChunkFinished() bool
- func (r *BitReader) Close() error
- func (r *BitReader) EndChunk()
- func (r *BitReader) LazyPosition() int
- func (r *BitReader) Open(underlying io.Reader, bufferSize int)
- func (r *BitReader) OpenWithBuffer(underlying io.Reader, buffer []byte)
- func (r *BitReader) ReadBit() bool
- func (r *BitReader) ReadBits(n int) []byte
- func (r *BitReader) ReadBitsToByte(n int) byte
- func (r *BitReader) ReadBytes(n int) []byte
- func (r *BitReader) ReadBytesInto(out *[]byte, n int)
- func (r *BitReader) ReadCString(n int) string
- func (r *BitReader) ReadInt(n int) uint
- func (r *BitReader) ReadSignedInt(n int) int
- func (r *BitReader) ReadSingleByte() byte
- func (r *BitReader) Skip(n int)
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 ¶
ActualPosition returns the offset from the start in bits.
func (*BitReader) BeginChunk ¶
BeginChunk starts a new chunk with n bits. Useful to make sure the position in the bit stream is correct.
func (*BitReader) ChunkFinished ¶
ChunkFinished returns true if the current position is at the end of the chunk.
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 ¶
LazyPosition returns the offset at the time of the last time the buffer was refilled.
func (*BitReader) Open ¶
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 ¶
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) ReadBitsToByte ¶
ReadBitsToByte reads n bits into a byte. Undefined for n > 8.
func (*BitReader) ReadBytesInto ¶
ReadBytesInto reads n bytes into out. Useful for pooling []byte slices.
func (*BitReader) ReadCString ¶
ReadCString reads n bytes as characters into a string. The string is terminated by zero.
func (*BitReader) ReadSignedInt ¶
ReadSignedInt is like ReadInt but returns signed int. Undefined for n > 32.
func (*BitReader) ReadSingleByte ¶
ReadSingleByte reads one byte. Not called ReadByte as it does not comply with the standard library interface.