| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Value
Description
How a value is delimited on the wire, apart from packets and from what is
done with the value. A value is read in two steps: cellHead reads its
delimiter, and the caller then says what it wants of the payload, which is
all of it (wholeValueBytes), its pieces as they arrive (valueStream) or
nothing (skipValue).
Synopsis
- data Row
- rowColumnCount :: Row -> Int
- rowCell :: Row -> Int -> RawBytes
- rowCellLength :: Row -> Int -> Int
- rowValues :: Row -> [RawBytes]
- rowFromValues :: [RawBytes] -> Row
- data ColumnShape
- data Cell
- cellLength :: Cell -> Maybe Int64
- rowShape :: TypeInfo -> ColumnShape
- valueShape :: TypeInfo -> ColumnShape
- cellHead :: ColumnShape -> Parser Cell
- valueStream :: Cell -> Stream (Of ByteString) Parser ()
- boundedValue :: Int -> Int -> Cell -> Parser (Either (Stream (Of ByteString) Parser ()) WholeValue)
- data WholeValue
- wholeValueBytes :: Int -> Cell -> Parser WholeValue
- ownedValue :: Int -> Cell -> Parser RawBytes
- skipValue :: Cell -> Parser ()
- foldValue :: (a -> Int -> Parser a) -> a -> Cell -> Parser a
- rowBitmap :: Int -> Parser ByteString
- columnNull :: ByteString -> Int -> Bool
- cellAt :: ByteString -> Int -> ColumnShape -> Parser Cell
- skipCells :: ByteString -> [(Int, ColumnShape)] -> Parser ()
Documentation
A row's values, each read whole into bytes of its own, for the token-level
interface (TRow). A typed row decoder never builds one.
rowColumnCount :: Row -> Int Source #
How many columns the row has.
rowCell :: Row -> Int -> RawBytes Source #
The value at a column, counted from 0; error past the last.
rowFromValues :: [RawBytes] -> Row Source #
A row from its values.
data ColumnShape Source #
How a column's values are delimited, chosen once from its metadata. A
value with no delimiter of its own (a fixed width, or no value at all) keeps
its Cell here, so that every row shares it.
Constructors
| ConstantCell !Cell | |
| ByteLength | |
| ShortLength | |
| LongLength | |
| TextPointer | |
| Variant | |
| PlpValue |
Instances
| Show ColumnShape Source # | |
Defined in Hmssql.Tds.Value Methods showsPrec :: Int -> ColumnShape -> ShowS # show :: ColumnShape -> String # showList :: [ColumnShape] -> ShowS # | |
| Eq ColumnShape Source # | |
Defined in Hmssql.Tds.Value | |
What a value's delimiter said: NULL, a known length, or a PLP value whose total length may or may not be known. The payload still follows.
cellLength :: Cell -> Maybe Int64 Source #
The value's declared length, if it has one that fits an Int64.
rowShape :: TypeInfo -> ColumnShape Source #
How a column's value is delimited in a ROW: as valueShape says, with a
text pointer and timestamp in front of a legacy text, ntext or image
value.
valueShape :: TypeInfo -> ColumnShape Source #
How a RETURNVALUE's value is delimited: as a column's, except that a legacy
text, ntext or image value has no text pointer in front of it.
cellHead :: ColumnShape -> Parser Cell Source #
Read a value's delimiter. Each form has its own way to say NULL.
valueStream :: Cell -> Stream (Of ByteString) Parser () Source #
The value's payload as it arrives, in pieces. A PLP value's chunk headers are read here and never appear in the stream.
boundedValue :: Int -> Int -> Cell -> Parser (Either (Stream (Of ByteString) Parser ()) WholeValue) Source #
A value for a consumer: read whole (Right) if it is at most this many bytes,
given the allocation bound of wholeValueBytes and the limit, or else its payload
as it arrives (Left, as valueStream). A PLP value whose total isn't known
(xml, and json) is read a chunk at a time until it ends within the limit;
once a chunk would take it past, the stream starts with the chunks already read,
so at most the limit is ever held. A whole value is Owned unless it lay in one
payload, and a drain that takes over while it is read gives DiscardedValue.
data WholeValue Source #
A value read whole: NULL, present, or discarded because a drain took over the response while the value was being assembled.
Constructors
| NullValue | |
| PresentValue !ValueBytes | |
| DiscardedValue |
wholeValueBytes :: Int -> Cell -> Parser WholeValue Source #
Read all of a value: a slice if it lies in the buffer, otherwise one buffer of its own.
ownedValue :: Int -> Cell -> Parser RawBytes Source #
Read all of a value into bytes of its own, as an output parameter's value is kept. A value discarded by a drain comes back as empty bytes, which only the drain sees.
foldValue :: (a -> Int -> Parser a) -> a -> Cell -> Parser a Source #
Fold over the pieces of a value's payload: one piece for a sized value, or a PLP value's chunks, with the chunk headers read here. The step must consume exactly the length it is given, whether it reads, collects or skips.
rowBitmap :: Int -> Parser ByteString Source #
A row's token byte, and an NBCROW's null bitmap. Empty means a ROW, where each delimiter says for itself whether its value is NULL.
columnNull :: ByteString -> Int -> Bool Source #
Whether the bitmap marks this column NULL, in which case it has no bytes at all.
cellAt :: ByteString -> Int -> ColumnShape -> Parser Cell Source #
Read one column's delimiter, including its NBCROW null bit.
skipCells :: ByteString -> [(Int, ColumnShape)] -> Parser () Source #
Read past these columns of a row, given as their indexes and shapes.