gi-gstbase-1.0.12: GStreamerBase bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.GstBase.Structs.ByteReader

Contents

Description

ByteReader provides a byte reader that can read different integer and floating point types from a memory buffer. It provides functions for reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to read NUL-terminated strings in various character encodings.

Synopsis

Exported types

newtype ByteReader Source #

Instances

WrappedPtr ByteReader Source # 
(~) AttrOpTag tag AttrSet => Constructible ByteReader tag Source # 
((~) * info (ResolveByteReaderMethod t ByteReader), MethodInfo * info ByteReader p) => IsLabel t (ByteReader -> p) Source # 

Methods

fromLabel :: Proxy# Symbol t -> ByteReader -> p #

((~) * info (ResolveByteReaderMethod t ByteReader), MethodInfo * info ByteReader p) => IsLabelProxy t (ByteReader -> p) Source # 

Methods

fromLabelProxy :: Proxy Symbol t -> ByteReader -> p #

HasAttributeList * ByteReader Source # 
((~) * signature (m Bool), MonadIO m) => MethodInfo * ByteReaderSkipStringUtf8MethodInfo ByteReader signature Source # 
((~) * signature (m Bool), MonadIO m) => MethodInfo * ByteReaderSkipStringUtf32MethodInfo ByteReader signature Source # 
((~) * signature (m Bool), MonadIO m) => MethodInfo * ByteReaderSkipStringUtf16MethodInfo ByteReader signature Source # 
((~) * signature (Word32 -> m Bool), MonadIO m) => MethodInfo * ByteReaderSkipMethodInfo ByteReader signature Source # 
((~) * signature (Word32 -> m Bool), MonadIO m) => MethodInfo * ByteReaderSetPosMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word8)), MonadIO m) => MethodInfo * ByteReaderPeekUint8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word64)), MonadIO m) => MethodInfo * ByteReaderPeekUint64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word64)), MonadIO m) => MethodInfo * ByteReaderPeekUint64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderPeekUint32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderPeekUint32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderPeekUint24LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderPeekUint24BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word16)), MonadIO m) => MethodInfo * ByteReaderPeekUint16LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word16)), MonadIO m) => MethodInfo * ByteReaderPeekUint16BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, [Text])), MonadIO m) => MethodInfo * ByteReaderPeekStringUtf8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int8)), MonadIO m) => MethodInfo * ByteReaderPeekInt8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int64)), MonadIO m) => MethodInfo * ByteReaderPeekInt64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int64)), MonadIO m) => MethodInfo * ByteReaderPeekInt64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderPeekInt32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderPeekInt32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderPeekInt24LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderPeekInt24BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int16)), MonadIO m) => MethodInfo * ByteReaderPeekInt16LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int16)), MonadIO m) => MethodInfo * ByteReaderPeekInt16BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Double)), MonadIO m) => MethodInfo * ByteReaderPeekFloat64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Double)), MonadIO m) => MethodInfo * ByteReaderPeekFloat64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Float)), MonadIO m) => MethodInfo * ByteReaderPeekFloat32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Float)), MonadIO m) => MethodInfo * ByteReaderPeekFloat32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, ByteString)), MonadIO m) => MethodInfo * ByteReaderPeekDataMethodInfo ByteReader signature Source # 
((~) * signature (Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> m Word32), MonadIO m) => MethodInfo * ByteReaderMaskedScanUint32PeekMethodInfo ByteReader signature Source # 
((~) * signature (Word32 -> Word32 -> Word32 -> Word32 -> m Word32), MonadIO m) => MethodInfo * ByteReaderMaskedScanUint32MethodInfo ByteReader signature Source # 
((~) * signature (ByteString -> m ()), MonadIO m) => MethodInfo * ByteReaderInitMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word8)), MonadIO m) => MethodInfo * ByteReaderGetUint8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word64)), MonadIO m) => MethodInfo * ByteReaderGetUint64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word64)), MonadIO m) => MethodInfo * ByteReaderGetUint64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderGetUint32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderGetUint32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderGetUint24LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word32)), MonadIO m) => MethodInfo * ByteReaderGetUint24BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word16)), MonadIO m) => MethodInfo * ByteReaderGetUint16LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Word16)), MonadIO m) => MethodInfo * ByteReaderGetUint16BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, [Text])), MonadIO m) => MethodInfo * ByteReaderGetStringUtf8MethodInfo ByteReader signature Source # 
((~) * signature (m Word32), MonadIO m) => MethodInfo * ByteReaderGetSizeMethodInfo ByteReader signature Source # 
((~) * signature (m Word32), MonadIO m) => MethodInfo * ByteReaderGetRemainingMethodInfo ByteReader signature Source # 
((~) * signature (m Word32), MonadIO m) => MethodInfo * ByteReaderGetPosMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int8)), MonadIO m) => MethodInfo * ByteReaderGetInt8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int64)), MonadIO m) => MethodInfo * ByteReaderGetInt64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int64)), MonadIO m) => MethodInfo * ByteReaderGetInt64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderGetInt32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderGetInt32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderGetInt24LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int32)), MonadIO m) => MethodInfo * ByteReaderGetInt24BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int16)), MonadIO m) => MethodInfo * ByteReaderGetInt16LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Int16)), MonadIO m) => MethodInfo * ByteReaderGetInt16BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Double)), MonadIO m) => MethodInfo * ByteReaderGetFloat64LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Double)), MonadIO m) => MethodInfo * ByteReaderGetFloat64BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Float)), MonadIO m) => MethodInfo * ByteReaderGetFloat32LeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, Float)), MonadIO m) => MethodInfo * ByteReaderGetFloat32BeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, ByteString)), MonadIO m) => MethodInfo * ByteReaderGetDataMethodInfo ByteReader signature Source # 
((~) * signature (m ()), MonadIO m) => MethodInfo * ByteReaderFreeMethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, [Text])), MonadIO m) => MethodInfo * ByteReaderDupStringUtf8MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, [Word32])), MonadIO m) => MethodInfo * ByteReaderDupStringUtf32MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, [Word16])), MonadIO m) => MethodInfo * ByteReaderDupStringUtf16MethodInfo ByteReader signature Source # 
((~) * signature (m (Bool, ByteString)), MonadIO m) => MethodInfo * ByteReaderDupDataMethodInfo ByteReader signature Source # 
type AttributeList ByteReader Source # 

