blaze-builder-0.4.2.3: Efficient buffered output.
Copyright(c) 2013 Leon P Smith
LicenseBSD3
Maintainerhttps://github.com/blaze-builder
Stabilitystable
Safe HaskellSafe-Inferred
LanguageHaskell98

Blaze.ByteString.Builder.Int

Description

Writes and Builders for serializing integers.

See Blaze.ByteString.Builder.Word for information about how to best write several integers at once.

Synopsis

Writing integers to a buffer

writeInt8 :: Int8 -> Write Source #

Write a single signed byte.

Big-endian writes

writeInt16be :: Int16 -> Write Source #

Write an Int16 in big endian format.

writeInt32be :: Int32 -> Write Source #

Write an Int32 in big endian format.

writeInt64be :: Int64 -> Write Source #

Write an Int64 in big endian format.

Little-endian writes

writeInt16le :: Int16 -> Write Source #

Write an Int16 in little endian format.

writeInt32le :: Int32 -> Write Source #

Write an Int32 in little endian format.

writeInt64le :: Int64 -> Write Source #

Write an Int64 in little endian format.

Host-endian writes

writeInthost :: Int -> Write Source #

Write a single native machine Int. The Int is written 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.

writeInt16host :: Int16 -> Write Source #

Write an Int16 in native host order and host endianness.

writeInt32host :: Int32 -> Write Source #

Write an Int32 in native host order and host endianness.

writeInt64host :: Int64 -> Write Source #

Write an Int64 in native host order and host endianness.

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.

fromInt8 :: Int8 -> Builder Source #

Serialize a single byte.

fromInt8s :: [Int8] -> Builder Source #

Serialize a list of bytes.

Big-endian serialization

fromInt16be :: Int16 -> Builder Source #

Serialize an Int16 in big endian format.

fromInt32be :: Int32 -> Builder Source #

Serialize an Int32 in big endian format.

fromInt64be :: Int64 -> Builder Source #

Serialize an Int64 in big endian format.

fromInt32sbe :: [Int32] -> Builder Source #

Serialize a list of Int32s in big endian format.

fromInt16sbe :: [Int16] -> Builder Source #

Serialize a list of Int16s in big endian format.

fromInt64sbe :: [Int64] -> Builder Source #

Serialize a list of Int64s in big endian format.

Little-endian serialization

fromInt16le :: Int16 -> Builder Source #

Serialize an Int16 in little endian format.

fromInt32le :: Int32 -> Builder Source #

Serialize an Int32 in little endian format.

fromInt64le :: Int64 -> Builder Source #

Serialize an Int64 in little endian format.

fromInt16sle :: [Int16] -> Builder Source #

Serialize a list of Int16s in little endian format.

fromInt32sle :: [Int32] -> Builder Source #

Serialize a list of Int32s in little endian format.

fromInt64sle :: [Int64] -> Builder Source #

Serialize a list of Int64s in little endian format.

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.

fromInt16host :: Int16 -> Builder Source #

Write an Int16 in native host order and host endianness.

fromInt32host :: Int32 -> Builder Source #

Write an Int32 in native host order and host endianness.

fromInt64host :: Int64 -> Builder Source #

Write an Int64 in native host order and host endianness.

fromIntshost :: [Int] -> Builder Source #

Serialize a list of Ints. See fromInthost for usage considerations.

fromInt16shost :: [Int16] -> Builder Source #

Write a list of Int16s in native host order and host endianness.

fromInt32shost :: [Int32] -> Builder Source #

Write a list of Int32s in native host order and host endianness.

fromInt64shost :: [Int64] -> Builder Source #

Write a list of Int64s in native host order and host endianness.