Read-bytes$
Flexible macro for reading and combining 1, 2, 4, or 8 bytes from an
open :byte input stream into a single value.
General form:
(read-bytes$ channel
[:bytes bytes] ;; default: 1
[:signed signed] ;; default: nil
[:end end] ;; default: :big
)
-->
(mv value state)
- If you provide bytes, it must be explicitly 1, 2, 4, or 8.
- If you provide signed, it must be either t or nil.
- If you provide end, it must be either :big or :little. (For
the 1-byte readers, end does not matter.)
Read-byte$ is a macro that expands into the appropriate function from
the table below.
Name Bytes Read Value Range Endian-ness
---------------------------------------------------------------
read-byte$ 1 [0, 2^8-1] N/A
read-8s 1 [-2^7, 2^7-1] N/A
read-16ube 2 [0, 2^16-1] Big Endian
read-16ule 2 [0, 2^16-1] Little Endian
read-16sbe 2 [-2^15, 2^15-1] Big Endian
read-16sle 2 [-2^15, 2^15-1] Little Endian
read-32ube 4 [0, 2^32-1] Big Endian
read-32ule 4 [0, 2^32-1] Little Endian
read-32sbe 4 [-2^31, 2^31-1] Big Endian
read-32sle 4 [-2^31, 2^31-1] Little Endian
read-64ube 8 [0, 2^64-1] Big Endian
read-64ule 8 [0, 2^64-1] Little Endian
read-64sbe 8 [-2^63, 2^63-1] Big Endian
read-64sle 8 [-2^63, 2^63-1] Little Endian
---------------------------------------------------------------
Subtopics
- Read-64ule
- (read-64ule channel state) reads a 64-bit, unsigned, little-endian value from
the input channel.
- Read-64ube
- (read-64ube channel state) reads a 64-bit, unsigned, big-endian value from
the input channel.
- Read-64sle
- (read-64sle channel state) reads a 64-bit, signed, big-endian value from the
input channel.
- Read-64sbe
- (read-64sbe channel state) reads a 64-bit, signed, big-endian value from the
input channel.
- Read-32ule
- (read-32ule channel state) reads a 32-bit, unsigned, little-endian value
from the input channel.
- Read-32sle
- (read-32sle channel state) reads a 32-bit, signed, little-endian value from
the input channel.
- Read-32sbe
- (read-32sbe channel state) reads a 32-bit, signed, big-endian value from the
input channel.
- Read-32ube
- (read-32ube channel state) reads a 32-bit, unsigned, big-endian value from
the input channel.
- Read-16sle
- (read-16sle channel state) reads a 16-bit, signed, little-endian value from
the input channel.
- Read-16sbe
- (read-16sbe channel state) reads a 16-bit, signed, big-endian value from the
input channel.
- Read-16ule
- (read-16ule channel state) reads a 16-bit, unsigned, little-endian value
from the input channel.
- Read-16ube
- (read-16ube channel state) reads a 16-bit, unsigned, big-endian value from
the input channel.
- Read-8s
- (read-8s channel state) reads a signed byte from the input channel.
- Combine-functions
- Optimized byte-combining functions.