newZeroByteReader :: MonadIO m => m ByteReader Source #

Construct a ByteReader struct initialized to zero.

Methods

dupData

byteReaderDupData Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, ByteString)

Returns: True if successful, False otherwise.

Free-function: g_free

Returns a newly-allocated copy of the current data position if at least size bytes are left and updates the current position. Free with free when no longer needed.

dupStringUtf16

byteReaderDupStringUtf16 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, [Word16])

Returns: True if a string could be read, False otherwise. The string put into str must be freed with free when no longer needed.

Free-function: g_free

Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-16 string in the data (this could be an empty string as well), and advances the current position.

No input checking for valid UTF-16 is done. This function is endianness agnostic - you should not assume the UTF-16 characters are in host endianness.

This function will fail if no NUL-terminator was found in in the data.

Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-16 string.

dupStringUtf32

byteReaderDupStringUtf32 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, [Word32])

Returns: True if a string could be read, False otherwise. The string put into str must be freed with free when no longer needed.

Free-function: g_free

Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-32 string in the data (this could be an empty string as well), and advances the current position.

No input checking for valid UTF-32 is done. This function is endianness agnostic - you should not assume the UTF-32 characters are in host endianness.

This function will fail if no NUL-terminator was found in in the data.

Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-32 string.

dupStringUtf8

byteReaderDupStringUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, [Text])

Returns: True if a string could be read into str, False otherwise. The string put into str must be freed with free when no longer needed.

Free-function: g_free

FIXME:Reads (copies) a NUL-terminated string in the ByteReader instance, advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.

This function will fail if no NUL-terminator was found in in the data.

free

byteReaderFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m () 

Frees a ByteReader instance, which was previously allocated by gst_byte_reader_new().

getData

byteReaderGetData Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, ByteString)

Returns: True if successful, False otherwise.

Returns a constant pointer to the current data position if at least size bytes are left and updates the current position.

getFloat32Be

byteReaderGetFloat32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Float)

Returns: True if successful, False otherwise.

Read a 32 bit big endian floating point value into val and update the current position.

getFloat32Le

byteReaderGetFloat32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Float)

Returns: True if successful, False otherwise.

Read a 32 bit little endian floating point value into val and update the current position.

getFloat64Be

byteReaderGetFloat64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Double)

Returns: True if successful, False otherwise.

Read a 64 bit big endian floating point value into val and update the current position.

getFloat64Le

byteReaderGetFloat64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Double)

Returns: True if successful, False otherwise.

Read a 64 bit little endian floating point value into val and update the current position.

getInt16Be

byteReaderGetInt16Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int16)

Returns: True if successful, False otherwise.

Read a signed 16 bit big endian integer into val and update the current position.

getInt16Le

byteReaderGetInt16Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int16)

Returns: True if successful, False otherwise.

Read a signed 16 bit little endian integer into val and update the current position.

getInt24Be

byteReaderGetInt24Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 24 bit big endian integer into val and update the current position.

