All Manuals > LispWorks User Guide and Reference Manual > 49 The SYSTEM Package

NextPrevUpTopContentsIndex

octet-ref

base-char-ref

Functions
Summary

Loads an octet from a simple vector and returns it as an integer or base-char.

Package

system

Signature

octet-ref vector octet-index => iresult

(setf octet-ref) int vector octet-index => int

Signature

base-char-ref vector octet-index => cresult

(setf base-char-ref) char vector octet-index => char

Arguments

vector

A simple-base-string, a simple-bmp-string or a simple binary vector meaning a vector of element type (unsigned-byte n) or (signed-byte n) for n = 8, 16, 32. In 64-bit LispWorks, n = 64 is also supported.

octet-index

A non-negative integer.

int

An integer.

char

A base-char.

Values

iresult

An integer in the inclusive range [0, 255].

cresult

A base-char.

Description

The functions octet-ref and load an octet (8-bits element) from the simple vector vector at offset octet-index, and return it as an integer or base-char.

vector must be either a string with element type base-char or bmp-char or a binary vector (as defined above). vector cannot be displaced, adjustable or have a fill pointer, and it cannot be a string with element type character.

octet-index must be an integer, which is used as the count of octets (rather than array elements) to compute the actual offsets.

octet-ref, base-char-ref and their setters are intended to allow efficient access to (unsigned-byte 8) vectors and simple-base-string in the same code. For these types of vector they match what aref and (setf aref) do except that they always take and return the same value/result type, while aref and (setf aref) take and return a value of a type which depends on the type of the vector. octet-ref (and base-char-ref) are also more efficient than aref.

octet-ref, base-char-ref and their setters also work on simple binary vectors with element length other than 8 bits, and the results are consistent between themselves. However their results for such vectors do not match aref, because they will load and set either part of an element or multiple elements. Also the results of octet-ref (and base-char-ref) and the result of aref can differ between different platforms due to endianness.

Notes

octet-ref, base-char-ref and their setters cannot be used on a simple-text-string.

See also

Optimized integer arithmetic and integer vector access


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex