Next: srfi.78
- Lightweight testing, Previous: srfi.69
- Basic hash tables, Up: Library modules - SRFIs [Contents][Index]
srfi.74
- Octet-addressed binary blocksThis module provides procedures to deal with blob, or a sequence of octets. In Gauche, a blob is simply an u8vector.
Most functionalities of this module is available
in binary.io
module (see binary.io
- Binary I/O), and in fact
this module is a thin wrapper to it.
We provide this module for the compatibility.
If you’re writing Gauche-specific code, we recommend to use
binary.io
directly.
[SRFI-74]{srfi.74}
The argument e must be one of the symbols big
, little
,
or native
. It expands to the implementation-specific
endianness designator. In Gauche, the result is one of the
symbols; see Endianness, for the details.
[SRFI-74]{srfi.74}
Returns a freshly created blob that can hold size octets.
In Gauche, this is the same as (make-u8vector size)
.
[SRFI-74]{srfi.74}
Returns #t
if obj is a blob, #f
otherwise.
In Gauche, this is the same as (u8vector? obj)
.
[SRFI-74]{srfi.74}
Returns the size of the blob, in octets. In Gauche,
this is the same as (u8vector-length blob)
.
[SRFI-74]{srfi.74} Read an unsigned or signed integer of size octets beginning at the position of pos from blob, respectively.
These are wrappers of (get-uint size blob pos endian)
and (get-sint size blob pos endian)
in binary.io
module (see binary.io
- Binary I/O), except that
blob-uint-ref
/blob-sint-ref
only accept u8vector
as blob.
[SRFI-74]{srfi.74} Store an unsigned or signed integer val of size octets into blob starting at the position of pos, respectively.
These are wrappers of (put-uint! size blob pos val endian)
and (put-sint! size blob pos val endian)
in binary.io
module (see binary.io
- Binary I/O), except that
blob-uint-set!
/blob-sint-set!
only accept u8vector
as blob.
[SRFI-74]{srfi.74} Get/set an unsigned or signed integer as a octet at pos from/to blob.
These are wrappers of get-u8
, put-u8!
,
get-s8
and put-s8!
in binary.io
, respectively.
[SRFI-74]{srfi.74} Get/set an unsigned or signed integer of the indicated length at pos from/to blob, using the specified endian.
These are wrappers of corresponding get-XX
and put-XX!
in binary.io
; note that the argument orders differ, though.
[SRFI-74]{srfi.74} Get/set an unsigned or signed integer of the indicated length at pos from/to blob, using the native endianness.
These are wrappers of corresponding get-XX
and put-XX!
in binary.io
; note that the argument orders differ, though.
Note: SRFI-74 only requires these procedures to work with alined pos, which is the multiple of the size of the integer in octets. Gauche doesn’t have such restriction, but keep this in mind when you’re writing a portable code.
[SRFI-74]{srfi.74}
This is the same as u8vector=?
in gauche.uvector
.
[SRFI-74]{srfi.74} Copy n octets from the source blob src starting from sstart into the target blob target starting from tstart.
Note that the order of arguments differs from other *-copy!
procedures (e.g. R7RS’s string-copy!
and vector-copy!
,
and gauche.uvector
’s u8vector-copy!
)), which have the
following signature: (*-copy! target tstart src sstart send)
[SRFI-74]{srfi.74}
Returns a fresh copy of blob. The same as u8vector-copy
in gauche.uvector
.
[SRFI-74]{srfi.74}
Wrappers of u8vector->list
and list->u8vector
, except
those don’t take optional start/end arguments.
[SRFI-74]{srfi.74} Read a sequence of unsigned or signed integers of size octets from blob with endian, and returns them as a list.
(blob->uint-list 3 (endianness big) '#u8(0 0 1 0 0 2 0 0 3)) ⇒ (1 2 3)
[SRFI-74]{srfi.74}
Convert a list of unsigned or signed integers to a blob.
The resulting blob has (* size (length list))
octets.
Each integer occupies size octets.
(uint-list->blob 3 (endianness little) '(1 2 3)) ⇒ #u8(1 0 0 2 0 0 3 0 0)
Next: srfi.78
- Lightweight testing, Previous: srfi.69
- Basic hash tables, Up: Library modules - SRFIs [Contents][Index]