wiki:VectorStreams

Version 2 (modified by gb, 4 years ago) (diff)

integer encoding/decoding functions use fixed-length fields, not LEB128

Vector streams are similar to STRING streams but use vectors of (UNSIGNED-BYTE 8) and allow binary as well as character I/O.

[Type]
VECTOR-INPUT-STREAM

Type of input vector streams.

[Type]
VECTOR-OUTPUT-STREAM

Type of output vector streams.

[Function]
MAKE-VECTOR-OUTPUT-STREAM &key external-format

Returns a VECTOR-OUTPUT-STREAM. Character output on that stream is encoded according to the specified external format (which is handled as it is by other CCL stream classes.)

[Function]
GET-OUTPUT-STREAM-VECTOR s

S should be a VECTOR-OUTPUT-STREAM. Returns a (SIMPLE-ARRAY (UNSIGNED-BYTE) (*)) of all bytes written to S since it was created or since the last call GET-OUTPUT-STREAM-VECTOR on S.

[Macro]
WITH-OUTPUT-TO-VECTOR var &optional vector &key external-format &body body

Like WITH-OUTPUT-TO-STRING (too much like it, in fact.) Executes BODY with VAR bound to a VECTOR-OUTPUT-STREAM. If VECTOR is non-null, it should be a (VECTOR (UNSIGNED-BYTE 8)) with a fill-pointer; the value(s) returned by BODY are returned and the vector's contents and fill-pointer are updated at the end of the WITH-OUTPUT-TO-VECTOR form. If VECTOR is NIL, returns the result of (GET-OUTPUT-STREAM-VECTOR var) after executing BODY.

[Macro]
WITH-INPUT-FROM-VECTOR var vector &key (start 0) end external-format &body body

Like WITH-INPUT-FROM-STRING. VECTOR should be a (VECTOR (UNSIGNED-BYTE 8)). Executes BODY with VAR bound to a VECTOR-INPUT-STREAM constructed from VECTOR (bounded by START and END.)

[Function]
UNSIGNED-INTEGER-TO-BINARY value len s

Encodes the least significant (* LEN 8) bits of the integer VALUE in LEN big-endian bytes on the VECTOR-OUTPUT-STREAM S.

[Function]
SIGNED-INTEGER-TO-BINARY value len s

Encodes the integer VALUE in LEN big-endian bytes on the VECTOR-OUTPUT-STREAM S.

[Function]
PARSE-UNSIGNED-INTEGER vector &optional (start 0) end

Decodes a big-endian-encoded unsigned integer from the bounded range of VECTOR, which must be of type (VECTOR (UNSIGNED-BYTE 8)).

[Function]
PARSE-SIGNED-INTEGER vector &optional (start 0) end

As PARSE-UNSIGNED-INTEGER, but interprets the bytes as encoding a signed integer and may return a negative value.

[Function]
PUI-STREAM s count

Decodes an unsigned integer encoded in COUNT bytes of big-endian data from the VECTOR-INPUT-STREAM S and returns that value.

[Function]
PSI-STREAM s count

Decodes a signed integer encoded in COUNT bytes of big-endian data from the VECTOR-INPUT-STREAM S and returns that value.