For Gauche 0.9.6


Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]

11.17 srfi-74 - Octet-addressed binary blocks

Module: srfi-74

This 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 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.

Macro: endianness e

[SRFI-74] {srfi-74} The argument e must be either 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.

Function: make-blob size

[SRFI-74] {srfi-74} Returns a freshly created blob that can hold size octets. In Gauche, this is the same as (make-u8vector size).

Function: blob? obj

[SRFI-74] {srfi-74} Returns #t if obj is a blob, #f otherwise. In Gauche, this is the same as (u8vector? obj).

Function: blob-length blob

[SRFI-74] {srfi-74} Returns the size of the blob, in octets. In Gauche, this is the same as (u8vector-length blob).

Function: blob-uint-ref size endian blob pos
Function: blob-sint-ref size endian blob pos

[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 I/O), except that blob-uint-ref/blob-sint-ref only accept u8vector as blob.

Function: blob-uint-set! size endian blob pos val
Function: blob-sint-set! size endian blob pos val

[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 I/O), except that blob-uint-set!/blob-sint-set! only accept u8vector as blob.

Function: blob-u8-ref blob pos
Function: blob-u8-set! blob pos val
Function: blob-s8-ref blob pos
Function: blob-s8-set! blob pos val

[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.

Function: blob-u16-ref endian blob pos
Function: blob-u16-set! endian blob pos val
Function: blob-s16-ref endian blob pos
Function: blob-s16-set! endian blob pos val
Function: blob-u32-ref endian blob pos
Function: blob-u32-set! endian blob pos val
Function: blob-s32-ref endian blob pos
Function: blob-s32-set! endian blob pos val
Function: blob-u64-ref endian blob pos
Function: blob-u64-set! endian blob pos val
Function: blob-s64-ref endian blob pos
Function: blob-s64-set! endian blob pos val

[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.

Function: blob-u16-native-ref blob pos
Function: blob-u16-native-set! blob pos val
Function: blob-s16-native-ref blob pos
Function: blob-s16-native-set! blob pos val
Function: blob-u32-native-ref blob pos
Function: blob-u32-native-set! blob pos val
Function: blob-s32-native-ref blob pos
Function: blob-s32-native-set! blob pos val
Function: blob-u64-native-ref blob pos
Function: blob-u64-native-set! blob pos val
Function: blob-s64-native-ref blob pos
Function: blob-s64-native-set! blob pos val

[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.

Function: blob=? blob1 blob2

[SRFI-74] {srfi-74} This is the same as u8vector=? in gauche.uvector.

Function: blob-copy! src sstart target tstart n

[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 gauhce.uvector’s u8vector-copy!)), which have the following signature: (*-copy! target tstart src sstart send)

Function: blob-copy blob

[SRFI-74] {srfi-74} Returns a fresh copy of blob. The same as u8vector-copy in gauche.uvector.

Function: blob->u8-list blob
Function: u8-list->blob list

[SRFI-74] {srfi-74} Wrappers of u8vector->list and list->u8vector, except those don’t take optional start/end arguments.

Function: blob->uint-list size endian blob
Function: blob->sint-list size endian blob

[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)
Function: uint-list->blob size endian list
Function: sint-list->blob size endian list

[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: , Previous: , Up: Library modules - SRFIs   [Contents][Index]