{-# LANGUAGE CPP, RankNTypes, MagicHash, BangPatterns #-}
{-# LANGUAGE Trustworthy #-}
#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
#include "MachDeps.h"
#endif
module Data.Binary.Get (
Get
, runGet
, runGetOrFail
, ByteOffset
, Decoder(..)
, runGetIncremental
, pushChunk
, pushChunks
, pushEndOfInput
, skip
, isEmpty
, bytesRead
, isolate
, lookAhead
, lookAheadM
, lookAheadE
, label
, getByteString
, getLazyByteString
, getLazyByteStringNul
, getRemainingLazyByteString
, getWord8
, getWord16be
, getWord32be
, getWord64be
, getWord16le
, getWord32le
, getWord64le
, getWordhost
, getWord16host
, getWord32host
, getWord64host
, getInt8
, getInt16be
, getInt32be
, getInt64be
, getInt16le
, getInt32le
, getInt64le
, getInthost
, getInt16host
, getInt32host
, getInt64host
, getFloatbe
, getFloatle
, getFloathost
, getDoublebe
, getDoublele
, getDoublehost
, runGetState
, remaining
, getBytes
) where
#if ! MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Foreign
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Internal as L
import Data.Binary.Get.Internal hiding ( Decoder(..), runGetIncremental )
import qualified Data.Binary.Get.Internal as I
import Data.Binary.FloatCast (wordToFloat, wordToDouble)
data Decoder a = Fail !B.ByteString {-# UNPACK #-} !ByteOffset String
| Partial (Maybe B.ByteString -> Decoder a)
| Done !B.ByteString {-# UNPACK #-} !ByteOffset a
runGetIncremental :: Get a -> Decoder a
runGetIncremental :: forall a. Get a -> Decoder a
runGetIncremental = forall a. Decoder a -> Decoder a
calculateOffset forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Get a -> Decoder a
I.runGetIncremental
calculateOffset :: I.Decoder a -> Decoder a
calculateOffset :: forall a. Decoder a -> Decoder a
calculateOffset Decoder a
r0 = forall {a}. Decoder a -> Int64 -> Decoder a
go Decoder a
r0 Int64
0
where
go :: Decoder a -> Int64 -> Decoder a
go Decoder a
r !Int64
acc = case Decoder a
r of
I.Done ByteString
inp a
a -> forall a. ByteString -> Int64 -> a -> Decoder a
Done ByteString
inp (Int64
acc forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
inp)) a
a
I.Fail ByteString
inp String
s -> forall a. ByteString -> Int64 -> String -> Decoder a
Fail ByteString
inp (Int64
acc forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
inp)) String
s
I.Partial Maybe ByteString -> Decoder a
k ->
forall a. (Maybe ByteString -> Decoder a) -> Decoder a
Partial forall a b. (a -> b) -> a -> b
$ \Maybe ByteString
ms ->
case Maybe ByteString
ms of
Maybe ByteString
Nothing -> Decoder a -> Int64 -> Decoder a
go (Maybe ByteString -> Decoder a
k forall a. Maybe a
Nothing) Int64
acc
Just ByteString
i -> Decoder a -> Int64 -> Decoder a
go (Maybe ByteString -> Decoder a
k Maybe ByteString
ms) (Int64
acc forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
i))
I.BytesRead Int64
unused Int64 -> Decoder a
k ->
Decoder a -> Int64 -> Decoder a
go (Int64 -> Decoder a
k forall a b. (a -> b) -> a -> b
$! (Int64
acc forall a. Num a => a -> a -> a
- Int64
unused)) Int64
acc
{-# DEPRECATED runGetState "Use runGetIncremental instead. This function will be removed." #-}
runGetState :: Get a -> L.ByteString -> ByteOffset -> (a, L.ByteString, ByteOffset)
runGetState :: forall a. Get a -> ByteString -> Int64 -> (a, ByteString, Int64)
runGetState Get a
g ByteString
lbs0 Int64
pos' = forall {a}. Decoder a -> ByteString -> (a, ByteString, Int64)
go (forall a. Get a -> Decoder a
runGetIncremental Get a
g) ByteString
lbs0
where
go :: Decoder a -> ByteString -> (a, ByteString, Int64)
go (Done ByteString
s Int64
pos a
a) ByteString
lbs = (a
a, ByteString -> ByteString -> ByteString
L.chunk ByteString
s ByteString
lbs, Int64
posforall a. Num a => a -> a -> a
+Int64
pos')
go (Partial Maybe ByteString -> Decoder a
k) ByteString
lbs = Decoder a -> ByteString -> (a, ByteString, Int64)
go (Maybe ByteString -> Decoder a
k (ByteString -> Maybe ByteString
takeHeadChunk ByteString
lbs)) (ByteString -> ByteString
dropHeadChunk ByteString
lbs)
go (Fail ByteString
_ Int64
pos String
msg) ByteString
_ =
forall a. HasCallStack => String -> a
error (String
"Data.Binary.Get.runGetState at position " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int64
pos forall a. [a] -> [a] -> [a]
++ String
": " forall a. [a] -> [a] -> [a]
++ String
msg)
takeHeadChunk :: L.ByteString -> Maybe B.ByteString
takeHeadChunk :: ByteString -> Maybe ByteString
takeHeadChunk ByteString
lbs =
case ByteString
lbs of
(L.Chunk ByteString
bs ByteString
_) -> forall a. a -> Maybe a
Just ByteString
bs
ByteString
_ -> forall a. Maybe a
Nothing
dropHeadChunk :: L.ByteString -> L.ByteString
dropHeadChunk :: ByteString -> ByteString
dropHeadChunk ByteString
lbs =
case ByteString
lbs of
(L.Chunk ByteString
_ ByteString
lbs') -> ByteString
lbs'
ByteString
_ -> ByteString
L.Empty
runGetOrFail :: Get a -> L.ByteString
-> Either (L.ByteString, ByteOffset, String) (L.ByteString, ByteOffset, a)
runGetOrFail :: forall a.
Get a
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, a)
runGetOrFail Get a
g ByteString
lbs0 = forall {c}.
Decoder c
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, c)
feedAll (forall a. Get a -> Decoder a
runGetIncremental Get a
g) ByteString
lbs0
where
feedAll :: Decoder c
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, c)
feedAll (Done ByteString
bs Int64
pos c
x) ByteString
lbs = forall a b. b -> Either a b
Right (ByteString -> ByteString -> ByteString
L.chunk ByteString
bs ByteString
lbs, Int64
pos, c
x)
feedAll (Partial Maybe ByteString -> Decoder c
k) ByteString
lbs = Decoder c
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, c)
feedAll (Maybe ByteString -> Decoder c
k (ByteString -> Maybe ByteString
takeHeadChunk ByteString
lbs)) (ByteString -> ByteString
dropHeadChunk ByteString
lbs)
feedAll (Fail ByteString
x Int64
pos String
msg) ByteString
xs = forall a b. a -> Either a b
Left (ByteString -> ByteString -> ByteString
L.chunk ByteString
x ByteString
xs, Int64
pos, String
msg)
type ByteOffset = Int64
runGet :: Get a -> L.ByteString -> a
runGet :: forall a. Get a -> ByteString -> a
runGet Get a
g ByteString
lbs0 = forall {a}. Decoder a -> ByteString -> a
feedAll (forall a. Get a -> Decoder a
runGetIncremental Get a
g) ByteString
lbs0
where
feedAll :: Decoder a -> ByteString -> a
feedAll (Done ByteString
_ Int64
_ a
x) ByteString
_ = a
x
feedAll (Partial Maybe ByteString -> Decoder a
k) ByteString
lbs = Decoder a -> ByteString -> a
feedAll (Maybe ByteString -> Decoder a
k (ByteString -> Maybe ByteString
takeHeadChunk ByteString
lbs)) (ByteString -> ByteString
dropHeadChunk ByteString
lbs)
feedAll (Fail ByteString
_ Int64
pos String
msg) ByteString
_ =
forall a. HasCallStack => String -> a
error (String
"Data.Binary.Get.runGet at position " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int64
pos forall a. [a] -> [a] -> [a]
++ String
": " forall a. [a] -> [a] -> [a]
++ String
msg)
pushChunk :: Decoder a -> B.ByteString -> Decoder a
pushChunk :: forall a. Decoder a -> ByteString -> Decoder a
pushChunk Decoder a
r ByteString
inp =
case Decoder a
r of
Done ByteString
inp0 Int64
p a
a -> forall a. ByteString -> Int64 -> a -> Decoder a
Done (ByteString
inp0 ByteString -> ByteString -> ByteString
`B.append` ByteString
inp) Int64
p a
a
Partial Maybe ByteString -> Decoder a
k -> Maybe ByteString -> Decoder a
k (forall a. a -> Maybe a
Just ByteString
inp)
Fail ByteString
inp0 Int64
p String
s -> forall a. ByteString -> Int64 -> String -> Decoder a
Fail (ByteString
inp0 ByteString -> ByteString -> ByteString
`B.append` ByteString
inp) Int64
p String
s
pushChunks :: Decoder a -> L.ByteString -> Decoder a
pushChunks :: forall a. Decoder a -> ByteString -> Decoder a
pushChunks Decoder a
r0 = forall {a}. Decoder a -> [ByteString] -> Decoder a
go Decoder a
r0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
L.toChunks
where
go :: Decoder a -> [ByteString] -> Decoder a
go Decoder a
r [] = Decoder a
r
go (Done ByteString
inp Int64
pos a
a) [ByteString]
xs = forall a. ByteString -> Int64 -> a -> Decoder a
Done ([ByteString] -> ByteString
B.concat (ByteString
inpforall a. a -> [a] -> [a]
:[ByteString]
xs)) Int64
pos a
a
go (Fail ByteString
inp Int64
pos String
s) [ByteString]
xs = forall a. ByteString -> Int64 -> String -> Decoder a
Fail ([ByteString] -> ByteString
B.concat (ByteString
inpforall a. a -> [a] -> [a]
:[ByteString]
xs)) Int64
pos String
s
go (Partial Maybe ByteString -> Decoder a
k) (ByteString
x:[ByteString]
xs) = Decoder a -> [ByteString] -> Decoder a
go (Maybe ByteString -> Decoder a
k (forall a. a -> Maybe a
Just ByteString
x)) [ByteString]
xs
pushEndOfInput :: Decoder a -> Decoder a
pushEndOfInput :: forall a. Decoder a -> Decoder a
pushEndOfInput Decoder a
r =
case Decoder a
r of
Done ByteString
_ Int64
_ a
_ -> Decoder a
r
Partial Maybe ByteString -> Decoder a
k -> Maybe ByteString -> Decoder a
k forall a. Maybe a
Nothing
Fail ByteString
_ Int64
_ String
_ -> Decoder a
r
skip :: Int -> Get ()
skip :: Int -> Get ()
skip Int
n = forall s b.
s
-> Consume s
-> ([ByteString] -> b)
-> ([ByteString] -> Get b)
-> Get b
withInputChunks (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n) Consume Int64
consumeBytes (forall a b. a -> b -> a
const ()) forall a. [ByteString] -> Get a
failOnEOF
getLazyByteString :: Int64 -> Get L.ByteString
getLazyByteString :: Int64 -> Get ByteString
getLazyByteString Int64
n0 = forall s b.
s
-> Consume s
-> ([ByteString] -> b)
-> ([ByteString] -> Get b)
-> Get b
withInputChunks Int64
n0 Consume Int64
consumeBytes [ByteString] -> ByteString
L.fromChunks forall a. [ByteString] -> Get a
failOnEOF
consumeBytes :: Consume Int64
consumeBytes :: Consume Int64
consumeBytes Int64
n ByteString
str
| forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
str) forall a. Ord a => a -> a -> Bool
>= Int64
n = forall a b. b -> Either a b
Right (Int -> ByteString -> (ByteString, ByteString)
B.splitAt (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
n) ByteString
str)
| Bool
otherwise = forall a b. a -> Either a b
Left (Int64
n forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
str))
consumeUntilNul :: Consume ()
consumeUntilNul :: Consume ()
consumeUntilNul ()
_ ByteString
str =
case (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
B.break (forall a. Eq a => a -> a -> Bool
==Word8
0) ByteString
str of
(ByteString
want, ByteString
rest) | ByteString -> Bool
B.null ByteString
rest -> forall a b. a -> Either a b
Left ()
| Bool
otherwise -> forall a b. b -> Either a b
Right (ByteString
want, Int -> ByteString -> ByteString
B.drop Int
1 ByteString
rest)
consumeAll :: Consume ()
consumeAll :: Consume ()
consumeAll ()
_ ByteString
_ = forall a b. a -> Either a b
Left ()
resumeOnEOF :: [B.ByteString] -> Get L.ByteString
resumeOnEOF :: [ByteString] -> Get ByteString
resumeOnEOF = forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ByteString] -> ByteString
L.fromChunks
getLazyByteStringNul :: Get L.ByteString
getLazyByteStringNul :: Get ByteString
getLazyByteStringNul = forall s b.
s
-> Consume s
-> ([ByteString] -> b)
-> ([ByteString] -> Get b)
-> Get b
withInputChunks () Consume ()
consumeUntilNul [ByteString] -> ByteString
L.fromChunks forall a. [ByteString] -> Get a
failOnEOF
getRemainingLazyByteString :: Get L.ByteString
getRemainingLazyByteString :: Get ByteString
getRemainingLazyByteString = forall s b.
s
-> Consume s
-> ([ByteString] -> b)
-> ([ByteString] -> Get b)
-> Get b
withInputChunks () Consume ()
consumeAll [ByteString] -> ByteString
L.fromChunks [ByteString] -> Get ByteString
resumeOnEOF
getPtr :: Storable a => Int -> Get a
getPtr :: forall a. Storable a => Int -> Get a
getPtr Int
n = forall a. Int -> (Ptr a -> IO a) -> Get a
readNWith Int
n forall a. Storable a => Ptr a -> IO a
peek
{-# INLINE getPtr #-}
getWord8 :: Get Word8
getWord8 :: Get Word8
getWord8 = forall a. Int -> (ByteString -> a) -> Get a
readN Int
1 ByteString -> Word8
B.unsafeHead
{-# INLINE[2] getWord8 #-}
getInt8 :: Get Int8
getInt8 :: Get Int8
getInt8 = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word8
getWord8
{-# INLINE getInt8 #-}
{-# RULES
"getWord8/readN" getWord8 = readN 1 B.unsafeHead
"getWord16be/readN" getWord16be = readN 2 word16be
"getWord16le/readN" getWord16le = readN 2 word16le
"getWord32be/readN" getWord32be = readN 4 word32be
"getWord32le/readN" getWord32le = readN 4 word32le
"getWord64be/readN" getWord64be = readN 8 word64be
"getWord64le/readN" getWord64le = readN 8 word64le #-}
getWord16be :: Get Word16
getWord16be :: Get Word16
getWord16be = forall a. Int -> (ByteString -> a) -> Get a
readN Int
2 ByteString -> Word16
word16be
word16be :: B.ByteString -> Word16
word16be :: ByteString -> Word16
word16be = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1))
{-# INLINE[2] getWord16be #-}
{-# INLINE word16be #-}
getWord16le :: Get Word16
getWord16le :: Get Word16
getWord16le = forall a. Int -> (ByteString -> a) -> Get a
readN Int
2 ByteString -> Word16
word16le
word16le :: B.ByteString -> Word16
word16le :: ByteString -> Word16
word16le = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) )
{-# INLINE[2] getWord16le #-}
{-# INLINE word16le #-}
getWord32be :: Get Word32
getWord32be :: Get Word32
getWord32be = forall a. Int -> (ByteString -> a) -> Get a
readN Int
4 ByteString -> Word32
word32be
word32be :: B.ByteString -> Word32
word32be :: ByteString -> Word32
word32be = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
24) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
16) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
2) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
3) )
{-# INLINE[2] getWord32be #-}
{-# INLINE word32be #-}
getWord32le :: Get Word32
getWord32le :: Get Word32
getWord32le = forall a. Int -> (ByteString -> a) -> Get a
readN Int
4 ByteString -> Word32
word32le
word32le :: B.ByteString -> Word32
word32le :: ByteString -> Word32
word32le = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
3) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
24) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
2) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
16) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) )
{-# INLINE[2] getWord32le #-}
{-# INLINE word32le #-}
getWord64be :: Get Word64
getWord64be :: Get Word64
getWord64be = forall a. Int -> (ByteString -> a) -> Get a
readN Int
8 ByteString -> Word64
word64be
word64be :: B.ByteString -> Word64
word64be :: ByteString -> Word64
word64be = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
56) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
48) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
2) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
40) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
3) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
32) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
4) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
24) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
5) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
16) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
6) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
7) )
{-# INLINE[2] getWord64be #-}
{-# INLINE word64be #-}
getWord64le :: Get Word64
getWord64le :: Get Word64
getWord64le = forall a. Int -> (ByteString -> a) -> Get a
readN Int
8 ByteString -> Word64
word64le
word64le :: B.ByteString -> Word64
word64le :: ByteString -> Word64
word64le = \ByteString
s ->
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
7) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
56) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
6) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
48) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
5) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
40) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
4) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
32) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
3) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
24) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
2) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
16) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
1) forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
8) forall a. Bits a => a -> a -> a
.|.
(forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString
s ByteString -> Int -> Word8
`B.unsafeIndex` Int
0) )
{-# INLINE[2] getWord64le #-}
{-# INLINE word64le #-}
getInt16be :: Get Int16
getInt16be :: Get Int16
getInt16be = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word16
getWord16be
{-# INLINE getInt16be #-}
getInt32be :: Get Int32
getInt32be :: Get Int32
getInt32be = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32be
{-# INLINE getInt32be #-}
getInt64be :: Get Int64
getInt64be :: Get Int64
getInt64be = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64be
{-# INLINE getInt64be #-}
getInt16le :: Get Int16
getInt16le :: Get Int16
getInt16le = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word16
getWord16le
{-# INLINE getInt16le #-}
getInt32le :: Get Int32
getInt32le :: Get Int32
getInt32le = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32le
{-# INLINE getInt32le #-}
getInt64le :: Get Int64
getInt64le :: Get Int64
getInt64le = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64le
{-# INLINE getInt64le #-}
getWordhost :: Get Word
getWordhost :: Get Word
getWordhost = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Word))
{-# INLINE getWordhost #-}
getWord16host :: Get Word16
getWord16host :: Get Word16
getWord16host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Word16))
{-# INLINE getWord16host #-}
getWord32host :: Get Word32
getWord32host :: Get Word32
getWord32host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Word32))
{-# INLINE getWord32host #-}
getWord64host :: Get Word64
getWord64host :: Get Word64
getWord64host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Word64))
{-# INLINE getWord64host #-}
getInthost :: Get Int
getInthost :: Get Int
getInthost = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Int))
{-# INLINE getInthost #-}
getInt16host :: Get Int16
getInt16host :: Get Int16
getInt16host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Int16))
{-# INLINE getInt16host #-}
getInt32host :: Get Int32
getInt32host :: Get Int32
getInt32host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Int32))
{-# INLINE getInt32host #-}
getInt64host :: Get Int64
getInt64host :: Get Int64
getInt64host = forall a. Storable a => Int -> Get a
getPtr (forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: Int64))
{-# INLINE getInt64host #-}
getFloatbe :: Get Float
getFloatbe :: Get Float
getFloatbe = Word32 -> Float
wordToFloat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32be
{-# INLINE getFloatbe #-}
getFloatle :: Get Float
getFloatle :: Get Float
getFloatle = Word32 -> Float
wordToFloat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32le
{-# INLINE getFloatle #-}
getFloathost :: Get Float
getFloathost :: Get Float
getFloathost = Word32 -> Float
wordToFloat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32host
{-# INLINE getFloathost #-}
getDoublebe :: Get Double
getDoublebe :: Get Double
getDoublebe = Word64 -> Double
wordToDouble forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64be
{-# INLINE getDoublebe #-}
getDoublele :: Get Double
getDoublele :: Get Double
getDoublele = Word64 -> Double
wordToDouble forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64le
{-# INLINE getDoublele #-}
getDoublehost :: Get Double
getDoublehost :: Get Double
getDoublehost = Word64 -> Double
wordToDouble forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64host
{-# INLINE getDoublehost #-}