All heap-allocated objects in OpenMCL that cannot contain pointers to lisp objects are represented as ivectors. OpenMCL provides low-level functions to efficiently transfer data between buffered streams and ivectors. and buffered streams. There's some overlap in functionality between the functions described here and the ANSI CL READ-SEQUENCE and WRITE-SEQUENCE functions.
As used here, the term "octet" means roughly the same thing as the term "8-bit byte". The functions described below transfer a specified sequence of octets between a buffered stream and an ivector, and don't really concern themselves with higher-level issues (like whether that octet sequence is within bounds or how it relates to the logical contents of the ivector.) For these reasons, these functions are generally less safe and more flexible than their ANSI counterparts.
Syntax | stream-read-ivector stream ivector start-octet max-octets |
Description | Reads up to max-octets octets from stream into ivector, storing them at start-octet. Returns the number of octets actually read. |
Arguments |
|
Syntax | stream-write-ivector stream ivector start-octet max-octets |
Description | Writes max-octets octets to stream from ivector, starting at start-octet. Returns max-octets. |
Arguments |
|
;;; Write the contents of a (SIMPLE-ARRAY (UNSIGNED-BYTE 16) 3) to a ;;; character file stream. Read back the characters. (let* ((a (make-array 3 :element-type '(unsigned-byte 16) :initial-contents '(26725 27756 28449)))) (with-open-file (s "junk" :element-type 'character :direction :io :if-does-not-exist :create :if-exists :supersede) ;; Write six octets (three elements). (stream-write-ivector s a 0 6) ;; Rewind, then read a line (file-position s 0) (read-line s))) ;;; Write a vector of DOUBLE-FLOATs. Note that (to maintain ;;; alignment) there are 4 octets of padding before the 0th element of ;;; a (VECTOR DOUBLE-FLOAT). ;;; (Note that (= (- arch::misc-dfloat-offset arch::misc-data-offset) 4)) (defun write-double-float-vector (stream vector &key (start 0) (end (length vector))) (check-type vector (vector double-float)) (let* ((start-octet (+ (* start 8) (- arch::misc-dfloat-offset arch::misc-data-offset))) (num-octets (* 8 (- end start)))) (stream-write-ivector stream vector start-octet num-octets)))Last modified: Tue Sep 11 02:00:32 PDT 2001