Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STREAM

This package exports utility functions about streams. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

BARE-STREAM (STREAM &KEY (DIRECTION OUTPUT))

RETURN: A stream or a list of streams that are not compound streams (and therefore usable by #+clisp SOCKET:SOCKET-STATUS).

CONTENTS-FROM-STREAM (STREAM &KEY LENGTH (MIN-SIZE 256) MAX-EXTEND)

STREAM: May be a binary or character, file or non-file stream. LENGTH: NIL, or the number of stream elements to read. MIN-SIZE: Minimum pre-allocated buffer size. If LENGTH is given, or STREAM has a FILE-LENGTH, then the MIN-SIZE is ignored. MAX-EXTEND: NIL ==> double the buffer size, or double the buffer size until it's greater than MAX-EXTEND, and then increment by MAX-EXTEND. RETURN: A vector containing the elements read from the STREAM.

COPY-OVER (STREAM FROM-POS TO-POS &KEY (ELEMENT-TYPE 'CHARACTER))

DO: Copies elements from the FROM-POS to the end of the STREAM to the TO-POS. POST: (file-position stream) == (+ to-pos (- eof-pos from-ops)) NOTE: The file is not truncated.

COPY-STREAM (FROM TO)

Copy into TO from FROM until end of the input file. Do not translate or otherwise maul anything. AUTHORS: Daniel Barlow, Xarch

STREAM-TO-STRING-LIST (STREAM)

RETURN: the list of lines collected from stream.

Private

SPLIT-STRING (STRING &OPTIONAL (SEPARATORS ) (REMOVE-EMPTY NIL))

STRING: A sequence. SEPARATOR: A sequence. RETURN: A list of subsequence of STRING, split upon any element of SEPARATORS. Separators are compared to elements of the STRING with EQL. NOTE: It's actually a simple split-sequence now. EXAMPLES: (split-string '(1 2 0 3 4 5 0 6 7 8 0 9) '(0)) --> ((1 2) (3 4 5) (6 7 8) (9)) (split-string #(1 2 0 3 4 5 0 6 7 8 0 9) #(0)) --> (#(1 2) #(3 4 5) #(6 7 8) #(9)) (split-string "1 2 0 3 4 5 0 6 7 8" '(#space #0)) --> ("1" "2" "" "" "3" "4" "5" "" "" "6" "7" "8")

MACRO

Public

WITH-INPUT-FROM-BYTE-VECTOR ((VAR BYTE-VECTOR &KEY INDEX START END) &BODY BODY)

DO: Execute the BODY with VAR bound to an input byte vector stream reading bytes from the BYTE-VECTOR, from START to END. If INDEX is given it should be a place into which the last position is stored. RETURN: The last position.

WITH-OUTPUT-TO-BYTE-VECTOR ((VAR &OPTIONAL BYTE-VECTOR-FORM &KEY ELEMENT-TYPE) &BODY BODY)

DO: Execute the BODY with VAR bound to an output byte vector stream. If BYTE-VECTOR-FORM is given it should produce a byte vector with a fill-pointer where the bytes written to the bvstream are stored. ELEMENT-TYPE: The type of bytes. If BYTE-VECTOR-FORM is nil, one can choose a different element-type for the byte vector. RETURN: The byte vector written.

GENERIC-FUNCTION

Public

BVSTREAM-POSITION (BVSTREAM POSITION)

Set the position of the BVSTREAM.

BVSTREAM-READ-BYTE (BVSTREAM)

Read a byte from the BVSTREAM.

BVSTREAM-WRITE-BYTE (BVSTREAM BYTE)

Write a byte to the BVSTREAM.

STREAM-INPUT-STREAM (STREAM)

RETURN: A simple INPUT-STREAM.

STREAM-OUTPUT-STREAM (STREAM)

RETURN: A simple OUTPUT-STREAM.

SLOT-ACCESSOR

Private

Undocumented

BIS-POSITION (OBJECT)

SETFBIS-POSITION (NEW-VALUE OBJECT)

BYTE-VECTOR (OBJECT)

SETFBYTE-VECTOR (NEW-VALUE OBJECT)

GET-BYTES (OBJECT)

GET-POSITION (OBJECT)

SET-BYTES (NEW-VALUE OBJECT)

CLASS

Private

BVSTREAM-IN

An input byte vector stream.

BVSTREAM-OUT

An output byte vector stream.