| |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
Description | |||||||||||||||||||||||||||||||||||||||||||||
This is a reader monad for parsing bit-aligned data. The usual Get monad handles byte aligned data well. In this monad, the current offset into the input is a number of bits, and fetching n bits from the current position will shift everything correctly. Bit vectors are represented as ByteStrings here either the first n bits are valid (left aligned) or the last n bits are (right aligned). If one is looking to parse integers etc, right alignment is the easist to work with, however left alignment makes more sense in some situations. | |||||||||||||||||||||||||||||||||||||||||||||
Synopsis | |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
Get BitGet type | |||||||||||||||||||||||||||||||||||||||||||||
data BitGet a | |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
runBitGet :: ByteString -> BitGet a -> Either String a | |||||||||||||||||||||||||||||||||||||||||||||
Run a BitGet on a ByteString | |||||||||||||||||||||||||||||||||||||||||||||
Utility | |||||||||||||||||||||||||||||||||||||||||||||
skip :: Int -> BitGet () | |||||||||||||||||||||||||||||||||||||||||||||
Skip n bits of the input. Fails if less then n bits remain | |||||||||||||||||||||||||||||||||||||||||||||
remaining :: BitGet Int | |||||||||||||||||||||||||||||||||||||||||||||
Return the number of bits remaining to be parsed | |||||||||||||||||||||||||||||||||||||||||||||
isEmpty :: BitGet Bool | |||||||||||||||||||||||||||||||||||||||||||||
Return true if there are no more bits to parse | |||||||||||||||||||||||||||||||||||||||||||||
Generic parsing | |||||||||||||||||||||||||||||||||||||||||||||
getBit :: BitGet Bool | |||||||||||||||||||||||||||||||||||||||||||||
Get a single bit from the input | |||||||||||||||||||||||||||||||||||||||||||||
getLeftByteString :: Int -> BitGet ByteString | |||||||||||||||||||||||||||||||||||||||||||||
Get a ByteString with the given number of bits, left aligned. | |||||||||||||||||||||||||||||||||||||||||||||
getRightByteString :: Int -> BitGet ByteString | |||||||||||||||||||||||||||||||||||||||||||||
Get a ByteString with the given number of bits in, right aligned. | |||||||||||||||||||||||||||||||||||||||||||||
Interpreting some number of bits as an integer | |||||||||||||||||||||||||||||||||||||||||||||
getAsWord8 :: Int -> BitGet Word8 | |||||||||||||||||||||||||||||||||||||||||||||
getAsWord16 :: Int -> BitGet Word16 | |||||||||||||||||||||||||||||||||||||||||||||
Read a Word16 in big endian format | |||||||||||||||||||||||||||||||||||||||||||||
getAsWord32 :: Int -> BitGet Word32 | |||||||||||||||||||||||||||||||||||||||||||||
Read a Word32 in big endian format | |||||||||||||||||||||||||||||||||||||||||||||
getAsWord64 :: Int -> BitGet Word64 | |||||||||||||||||||||||||||||||||||||||||||||
Read a Word64 in big endian format | |||||||||||||||||||||||||||||||||||||||||||||
Parsing particular types | |||||||||||||||||||||||||||||||||||||||||||||
getWord8 :: BitGet Word8 | |||||||||||||||||||||||||||||||||||||||||||||
getWord16le :: BitGet Word16 | |||||||||||||||||||||||||||||||||||||||||||||
getWord16be :: BitGet Word16 | |||||||||||||||||||||||||||||||||||||||||||||
getWord16host :: BitGet Word16 | |||||||||||||||||||||||||||||||||||||||||||||
getWord32le :: BitGet Word32 | |||||||||||||||||||||||||||||||||||||||||||||
getWord32be :: BitGet Word32 | |||||||||||||||||||||||||||||||||||||||||||||
getWord32host :: BitGet Word32 | |||||||||||||||||||||||||||||||||||||||||||||
getWord64le :: BitGet Word64 | |||||||||||||||||||||||||||||||||||||||||||||
getWord64be :: BitGet Word64 | |||||||||||||||||||||||||||||||||||||||||||||
getWord64host :: BitGet Word64 | |||||||||||||||||||||||||||||||||||||||||||||
getWordhost :: BitGet Word | |||||||||||||||||||||||||||||||||||||||||||||
Produced by Haddock version 0.8 |