The cl-octet-streams Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-octet-streams Reference Manual

This is the cl-octet-streams Reference Manual, version 1.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 03:52:13 2022 GMT+0.

Table of Contents


1 Introduction

#+TITLE: cl-octet-streams

*cl-octet-streams* is a library implementing in-memory octet streams for Common Lisp.
It was inspired by the [[https://github.com/sharplispers/trivial-octet-streams][trivial-octet-streams]] and [[https://github.com/smithzvk/cl-plumbing][cl-plumbing]] libraries.

* Installation

The only dependency is the [[https://common-lisp.net/project/trivial-gray-streams][trivial-gray-streams]] library.

* API
** Input stream

#+BEGIN_SRC lisp
(make-octet-input-stream seq &optional (start 0) end) => stream
#+END_SRC

Return an input stream which will supply the bytes of /seq/ between /start/ and
/end/ in order.

#+BEGIN_SRC lisp
(with-octet-input-stream (var seq &optional (start 0) end) &body body)
#+END_SRC

Within /body/, /var/ is bound to an octet input stream defined by /seq/, /start/
and /end/. The result of the last form of /body/ is returned.

** Output stream

#+BEGIN_SRC lisp
(make-octet-output-stream) => stream
#+END_SRC

Return an output stream which will accumulate all the bytes written to it for
the benefit of the function /get-output-stream-octets/.

#+BEGIN_SRC lisp
(get-output-stream-octets stream) => bytes
#+END_SRC

Return the bytes that were written to an octet output /stream/.

#+BEGIN_SRC lisp
(with-octet-output-stream (var) &body body) => bytes
#+END_SRC

Within /body/, /var/ is bound to an octet output stream. After all the forms in
/body/ have been executed, the bytes that have been written to /var/ (and that
haven't been consumed by a call to /get-output-stream-octets/ within /body/) are
returned.

** Pipe

#+BEGIN_SRC lisp
(make-octet-pipe) => stream
#+END_SRC

Return a stream which will supply the bytes that have been written to it in
order.

#+BEGIN_SRC lisp
(with-octet-pipe (var) &body body)
#+END_SRC

Within /body/, /var/ is bound to an octet pipe. The result of the last form of
/body/ is returned.

** Connected streams

#+BEGIN_SRC lisp
(make-connected-octet-streams) => stream1, stream2
#+END_SRC

Return two streams connected to each other. The bytes written to the first
stream can be read from the second, and the bytes written to the second stream
can be read from the first.

#+BEGIN_SRC lisp
(with-connected-octet-streams (var1 var2) &body body)
#+END_SRC

Within /body/, /var1/ and /var2/ are bound to octet streams connected to each
other. The result of the last form of /body/ is returned.

** Extra functions

The following functions can be used on input streams, output streams and pipes.

#+BEGIN_SRC lisp
(octet-stream-length stream) => integer
#+END_SRC

Return the number of bytes available in /stream/.

#+BEGIN_SRC lisp
(octet-stream-ref stream index) => byte
#+END_SRC

Return the byte at /index/ in /stream/.

#+BEGIN_SRC lisp
(octet-stream-search stream pattern jump-table) => index or nil
#+END_SRC

Search /pattern/ in the bytes of /stream/ using the Boyer-Moore algorithm. The
/jump-table/ must be 256 bytes long. If there is a match, return the index of
the beginning of the /pattern/ in the /stream/, otherwise return ~nil~.

#+BEGIN_SRC lisp
(make-jump-table pattern) => array
#+END_SRC

Return a jump table for /pattern/ that can be used with /octet-stream-search/.

* Tests

The tests require the [[https://common-lisp.net/project/fiveam][fiveam]] library.

#+BEGIN_SRC lisp
(asdf:test-system "cl-octet-streams")
#+END_SRC


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-octet-streams

In-memory octet streams

Author

Guillaume LE VAILLANT

License

GPL-3

Version

1.2

Dependency

trivial-gray-streams (system).

Source

cl-octet-streams.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 cl-octet-streams/src

Source

cl-octet-streams.asd.

Parent Component

cl-octet-streams (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


4.1.1 cl-octet-streams/cl-octet-streams.asd

Source

cl-octet-streams.asd.

Parent Component

cl-octet-streams (system).

ASDF Systems

cl-octet-streams.


4.1.2 cl-octet-streams/src/package.lisp

Source

cl-octet-streams.asd.

Parent Component

src (module).

Packages

octet-streams.


4.1.3 cl-octet-streams/src/ring-buffers.lisp

Dependency

package.lisp (file).

Source

cl-octet-streams.asd.

Parent Component

src (module).

Internals

4.1.4 cl-octet-streams/src/octet-streams.lisp

Dependency

ring-buffers.lisp (file).

Source

cl-octet-streams.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.5 cl-octet-streams/src/octet-pipes.lisp

Dependency

octet-streams.lisp (file).

Source

cl-octet-streams.asd.

Parent Component

src (module).

Public Interface
Internals

octet-pipe (class).


4.1.6 cl-octet-streams/src/connected-octet-streams.lisp

Dependency

octet-pipes.lisp (file).

Source

cl-octet-streams.asd.

Parent Component

src (module).

Public Interface

5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 octet-streams

Source

package.lisp.

Nickname

cl-octet-streams

Use List
  • common-lisp.
  • trivial-gray-streams.
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


6.1.1 Macros

Macro: with-connected-octet-streams ((var1 var2) &body body)

Within BODY, VAR1 and VAR2 are bound to octet streams connected to each other. The result of the last form of BODY is returned.

Package

octet-streams.

Source

connected-octet-streams.lisp.

Macro: with-octet-input-stream ((var seq &optional start end) &body body)

Within BODY, VAR is bound to an octet input stream defined by SEQ, START and END. The result of the last form of BODY is returned.

Package

octet-streams.

Source

octet-streams.lisp.

Macro: with-octet-output-stream ((var) &body body)

Within BODY, VAR is bound to an octet output stream. After all the forms in BODY have been executed, the bytes that have been written to VAR (and that haven’t been consumed by a call to GET-OUTPUT-STREAM-OCTETS within BODY) are returned.

Package

octet-streams.

Source

octet-streams.lisp.

Macro: with-octet-pipe ((var) &body body)

Within BODY, VAR is bound to an octet pipe. The result of the last form of BODY is returned.

Package

octet-streams.

Source

octet-pipes.lisp.


6.1.2 Ordinary functions

Function: get-output-stream-octets (stream)

Return the bytes that were written to an octet output STREAM.

Package

octet-streams.

Source

octet-streams.lisp.

Function: make-connected-octet-streams ()

Return two streams connected to each other. The bytes written to the first stream can be read from the second, and the bytes written to the second stream can be read from the first.

Package

octet-streams.

Source

connected-octet-streams.lisp.

Function: make-jump-table (pattern)

Return a jump table for PATTERN that can be used with OCTET-STREAM-SEARCH.

Package

octet-streams.

Source

octet-streams.lisp.

Function: make-octet-input-stream (seq &optional start end)

Return an input stream which will supply the bytes of SEQ between START and END in order.

Package

octet-streams.

Source

octet-streams.lisp.

Function: make-octet-output-stream ()

Return an output stream which will accumulate all the bytes written to it for the benefit of the function GET-OUTPUT-STREAM-OCTETS.

Package

octet-streams.

Source

octet-streams.lisp.

Function: make-octet-pipe ()

Return a stream which will supply the bytes that have been written to it in order.

Package

octet-streams.

Source

octet-pipes.lisp.

Function: octet-stream-length (stream)

Return the number of bytes available in STREAM.

Package

octet-streams.

Source

octet-streams.lisp.

Function: octet-stream-ref (stream index)

Return the byte at INDEX in STREAM.

Package

octet-streams.

Source

octet-streams.lisp.

Function: octet-stream-search (stream pattern jump-table)

Search PATTERN in the bytes of STREAM using the Boyer-Moore algorithm. The JUMP-TABLE must be 256 bytes long. If there is a match, return the index of the beginning of the PATTERN in the STREAM, otherwise return NIL.

Package

octet-streams.

Source

octet-streams.lisp.


6.1.3 Standalone methods

Method: stream-clear-input ((stream octet-input-stream))
Package

sb-gray.

Source

octet-streams.lisp.

Method: stream-clear-output ((stream octet-output-stream))
Package

sb-gray.

Source

octet-streams.lisp.

Method: stream-element-type ((stream octet-stream))
Source

octet-streams.lisp.

Method: stream-listen ((stream octet-input-stream))
Package

sb-gray.

Source

octet-streams.lisp.

Method: stream-read-byte ((stream octet-input-stream))
Package

sb-gray.

Source

octet-streams.lisp.

Method: stream-read-sequence ((stream octet-input-stream) seq start end &key &allow-other-keys)
Package

trivial-gray-streams.

Source

octet-streams.lisp.

Method: stream-write-byte ((stream octet-output-stream) byte)
Package

sb-gray.

Source

octet-streams.lisp.

Method: stream-write-sequence ((stream octet-output-stream) seq start end &key &allow-other-keys)
Package

trivial-gray-streams.

Source

octet-streams.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Macros

Macro: replace* (seq1 seq2 &key start1 end1 start2 end2)
Package

octet-streams.

Source

ring-buffers.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.2 Ordinary functions

Function: replace-fast (buffer1 buffer2 start1 end1 start2 end2)
Package

octet-streams.

Source

ring-buffers.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.3 Generic functions

Generic Reader: buffer (object)
Package

octet-streams.

Methods
Reader Method: buffer ((octet-stream octet-stream))

automatically generated reader method

Source

octet-streams.lisp.

Target Slot

buffer.

Reader Method: buffer ((ring-buffer ring-buffer))

automatically generated reader method

Source

ring-buffers.lisp.

Target Slot

buffer.

Generic Writer: (setf buffer) (object)
Package

octet-streams.

Methods
Writer Method: (setf buffer) ((octet-stream octet-stream))

automatically generated writer method

Source

octet-streams.lisp.

Target Slot

buffer.

Writer Method: (setf buffer) ((ring-buffer ring-buffer))

automatically generated writer method

Source

ring-buffers.lisp.

Target Slot

buffer.

Generic Reader: buffer-count (object)
Package

octet-streams.

Methods
Reader Method: buffer-count ((ring-buffer ring-buffer))

automatically generated reader method

Source

ring-buffers.lisp.

Target Slot

count.

Generic Writer: (setf buffer-count) (object)
Package

octet-streams.

Methods
Writer Method: (setf buffer-count) ((ring-buffer ring-buffer))

automatically generated writer method

Source

ring-buffers.lisp.

Target Slot

count.

Generic Reader: buffer-end (object)
Package

octet-streams.

Methods
Reader Method: buffer-end ((ring-buffer ring-buffer))

automatically generated reader method

Source

ring-buffers.lisp.

Target Slot

end.

Generic Writer: (setf buffer-end) (object)
Package

octet-streams.

Methods
Writer Method: (setf buffer-end) ((ring-buffer ring-buffer))

automatically generated writer method

Source

ring-buffers.lisp.

Target Slot

end.

Generic Function: buffer-ref (ring-buffer index)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: buffer-ref ((ring-buffer ring-buffer) index)
Generic Reader: buffer-size (object)
Package

octet-streams.

Methods
Reader Method: buffer-size ((ring-buffer ring-buffer))

automatically generated reader method

Source

ring-buffers.lisp.

Target Slot

size.

Generic Writer: (setf buffer-size) (object)
Package

octet-streams.

Methods
Writer Method: (setf buffer-size) ((ring-buffer ring-buffer))

automatically generated writer method

Source

ring-buffers.lisp.

Target Slot

size.

Generic Reader: buffer-start (object)
Package

octet-streams.

Methods
Reader Method: buffer-start ((ring-buffer ring-buffer))

automatically generated reader method

Source

ring-buffers.lisp.

Target Slot

start.

Generic Writer: (setf buffer-start) (object)
Package

octet-streams.

Methods
Writer Method: (setf buffer-start) ((ring-buffer ring-buffer))

automatically generated writer method

Source

ring-buffers.lisp.

Target Slot

start.

Generic Function: clear (ring-buffer)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: clear ((ring-buffer ring-buffer))
Generic Function: pop-data (ring-buffer length &optional seq start)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: pop-data ((ring-buffer ring-buffer) length &optional seq start)
Generic Function: push-data (ring-buffer seq &optional start end)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: push-data ((ring-buffer ring-buffer) seq &optional start end)
Generic Function: resize (ring-buffer new-size)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: resize ((ring-buffer ring-buffer) new-size)
Generic Function: search-data (ring-buffer pattern jump-table)
Package

octet-streams.

Source

ring-buffers.lisp.

Methods
Method: search-data ((ring-buffer ring-buffer) pattern jump-table)

Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Classes

Class: octet-input-stream
Package

octet-streams.

Source

octet-streams.lisp.

Direct superclasses
Direct subclasses

octet-pipe.

Direct methods
Class: octet-output-stream
Package

octet-streams.

Source

octet-streams.lisp.

Direct superclasses
Direct subclasses

octet-pipe.

Direct methods
Class: octet-pipe
Package

octet-streams.

Source

octet-pipes.lisp.

Direct superclasses
Class: octet-stream
Package

octet-streams.

Source

octet-streams.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: buffer
Type

octet-streams::ring-buffer

Initargs

:buffer

Readers

buffer.

Writers

(setf buffer).

Class: ring-buffer
Package

octet-streams.

Source

ring-buffers.lisp.

Direct methods
Direct slots
Slot: buffer
Type

octet-streams::simple-octet-vector

Initargs

:buffer

Readers

buffer.

Writers

(setf buffer).

Slot: size
Type

octet-streams::index

Initargs

:size

Readers

buffer-size.

Writers

(setf buffer-size).

Slot: start
Type

octet-streams::index

Initargs

:start

Readers

buffer-start.

Writers

(setf buffer-start).

Slot: end
Type

octet-streams::index

Initargs

:end

Readers

buffer-end.

Writers

(setf buffer-end).

Slot: count
Package

common-lisp.

Type

octet-streams::index

Initargs

:count

Readers

buffer-count.

Writers

(setf buffer-count).


Previous: , Up: Internals   [Contents][Index]

6.2.5 Types

Type: index ()
Package

octet-streams.

Source

ring-buffers.lisp.

Type: simple-octet-vector ()
Package

octet-streams.

Source

ring-buffers.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
B   C   F   G   M   O   P   R   S   W  
Index Entry  Section

(
(setf buffer): Private generic functions
(setf buffer): Private generic functions
(setf buffer): Private generic functions
(setf buffer-count): Private generic functions
(setf buffer-count): Private generic functions
(setf buffer-end): Private generic functions
(setf buffer-end): Private generic functions
(setf buffer-size): Private generic functions
(setf buffer-size): Private generic functions
(setf buffer-start): Private generic functions
(setf buffer-start): Private generic functions

B
buffer: Private generic functions
buffer: Private generic functions
buffer: Private generic functions
buffer-count: Private generic functions
buffer-count: Private generic functions
buffer-end: Private generic functions
buffer-end: Private generic functions
buffer-ref: Private generic functions
buffer-ref: Private generic functions
buffer-size: Private generic functions
buffer-size: Private generic functions
buffer-start: Private generic functions
buffer-start: Private generic functions

C
clear: Private generic functions
clear: Private generic functions

F
Function, get-output-stream-octets: Public ordinary functions
Function, make-connected-octet-streams: Public ordinary functions
Function, make-jump-table: Public ordinary functions
Function, make-octet-input-stream: Public ordinary functions
Function, make-octet-output-stream: Public ordinary functions
Function, make-octet-pipe: Public ordinary functions
Function, octet-stream-length: Public ordinary functions
Function, octet-stream-ref: Public ordinary functions
Function, octet-stream-search: Public ordinary functions
Function, replace-fast: Private ordinary functions

G
Generic Function, (setf buffer): Private generic functions
Generic Function, (setf buffer-count): Private generic functions
Generic Function, (setf buffer-end): Private generic functions
Generic Function, (setf buffer-size): Private generic functions
Generic Function, (setf buffer-start): Private generic functions
Generic Function, buffer: Private generic functions
Generic Function, buffer-count: Private generic functions
Generic Function, buffer-end: Private generic functions
Generic Function, buffer-ref: Private generic functions
Generic Function, buffer-size: Private generic functions
Generic Function, buffer-start: Private generic functions
Generic Function, clear: Private generic functions
Generic Function, pop-data: Private generic functions
Generic Function, push-data: Private generic functions
Generic Function, resize: Private generic functions
Generic Function, search-data: Private generic functions
get-output-stream-octets: Public ordinary functions

M
Macro, replace*: Private macros
Macro, with-connected-octet-streams: Public macros
Macro, with-octet-input-stream: Public macros
Macro, with-octet-output-stream: Public macros
Macro, with-octet-pipe: Public macros
make-connected-octet-streams: Public ordinary functions
make-jump-table: Public ordinary functions
make-octet-input-stream: Public ordinary functions
make-octet-output-stream: Public ordinary functions
make-octet-pipe: Public ordinary functions
Method, (setf buffer): Private generic functions
Method, (setf buffer): Private generic functions
Method, (setf buffer-count): Private generic functions
Method, (setf buffer-end): Private generic functions
Method, (setf buffer-size): Private generic functions
Method, (setf buffer-start): Private generic functions
Method, buffer: Private generic functions
Method, buffer: Private generic functions
Method, buffer-count: Private generic functions
Method, buffer-end: Private generic functions
Method, buffer-ref: Private generic functions
Method, buffer-size: Private generic functions
Method, buffer-start: Private generic functions
Method, clear: Private generic functions
Method, pop-data: Private generic functions
Method, push-data: Private generic functions
Method, resize: Private generic functions
Method, search-data: Private generic functions
Method, stream-clear-input: Public standalone methods
Method, stream-clear-output: Public standalone methods
Method, stream-element-type: Public standalone methods
Method, stream-listen: Public standalone methods
Method, stream-read-byte: Public standalone methods
Method, stream-read-sequence: Public standalone methods
Method, stream-write-byte: Public standalone methods
Method, stream-write-sequence: Public standalone methods

O
octet-stream-length: Public ordinary functions
octet-stream-ref: Public ordinary functions
octet-stream-search: Public ordinary functions

P
pop-data: Private generic functions
pop-data: Private generic functions
push-data: Private generic functions
push-data: Private generic functions

R
replace*: Private macros
replace-fast: Private ordinary functions
resize: Private generic functions
resize: Private generic functions

S
search-data: Private generic functions
search-data: Private generic functions
stream-clear-input: Public standalone methods
stream-clear-output: Public standalone methods
stream-element-type: Public standalone methods
stream-listen: Public standalone methods
stream-read-byte: Public standalone methods
stream-read-sequence: Public standalone methods
stream-write-byte: Public standalone methods
stream-write-sequence: Public standalone methods

W
with-connected-octet-streams: Public macros
with-octet-input-stream: Public macros
with-octet-output-stream: Public macros
with-octet-pipe: Public macros

Jump to:   (  
B   C   F   G   M   O   P   R   S   W  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   F   I   M   O   P   R   S   T  
Index Entry  Section

C
cl-octet-streams: The cl-octet-streams system
cl-octet-streams.asd: The cl-octet-streams/cl-octet-streams․asd file
Class, octet-input-stream: Private classes
Class, octet-output-stream: Private classes
Class, octet-pipe: Private classes
Class, octet-stream: Private classes
Class, ring-buffer: Private classes
connected-octet-streams.lisp: The cl-octet-streams/src/connected-octet-streams․lisp file

F
File, cl-octet-streams.asd: The cl-octet-streams/cl-octet-streams․asd file
File, connected-octet-streams.lisp: The cl-octet-streams/src/connected-octet-streams․lisp file
File, octet-pipes.lisp: The cl-octet-streams/src/octet-pipes․lisp file
File, octet-streams.lisp: The cl-octet-streams/src/octet-streams․lisp file
File, package.lisp: The cl-octet-streams/src/package․lisp file
File, ring-buffers.lisp: The cl-octet-streams/src/ring-buffers․lisp file

I
index: Private types

M
Module, src: The cl-octet-streams/src module

O
octet-input-stream: Private classes
octet-output-stream: Private classes
octet-pipe: Private classes
octet-pipes.lisp: The cl-octet-streams/src/octet-pipes․lisp file
octet-stream: Private classes
octet-streams: The octet-streams package
octet-streams.lisp: The cl-octet-streams/src/octet-streams․lisp file

P
Package, octet-streams: The octet-streams package
package.lisp: The cl-octet-streams/src/package․lisp file

R
ring-buffer: Private classes
ring-buffers.lisp: The cl-octet-streams/src/ring-buffers․lisp file

S
simple-octet-vector: Private types
src: The cl-octet-streams/src module
System, cl-octet-streams: The cl-octet-streams system

T
Type, index: Private types
Type, simple-octet-vector: Private types

Jump to:   C   F   I   M   O   P   R   S   T