|
| Data.Binary.Get | | Portability | portable to Hugs and GHC. | | Stability | experimental | | Maintainer | Lennart Kolmodin <kolmodin@dtek.chalmers.se> |
|
|
|
|
|
| Description |
| The Get monad. A monad for efficiently building structures from
encoded lazy ByteStrings
|
|
| Synopsis |
|
|
|
|
| The Get type
|
|
|
| The Get monad is just a State monad carrying around the input ByteString
We treat it as a strict state monad.
| Instances | |
|
|
|
| Run the Get monad applies a get-based parser on the input ByteString
|
|
|
| Run the Get monad applies a get-based parser on the input
ByteString. Additional to the result of get it returns the number of
consumed bytes and the rest of the input.
|
|
| Parsing
|
|
|
| Skip ahead n bytes. Fails if fewer than n bytes are available.
|
|
|
| Skip ahead n bytes. No error if there isn't enough bytes.
|
|
|
| Run ga, but return without consuming its input.
Fails if ga fails.
|
|
|
| Like lookAhead, but consume the input if gma returns 'Just _'.
Fails if gma fails.
|
|
|
| Like lookAhead, but consume the input if gea returns 'Right _'.
Fails if gea fails.
|
|
|
| Get the next up to n bytes as a lazy ByteString, without consuming them.
|
|
| Utility
|
|
|
| Get the total number of bytes read to this point.
|
|
|
Pull n bytes from the input, as a strict ByteString.
important
|
|
|
| Get the number of remaining unparsed bytes.
Useful for checking whether all input has been consumed.
Note that this forces the rest of the input.
|
|
|
| Test whether all input has been consumed,
i.e. there are no remaining unparsed bytes.
|
|
| Parsing particular types
|
|
|
| Read a Word8 from the monad state
|
|
| ByteStrings
|
|
|
| An efficient get method for strict ByteStrings. Fails if fewer
than n bytes are left in the input.
|
|
|
| An efficient get method for lazy ByteStrings. Does not fail if fewer than
n bytes are left in the input.
|
|
|
| Get a lazy ByteString that is terminated with a NUL byte. Fails
if it reaches the end of input without hitting a NUL.
|
|
|
| Get the remaining bytes as a lazy ByteString
|
|
| Big-endian reads
|
|
|
| Read a Word16 in big endian format
|
|
|
| Read a Word32 in big endian format
|
|
|
| Read a Word64 in big endian format
|
|
| Little-endian reads
|
|
|
| Read a Word16 in little endian format
|
|
|
| Read a Word32 in little endian format
|
|
|
| Read a Word64 in little endian format
|
|
| Host-endian, unaligned reads
|
|
|
| O(1). Read a single native machine word. The word is read in
host order, host endian form, for the machine you're on. On a 64 bit
machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes.
|
|
|
| O(1). Read a 2 byte Word16 in native host order and host endianness.
|
|
|
| O(1). Read a Word32 in native host order and host endianness.
|
|
|
| O(1). Read a Word64 in native host order and host endianess.
|
|
| Produced by Haddock version 2.6.1 |