getInt24Le

byteReaderGetInt24Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 24 bit little endian integer into val and update the current position.

getInt32Be

byteReaderGetInt32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 32 bit big endian integer into val and update the current position.

getInt32Le

byteReaderGetInt32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 32 bit little endian integer into val and update the current position.

getInt64Be

byteReaderGetInt64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int64)

Returns: True if successful, False otherwise.

Read a signed 64 bit big endian integer into val and update the current position.

getInt64Le

byteReaderGetInt64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int64)

Returns: True if successful, False otherwise.

Read a signed 64 bit little endian integer into val and update the current position.

getInt8

byteReaderGetInt8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int8)

Returns: True if successful, False otherwise.

Read a signed 8 bit integer into val and update the current position.

getPos

byteReaderGetPos Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Word32

Returns: The current position of reader in bytes.

Returns the current position of a ByteReader instance in bytes.

getRemaining

byteReaderGetRemaining Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Word32

Returns: The remaining number of bytes of reader instance.

Returns the remaining number of bytes of a ByteReader instance.

getSize

byteReaderGetSize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Word32

Returns: The total number of bytes of reader instance.

Returns the total number of bytes of a ByteReader instance.

getStringUtf8

byteReaderGetStringUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, [Text])

Returns: True if a string could be found, False otherwise.

Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator), advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc.

No input checking for valid UTF-8 is done.

This function will fail if no NUL-terminator was found in in the data.

getUint16Be

byteReaderGetUint16Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word16)

Returns: True if successful, False otherwise.

Read an unsigned 16 bit big endian integer into val and update the current position.

getUint16Le

byteReaderGetUint16Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word16)

Returns: True if successful, False otherwise.

Read an unsigned 16 bit little endian integer into val and update the current position.

getUint24Be

byteReaderGetUint24Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 24 bit big endian integer into val and update the current position.

getUint24Le

byteReaderGetUint24Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 24 bit little endian integer into val and update the current position.

getUint32Be

byteReaderGetUint32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 32 bit big endian integer into val and update the current position.

getUint32Le

byteReaderGetUint32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 32 bit little endian integer into val and update the current position.

getUint64Be

byteReaderGetUint64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word64)

Returns: True if successful, False otherwise.

Read an unsigned 64 bit big endian integer into val and update the current position.

getUint64Le

byteReaderGetUint64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word64)

Returns: True if successful, False otherwise.

Read an unsigned 64 bit little endian integer into val and update the current position.

getUint8

byteReaderGetUint8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word8)

Returns: True if successful, False otherwise.

Read an unsigned 8 bit integer into val and update the current position.

init

byteReaderInit Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> ByteString

data: data from which the ByteReader should read

-> m () 

Initializes a ByteReader instance to read from data. This function can be called on already initialized instances.

maskedScanUint32

byteReaderMaskedScanUint32 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader

-> Word32

mask: mask to apply to data before matching against pattern

-> Word32

pattern: pattern to match (after mask is applied)

-> Word32

offset: offset from which to start scanning, relative to the current position

-> Word32

size: number of bytes to scan from offset

-> m Word32

Returns: offset of the first match, or -1 if no match was found.

Example: <programlisting> // Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff

gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 0, 256); // -> returns 0 gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 1, 255); // -> returns -1 gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x01020304, 1, 255); // -> returns 1 gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0001, 0, 256); // -> returns -1 gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0203, 0, 256); // -> returns 0 gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 256); // -> returns 2 gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 4); // -> returns -1 </programlisting>

Scan for pattern pattern with applied mask mask in the byte reader data, starting from offset offset relative to the current position.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader.

maskedScanUint32Peek

byteReaderMaskedScanUint32Peek Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader

-> Word32

mask: mask to apply to data before matching against pattern

-> Word32

pattern: pattern to match (after mask is applied)

-> Word32

offset: offset from which to start scanning, relative to the current position

-> Word32

size: number of bytes to scan from offset

-> Word32

value: pointer to uint32 to return matching data

-> m Word32

Returns: offset of the first match, or -1 if no match was found.

Scan for pattern pattern with applied mask mask in the byte reader data, starting from offset offset relative to the current position.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader.

Since: 1.6

peekData

byteReaderPeekData Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, ByteString)

Returns: True if successful, False otherwise.

Returns a constant pointer to the current data position if at least size bytes are left and keeps the current position.

peekFloat32Be

byteReaderPeekFloat32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Float)

Returns: True if successful, False otherwise.

Read a 32 bit big endian floating point value into val but keep the current position.

peekFloat32Le

byteReaderPeekFloat32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Float)

Returns: True if successful, False otherwise.

