Common Lisp Package: VARINT

Variable-size encoding and decoding of integers and floats

README:

FUNCTION

Public

ENCODE-UINT32 (BUFFER INDEX V)

Encode V, an unsigned 32-bit integer, into BUFFER at INDEX.

ENCODE-UINT32-CAREFULLY (BUFFER INDEX LIMIT V)

Encode V, an unsigned 32-bit integer, into BUFFER at INDEX, taking care to never write past position LIMIT. If writing past LIMIT is required to encode V, then raise ENCODE-OVERFLOW.

ENCODE-UINT64 (BUFFER INDEX V)

Encode V, an unsigned 64-bit integer, into BUFFER at INDEX.

ENCODE-UINT64-CAREFULLY (BUFFER INDEX LIMIT V)

Encode V, an unsigned 64-bit integer, into BUFFER at INDEX, taking care to never write past position LIMIT. If writing past LIMIT is required to encode V, then raise ENCODE-OVERFLOW.

Undocumented

LENGTH32 (V)

LENGTH64 (V)

PARSE-INT32-CAREFULLY (BUFFER INDEX LIMIT)

PARSE-INT64-CAREFULLY (BUFFER INDEX LIMIT)

PARSE-UINT31-CAREFULLY (BUFFER INDEX LIMIT)

PARSE-UINT32 (BUFFER INDEX)

PARSE-UINT32-CAREFULLY (BUFFER INDEX LIMIT)

PARSE-UINT64 (BUFFER INDEX)

PARSE-UINT64-CAREFULLY (BUFFER INDEX LIMIT)

PARSE32-BACKWARD (BUFFER INDEX BASE)

PARSE32-BACKWARD-SLOW (BUFFER INDEX BASE)

PARSE64-BACKWARD (BUFFER INDEX BASE)

PARSE64-BACKWARD-SLOW (BUFFER INDEX BASE)

SKIP32-BACKWARD (BUFFER INDEX BASE)

SKIP32-BACKWARD-SLOW (BUFFER INDEX BASE)

SKIP32-CAREFULLY (BUFFER INDEX LIMIT)

SKIP64-BACKWARD (BUFFER INDEX BASE)

SKIP64-BACKWARD-SLOW (BUFFER INDEX BASE)

SKIP64-CAREFULLY (BUFFER INDEX LIMIT)

CONDITION

Public

ALIGNMENT

Data buffer does not contain the type of value we have been asked to skip over or parse backwards.

BUFFER-OVERFLOW

Buffer space exhausted while encoding a value.

DATA-EXHAUSTED

Decoding a value requires more data than is available.

ENCODING-ERROR

Superclass of all VARINT encoding conditions.

PARSING-ERROR

Superclass of all VARINT decoding conditions.

VALUE-OUT-OF-RANGE

Value decoded is outside the range of the return type.

VARINT-ERROR

Superclass of all VARINT conditions.

CONSTANT

Public

+MAX-OCTETS-32+

Maximum number of octets needed to encode a 32-bit integer.

+MAX-OCTETS-64+

Maximum number of octets needed to encode a 64-bit integer.