Copyright | (c) 2013 Leon P Smith |
---|---|
License | BSD3 |
Maintainer | Leon P Smith <leon@melding-monads.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Write
s and Builder
s for serializing integers.
See Blaze.ByteString.Builder.Word for information about how to best write several integers at once.
- writeInt8 :: Int8 -> Write
- writeInt16be :: Int16 -> Write
- writeInt32be :: Int32 -> Write
- writeInt64be :: Int64 -> Write
- writeInt16le :: Int16 -> Write
- writeInt32le :: Int32 -> Write
- writeInt64le :: Int64 -> Write
- writeInthost :: Int -> Write
- writeInt16host :: Int16 -> Write
- writeInt32host :: Int32 -> Write
- writeInt64host :: Int64 -> Write
- fromInt8 :: Int8 -> Builder
- fromInt8s :: [Int8] -> Builder
- fromInt16be :: Int16 -> Builder
- fromInt32be :: Int32 -> Builder
- fromInt64be :: Int64 -> Builder
- fromInt32sbe :: [Int32] -> Builder
- fromInt16sbe :: [Int16] -> Builder
- fromInt64sbe :: [Int64] -> Builder
- fromInt16le :: Int16 -> Builder
- fromInt32le :: Int32 -> Builder
- fromInt64le :: Int64 -> Builder
- fromInt16sle :: [Int16] -> Builder
- fromInt32sle :: [Int32] -> Builder
- fromInt64sle :: [Int64] -> Builder
- fromInthost :: Int -> Builder
- fromInt16host :: Int16 -> Builder
- fromInt32host :: Int32 -> Builder
- fromInt64host :: Int64 -> Builder
- fromIntshost :: [Int] -> Builder
- fromInt16shost :: [Int16] -> Builder
- fromInt32shost :: [Int32] -> Builder
- fromInt64shost :: [Int64] -> Builder
Writing integers to a buffer
Big-endian writes
Little-endian writes
Host-endian writes
writeInthost :: Int -> Write Source #
Creating builders from integers
We provide serialization functions both for singleton integers as well as
for lists of integers. Using these list serialization functions is much faster
than using mconcat . map fromInt<n>
, as the list serialization
functions use a tighter inner loop.
Big-endian serialization
Little-endian serialization
Host-endian serialization
fromInthost :: Int -> Builder Source #
Serialize a single native machine Int
. The Int
is serialized in host
order, host endian form, for the machine you're on. On a 64 bit machine the
Int
is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this
way are not portable to different endian or integer sized machines, without
conversion.
fromIntshost :: [Int] -> Builder Source #
Serialize a list of Int
s.
See fromInthost
for usage considerations.
fromInt16shost :: [Int16] -> Builder Source #
Write a list of Int16
s in native host order and host endianness.