# README
bitreader
Provides basic interfaces to read and traverse an io.Reader
as a stream of bits, rather than a stream of bytes.
Installation
$ go get github.com/32bitkid/bitreader
Examples
Ever wanted to count the number of 0 bits from the start of a file?
package main
import (
"os"
"fmt"
"github.com/32bitkid/bitreader"
)
func main() {
file, _ := os.Open("file")
r := bitreader.NewReader(file)
n := 0
for {
val, err := r.Read1()
if err != nil || val == true {
break
}
n += 1
}
fmt.Printf("The file starts with %d off bits", n)
}
But seriously, this is used for parsing densely packed binary formats where data may not be byte aligned. For example, decoding values packed with Huffman Coding.
# Functions
NewBitReader returns the default implementation of a BitReader.
# Interfaces
Aligner is the interface that allows for byte realignment.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Peeker is the interface that wraps the basic Peek1 method
Peek1 will return true or false depending on whether or not the next bit in the bit stream is set; it does not advance the stream any bits.
No description provided by the author
Peeker32 is the interface that wraps the basic Peek32 method.
No description provided by the author
No description provided by the author
Reader1 is the interface that wraps the basic Read1 method
Read1() will return true or false depending on whether or not the next bit in the bit stream is set, then advance one bit forward in the bit-stream.
No description provided by the author
Reader32 is the interface that wraps the basic Read32 method.
No description provided by the author
No description provided by the author
Skipper is the interface that wraps the basic Skip method.