1. byte-blob-stream
    1. Description
    2. Library Procedures
      1. Predicates
      2. Constructors
      3. Accessors
      4. Transformers
      5. Subsequences
      6. Fold
      7. Find
      8. Files
    3. Version History
    4. License

byte-blob-stream

Description

byte-blob-stream is a library of routines for manipulating byte blobs contained in SRFI-41 streams.

Library Procedures

Predicates

[procedure] (byte-blob-stream? X) => BOOL

Returns #t if the given object is a stream that is either empty or its first element is a byte blob, #f otherwise.

[procedure] (byte-blob-stream-empty? STREAM) => BOOL

Returns #t if the given stream is empty, #f otherwise.

Constructors

[procedure] (byte-blob-stream-empty) => STREAM

Returns an empty stream.

[procedure] (byte-blob-stream-cons BYTE-BLOB STREAM) => STREAM

Prepends the given byte blob to the given stream and returns the resulting stream.

Accessors

[procedure] (byte-blob-stream-length STREAM) => INTEGER

Returns the number of elements contained in all byte blobs in the given stream.

[procedure] (byte-blob-stream-car STREAM) => X

Returns the first element of the first byte blob contained in the given stream. The stream argument must be non-empty, or an exception will be thrown.

[procedure] (byte-blob-stream-cdr STREAM) => STREAM

Returns a stream that contains the elements after the first element of the given byte blob. The argument stream must be non-empty, or an exception will be thrown.

[procedure] (byte-blob-stream-ref STREAM I) => BYTE

Returns the i-th element of the given stream of byte blobs.

Transformers

[procedure] (byte-blob-stream-append STREAM STREAM) => STREAM

Appends two streams of byte blobs together.

[procedure] (byte-blob-stream-reverse STREAM) => STREAM

Returns a stream that contains the elements of the given stream of byte blobs in reverse order.

[procedure] (byte-blob-stream-intersperse STREAM BYTE) => STREAM

Returns a stream of byte blobs with the given byte placed between the elements of the each byte blob from the input stream, and between byte blobs.

[procedure] (byte-blob-stream-map F STREAM) => STREAM

Returns a stream of byte blobs obtained by applying F to each element of the byte blobs in the input stream.

[procedure] (byte-blob-stream->list STREAM) => LIST

Returns a list containing the elements of the byte blobs contained in the input stream. If procedure F is provided as a second argument, it is applied to every element of the returned list.

[procedure] (list->byte-blob-stream LIST) => STREAM

Returns a stream of a single byte blob containing the elements of the given list.

Subsequences

[procedure] (byte-blob-stream-take STREAM N) => STREAM

Returns the prefix of the given stream of byte blobs of length N.

[procedure] (byte-blob-stream-drop STREAM N) => STREAM

Returns the suffix of the given stream of byte blobs after the first N elements.

[procedure] (byte-blob-stream-span STREAM START END) => STREAM

Returns the subsequence of the given stream of byte blobs from position START to position END.

Fold

[procedure] (byte-blob-stream-fold-left F INIT STREAM) => VALUE
[procedure] (byte-blob-stream-fold-right F INIT STREAM) => VALUE

Given a procedure of two arguments, a starting value, and a stream of byte blobs, reduces the stream using the supplied procedure, from left to right, or right to left, respectively.

Find

[procedure] (byte-blob-stream-find NEEDLE HAYSTACK) => LIST

Finds all non-overlapping instances of the byte blob NEEDLE in the stream of byte blobs HAYSTACK. The first element of the returned list is the prefix of HAYSTACK prior to any matches of NEEDLE. The second is a list of lists.

The first element of each pair in the list is a span from the beginning of a match to the beginning of the next match, while the second is a span from the beginning of the match to the end of the input.

Files

[procedure] (file->byte-blob-stream FILENAME [BLOCKSIZE] ) => STREAM

Reads a file into a byte-blob stream.

Version History

License

Based on ideas from the Haskell bytestring library.

The code for byte-blob-stream-find is based on code from the Haskell Text library by Tom Harper and Bryan O'Sullivan.

 Copyright 2009-2011 Ivan Raikov and the Okinawa Institute of Science and Technology.
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser 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
 General Public License for more details.
 A full copy of the GPL license can be found at
 <http://www.gnu.org/licenses/>.