haskus-binary-1.5: Haskus binary format manipulation

Safe HaskellNone
LanguageHaskell2010

Haskus.Binary.Bits.Get

Contents

Description

Bit getter

Synopsis

Documentation

data BitGetState Source #

BitGet state

Constructors

BitGetState 

Fields

Instances
Show BitGetState Source # 
Instance details

Defined in Haskus.Binary.Bits.Get

newBitGetState :: BitOrder -> Buffer -> BitGetState Source #

Create a new BitGetState

isEmpty :: BitGetState -> Bool Source #

Indicate that the source is empty

skipBits :: Word -> BitGetState -> BitGetState Source #

Skip the given number of bits from the input

skipBitsToAlignOnWord8 :: BitGetState -> BitGetState Source #

Skip the required number of bits to be aligned on 8-bits

getBits :: (Integral a, Bits a) => Word -> BitGetState -> a Source #

Read the given number of bits and put the result in a word

getBitsChecked :: (Integral a, Bits a, ReversableBits a) => Word -> Word -> BitGetState -> a Source #

Perform some checks before calling getBits

Check that the number of bits to read is not greater than the first parameter

getBitsBuffer :: Word -> BitGetState -> Buffer Source #

Read the given number of Word8 and return them in a Buffer

Examples: BB: xxxABCDE FGHIJKLM NOPxxxxx -> ABCDEFGH IJKLMNOP LL: LMNOPxxx DEFGHIJK xxxxxABC -> ABCDEFGH IJKLMNOP BL: xxxPONML KJIHGFED CBAxxxxx -> ABCDEFGH IJKLMNOP LB: EDCBAxxx MLKJIHGF xxxxxPON -> ABCDEFGH IJKLMNOP

Monadic

type BitGet a = BitGetT Identity a Source #

BitGet monad

type BitGetT m a = StateT BitGetState m a Source #

BitGet monad transformer

runBitGet :: BitOrder -> BitGet a -> Buffer -> a Source #

Evaluate a BitGet monad

runBitGetT :: Monad m => BitOrder -> BitGetT m a -> Buffer -> m a Source #

Evaluate a BitGet monad

runBitGetPartialT :: BitOrder -> BitGetT m a -> Buffer -> m (a, BitGetState) Source #

Evaluate a BitGet monad, return the remaining state

runBitGetPartial :: BitOrder -> BitGet a -> Buffer -> (a, BitGetState) Source #

Evaluate a BitGet monad, return the remaining state

resumeBitGetPartialT :: BitGetT m a -> BitGetState -> m (a, BitGetState) Source #

Resume a BitGet evaluation

resumeBitGetPartial :: BitGet a -> BitGetState -> (a, BitGetState) Source #

Resume a BitGet evaluation

isEmptyM :: Monad m => BitGetT m Bool Source #

Indicate if all bits have been read

skipBitsM :: Monad m => Word -> BitGetT m () Source #

Skip the given number of bits from the input (monadic version)

skipBitsToAlignOnWord8M :: Monad m => BitGetT m () Source #

Skip the required number of bits to be aligned on 8-bits (monadic version)

getBitsM :: (Integral a, Bits a, Monad m) => Word -> BitGetT m a Source #

Read the given number of bits and put the result in a word

getBitsCheckedM :: (Integral a, Bits a, ReversableBits a, Monad m) => Word -> Word -> BitGetT m a Source #

Perform some checks before calling getBitsM

getBitBoolM :: Monad m => BitGetT m Bool Source #

Get a bit and convert it into a Bool

getBitsBSM :: Monad m => Word -> BitGetT m Buffer Source #

Get the given number of Word8

changeBitGetOrder :: Monad m => BitOrder -> BitGetT m () Source #

Change the current bit ordering

Be careful to change the outer bit ordering (B* to L* or the inverse) only on bytes boundaries! Otherwise, you will read the same bits more than once.

withBitGetOrder :: Monad m => BitOrder -> BitGetT m a -> BitGetT m a Source #

Change the bit ordering for the wrapped BitGet

Be careful, this function uses changeBitGetOrder internally.