Read a 32 bit little endian floating point value into val but keep the current position.

peekFloat64Be

byteReaderPeekFloat64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Double)

Returns: True if successful, False otherwise.

Read a 64 bit big endian floating point value into val but keep the current position.

peekFloat64Le

byteReaderPeekFloat64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Double)

Returns: True if successful, False otherwise.

Read a 64 bit little endian floating point value into val but keep the current position.

peekInt16Be

byteReaderPeekInt16Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int16)

Returns: True if successful, False otherwise.

Read a signed 16 bit big endian integer into val but keep the current position.

peekInt16Le

byteReaderPeekInt16Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int16)

Returns: True if successful, False otherwise.

Read a signed 16 bit little endian integer into val but keep the current position.

peekInt24Be

byteReaderPeekInt24Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 24 bit big endian integer into val but keep the current position.

peekInt24Le

byteReaderPeekInt24Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 24 bit little endian integer into val but keep the current position.

peekInt32Be

byteReaderPeekInt32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 32 bit big endian integer into val but keep the current position.

peekInt32Le

byteReaderPeekInt32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int32)

Returns: True if successful, False otherwise.

Read a signed 32 bit little endian integer into val but keep the current position.

peekInt64Be

byteReaderPeekInt64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int64)

Returns: True if successful, False otherwise.

Read a signed 64 bit big endian integer into val but keep the current position.

peekInt64Le

byteReaderPeekInt64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int64)

Returns: True if successful, False otherwise.

Read a signed 64 bit little endian integer into val but keep the current position.

peekInt8

byteReaderPeekInt8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Int8)

Returns: True if successful, False otherwise.

Read a signed 8 bit integer into val but keep the current position.

peekStringUtf8

byteReaderPeekStringUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, [Text])

Returns: True if a string could be skipped, False otherwise.

Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator). The current position will be maintained. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc.

No input checking for valid UTF-8 is done.

This function will fail if no NUL-terminator was found in in the data.

peekUint16Be

byteReaderPeekUint16Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word16)

Returns: True if successful, False otherwise.

Read an unsigned 16 bit big endian integer into val but keep the current position.

peekUint16Le

byteReaderPeekUint16Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word16)

Returns: True if successful, False otherwise.

Read an unsigned 16 bit little endian integer into val but keep the current position.

peekUint24Be

byteReaderPeekUint24Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 24 bit big endian integer into val but keep the current position.

peekUint24Le

byteReaderPeekUint24Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 24 bit little endian integer into val but keep the current position.

peekUint32Be

byteReaderPeekUint32Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 32 bit big endian integer into val but keep the current position.

peekUint32Le

byteReaderPeekUint32Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word32)

Returns: True if successful, False otherwise.

Read an unsigned 32 bit little endian integer into val but keep the current position.

peekUint64Be

byteReaderPeekUint64Be Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word64)

Returns: True if successful, False otherwise.

Read an unsigned 64 bit big endian integer into val but keep the current position.

peekUint64Le

byteReaderPeekUint64Le Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word64)

Returns: True if successful, False otherwise.

Read an unsigned 64 bit little endian integer into val but keep the current position.

peekUint8

byteReaderPeekUint8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m (Bool, Word8)

Returns: True if successful, False otherwise.

Read an unsigned 8 bit integer into val but keep the current position.

setPos

byteReaderSetPos Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> Word32

pos: The new position in bytes

-> m Bool

Returns: True if the position could be set successfully, False otherwise.

Sets the new position of a ByteReader instance to pos in bytes.

skip

byteReaderSkip Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> Word32

nbytes: the number of bytes to skip

-> m Bool

Returns: True if nbytes bytes could be skipped, False otherwise.

Skips nbytes bytes of the ByteReader instance.

skipStringUtf16

byteReaderSkipStringUtf16 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Bool

Returns: True if a string could be skipped, False otherwise.

Skips a NUL-terminated UTF-16 string in the ByteReader instance, advancing the current position to the byte after the string.

No input checking for valid UTF-16 is done.

This function will fail if no NUL-terminator was found in in the data.

skipStringUtf32

byteReaderSkipStringUtf32 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Bool

Returns: True if a string could be skipped, False otherwise.

Skips a NUL-terminated UTF-32 string in the ByteReader instance, advancing the current position to the byte after the string.

No input checking for valid UTF-32 is done.

This function will fail if no NUL-terminator was found in in the data.

skipStringUtf8

byteReaderSkipStringUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteReader

reader: a ByteReader instance

-> m Bool

Returns: True if a string could be skipped, False otherwise.

Skips a NUL-terminated string in the ByteReader instance, advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.

This function will fail if no NUL-terminator was found in in the data.

Properties

byte

size