| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Bytes
Contents
Description
Bounds-checked little-endian (and two big-endian) reads from a
ByteString at an offset: what the value decoders use once a value's
length has been checked against its type.
No Get, no intermediate ByteString, and no pointers here:
each reader checks that the n bytes at off lie within the buffer (calling
error if they don't, as index does: a read can never touch memory
outside the buffer, whatever the caller got wrong), then assembles the value
from its bytes. Raw pointer operations, for the character codecs, are in
Hmssql.Tds.Bytes.Unsafe.
The parser and the scalar codecs read with these. A field conversion receives a whole value, so it never needs an offset into a packet.
Synopsis
- word8At :: ByteString -> Int -> Word8
- word16LeAt :: ByteString -> Int -> Word16
- word32LeAt :: ByteString -> Int -> Word32
- word64LeAt :: ByteString -> Int -> Word64
- word16BeAt :: ByteString -> Int -> Word16
- word64BeAt :: ByteString -> Int -> Word64
- wordLeAt :: Int -> ByteString -> Int -> Word64
- int8At :: ByteString -> Int -> Int8
- int16LeAt :: ByteString -> Int -> Int16
- int32LeAt :: ByteString -> Int -> Int32
- int64LeAt :: ByteString -> Int -> Int64
- spanWithin :: Int -> Int -> Int -> Bool
- checkSpan :: String -> ByteString -> Int -> Int -> ()
Checked reads from a buffer
word16LeAt :: ByteString -> Int -> Word16 Source #
word32LeAt :: ByteString -> Int -> Word32 Source #
word64LeAt :: ByteString -> Int -> Word64 Source #
word16BeAt :: ByteString -> Int -> Word16 Source #
Big-endian: a packet header's fields, and a GUID's last eight bytes.
word64BeAt :: ByteString -> Int -> Word64 Source #
wordLeAt :: Int -> ByteString -> Int -> Word64 Source #
An unsigned little-endian integer of n bytes (0 through 8).
Spans
spanWithin :: Int -> Int -> Int -> Bool Source #
Whether len bytes at off lie within a buffer of size bytes:
0 <= off, 0 <= len and off + len <= size, checked without
overflowing.
checkSpan :: String -> ByteString -> Int -> Int -> () Source #
error unless the span lies within the buffer (spanWithin).