{-# LANGUAGE CPP, MagicHash #-}
{-# LANGUAGE Safe #-}
module Data.Binary.Builder (
Builder
, toLazyByteString
, empty
, singleton
, append
, fromByteString
, fromLazyByteString
#if MIN_VERSION_bytestring(0,10,4)
, fromShortByteString
#endif
, flush
, putWord16be
, putWord32be
, putWord64be
, putInt16be
, putInt32be
, putInt64be
, putWord16le
, putWord32le
, putWord64le
, putInt16le
, putInt32le
, putInt64le
, putWordhost
, putWord16host
, putWord32host
, putWord64host
, putInthost
, putInt16host
, putInt32host
, putInt64host
, putCharUtf8
, putStringUtf8
) where
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
#if MIN_VERSION_bytestring(0,10,4)
import qualified Data.ByteString.Short as T
#endif
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Prim as Prim
import Data.ByteString.Builder ( Builder, toLazyByteString )
import Data.ByteString.Builder.Extra ( flush )
import Data.Monoid
import Data.Word
import Data.Int
import Prelude
empty :: Builder
empty :: Builder
empty = Builder
forall a. Monoid a => a
mempty
{-# INLINE empty #-}
singleton :: Word8 -> Builder
singleton :: Word8 -> Builder
singleton = Word8 -> Builder
B.word8
{-# INLINE singleton #-}
append :: Builder -> Builder -> Builder
append :: Builder -> Builder -> Builder
append = Builder -> Builder -> Builder
forall a. Monoid a => a -> a -> a
mappend
{-# INLINE append #-}
fromByteString :: S.ByteString -> Builder
fromByteString :: ByteString -> Builder
fromByteString = ByteString -> Builder
B.byteString
{-# INLINE fromByteString #-}
fromLazyByteString :: L.ByteString -> Builder
fromLazyByteString :: ByteString -> Builder
fromLazyByteString = ByteString -> Builder
B.lazyByteString
{-# INLINE fromLazyByteString #-}
#if MIN_VERSION_bytestring(0,10,4)
fromShortByteString :: T.ShortByteString -> Builder
fromShortByteString :: ShortByteString -> Builder
fromShortByteString = ShortByteString -> Builder
B.shortByteString
{-# INLINE fromShortByteString #-}
#endif
putWord16be :: Word16 -> Builder
putWord16be :: Word16 -> Builder
putWord16be = Word16 -> Builder
B.word16BE
{-# INLINE putWord16be #-}
putWord16le :: Word16 -> Builder
putWord16le :: Word16 -> Builder
putWord16le = Word16 -> Builder
B.word16LE
{-# INLINE putWord16le #-}
putWord32be :: Word32 -> Builder
putWord32be :: Word32 -> Builder
putWord32be = Word32 -> Builder
B.word32BE
{-# INLINE putWord32be #-}
putWord32le :: Word32 -> Builder
putWord32le :: Word32 -> Builder
putWord32le = Word32 -> Builder
B.word32LE
{-# INLINE putWord32le #-}
putWord64be :: Word64 -> Builder
putWord64be :: Word64 -> Builder
putWord64be = Word64 -> Builder
B.word64BE
{-# INLINE putWord64be #-}
putWord64le :: Word64 -> Builder
putWord64le :: Word64 -> Builder
putWord64le = Word64 -> Builder
B.word64LE
{-# INLINE putWord64le #-}
putInt16be :: Int16 -> Builder
putInt16be :: Int16 -> Builder
putInt16be = Int16 -> Builder
B.int16BE
{-# INLINE putInt16be #-}
putInt16le :: Int16 -> Builder
putInt16le :: Int16 -> Builder
putInt16le = Int16 -> Builder
B.int16LE
{-# INLINE putInt16le #-}
putInt32be :: Int32 -> Builder
putInt32be :: Int32 -> Builder
putInt32be = Int32 -> Builder
B.int32BE
{-# INLINE putInt32be #-}
putInt32le :: Int32 -> Builder
putInt32le :: Int32 -> Builder
putInt32le = Int32 -> Builder
B.int32LE
{-# INLINE putInt32le #-}
putInt64be :: Int64 -> Builder
putInt64be :: Int64 -> Builder
putInt64be = Int64 -> Builder
B.int64BE
putInt64le :: Int64 -> Builder
putInt64le :: Int64 -> Builder
putInt64le = Int64 -> Builder
B.int64LE
putWordhost :: Word -> Builder
putWordhost :: Word -> Builder
putWordhost = FixedPrim Word -> Word -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Word
Prim.wordHost
{-# INLINE putWordhost #-}
putWord16host :: Word16 -> Builder
putWord16host :: Word16 -> Builder
putWord16host = FixedPrim Word16 -> Word16 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Word16
Prim.word16Host
{-# INLINE putWord16host #-}
putWord32host :: Word32 -> Builder
putWord32host :: Word32 -> Builder
putWord32host = FixedPrim Word32 -> Word32 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Word32
Prim.word32Host
{-# INLINE putWord32host #-}
putWord64host :: Word64 -> Builder
putWord64host :: Word64 -> Builder
putWord64host = FixedPrim Word64 -> Word64 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Word64
Prim.word64Host
{-# INLINE putWord64host #-}
putInthost :: Int -> Builder
putInthost :: Int -> Builder
putInthost = FixedPrim Int -> Int -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Int
Prim.intHost
{-# INLINE putInthost #-}
putInt16host :: Int16 -> Builder
putInt16host :: Int16 -> Builder
putInt16host = FixedPrim Int16 -> Int16 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Int16
Prim.int16Host
{-# INLINE putInt16host #-}
putInt32host :: Int32 -> Builder
putInt32host :: Int32 -> Builder
putInt32host = FixedPrim Int32 -> Int32 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Int32
Prim.int32Host
{-# INLINE putInt32host #-}
putInt64host :: Int64 -> Builder
putInt64host :: Int64 -> Builder
putInt64host = FixedPrim Int64 -> Int64 -> Builder
forall a. FixedPrim a -> a -> Builder
Prim.primFixed FixedPrim Int64
Prim.int64Host
{-# INLINE putInt64host #-}
putCharUtf8 :: Char -> Builder
putCharUtf8 :: Char -> Builder
putCharUtf8 = BoundedPrim Char -> Char -> Builder
forall a. BoundedPrim a -> a -> Builder
Prim.primBounded BoundedPrim Char
Prim.charUtf8
{-# INLINE putCharUtf8 #-}
putStringUtf8 :: String -> Builder
putStringUtf8 :: String -> Builder
putStringUtf8 = BoundedPrim Char -> String -> Builder
forall a. BoundedPrim a -> [a] -> Builder
Prim.primMapListBounded BoundedPrim Char
Prim.charUtf8
{-# INLINE putStringUtf8 #-}