The qbase64 Reference Manual

This is the qbase64 Reference Manual, version 0.3.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:22:07 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 qbase64

Fast and flexible base64 encoder and decoder

Author

Chaitanya Gupta <>

License

BSD-3-Clause

Version

0.3.0

Dependencies
  • trivial-gray-streams (system).
  • metabang-bind (system).
Source

qbase64.asd.

Child Components

3 Files

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


3.1 Lisp


3.1.1 qbase64/qbase64.asd

Source

qbase64.asd.

Parent Component

qbase64 (system).

ASDF Systems

qbase64.


3.1.2 qbase64/package.lisp

Source

qbase64.asd.

Parent Component

qbase64 (system).

Packages

qbase64.


3.1.3 qbase64/utils.lisp

Dependency

package.lisp (file).

Source

qbase64.asd.

Parent Component

qbase64 (system).

Internals

3.1.4 qbase64/stream-utils.lisp

Dependency

utils.lisp (file).

Source

qbase64.asd.

Parent Component

qbase64 (system).

Public Interface
Internals

3.1.5 qbase64/qbase64.lisp

Dependency

stream-utils.lisp (file).

Source

qbase64.asd.

Parent Component

qbase64 (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 qbase64

Source

package.lisp.

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

5 Definitions

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


5.1 Public Interface


5.1.1 Constants

Constant: +max-bytes-length+

Max length of the byte array that is used as encoding input or decoding output

Package

qbase64.

Source

qbase64.lisp.

Constant: +max-string-length+

Max length of the string that is used as encoding output or decoding input

Package

qbase64.

Source

qbase64.lisp.


5.1.2 Ordinary functions

Function: decode (decoder string bytes &key start1 end1 start2 end2)

Decodes the given STRING and writes the resultant bytes to BYTES.

DECODER: The decoder

STRING: The string to decode.

BYTES: This is where the resultant bytes are written into. Should be a single-dimentional array of (UNSIGNED-BYTE 8) elements.

START1, END1: Bounds for STRING

START2, END2: Bounds for BYTES

Whitespace in string is ignored. It is not necessary that the entire STRING is decoded in one go. For example,

* There may not be enough space left in BYTES,

* or the length of the string (minus whitespace chars) may not be a multiple of 4 (base64 decoding works on groups of four characters at at time).

In these cases, DECODE will decode as much of the string as it can and write the resultant bytes into BYTES. The remaining string is copied to an internal buffer by the decoder and used the next time DECODE is called. Also, the second return value (called PENDINGP, see below) is set to true.

DECODE can be given an empty STRING in which case the buffered string is decoded as much as possible.

Returns POSITION, PENDINGP.

POSITION: First index of BYTES that wasn’t updated

PENDINGP: True if not all of the STRING was decoded

Package

qbase64.

Source

qbase64.lisp.

Function: decode-string (string &key scheme)

Decodes base64 chars in STRING and returns an array of (UNSIGNED-BYTE 8) elements.

STRING: The string to decode.

SCHEME: The base64 encoding scheme to use. Must be :ORIGINAL (default) or :URI.

Package

qbase64.

Source

qbase64.lisp.

Function: encode (encoder bytes string &key start1 end1 start2 end2 finish)

Encodes given BYTES and writes the resultant chars to STRING.

ENCODER: The encoder

BYTES: Should be a single-dimentional array of (UNSIGNED-BYTE 8) elements.

STRING: The encoded characters are written into this string.

START1, END1: Bounds for BYTES

START2, END2: Bounds for STRING

FINISH: Padding characters are output if required, and no new bytes can be accepted until all the pending bytes are written out.

It is not necessary that all of BYTES are encoded in one go. For example,

* There may not be enough space left in STRING

* FINISH is not true and the cumulative length of all the bytes given till now is not a multiple of 3 (base64 encoding works on groups of three bytes).

In these cases, as much as possible BYTES are encoded and the resultant chars written into STRING, the remaining bytes are copied to an internal buffer by the encoder and used the next time ENCODE is called. Also, the second value returned (called PENDINGP, see below) is set to true.

If FINISH is true but cumulative length of all the BYTES is not a multiple of 3, padding characters are written into STRING.

ENCODE can be given an empty BYTES array in which case the internal buffer is encoded as much as possible.

Returns POSITION, PENDINGP.

POSITION: First index of STRING that wasn’t updated

PENDINGP: True if not all BYTES were encoded

Package

qbase64.

Source

qbase64.lisp.

Function: encode-bytes (bytes &key scheme linebreak)

Encode BYTES to base64 and return the string.

BYTES: Should be a single-dimentional array of (UNSIGNED-BYTE 8) elements.

SCHEME: The base64 encoding scheme to use. Must
be :ORIGINAL (default) or :URI.

LINEBREAK: If 0 (the default), no linebreaks are written. Otherwise its value must be the max number of characters per line.

Package

qbase64.

Source

qbase64.lisp.

Function: make-decoder (&key scheme)

Creates a DECODER.

SCHEME: The base64 encoding scheme to use. Can be :ORIGINAL or :URI

Package

qbase64.

Source

qbase64.lisp.

Function: make-encoder (&key scheme)

Creates an ENCODER.

SCHEME: The base64 encoding scheme to use. Can be :ORIGINAL or :URI

Package

qbase64.

Source

qbase64.lisp.


5.1.3 Standalone methods

Method: close :before ((stream encode-stream) &key abort)
Source

qbase64.lisp.

Method: close ((stream stream-mixin) &key abort)
Source

stream-utils.lisp.

Method: initialize-instance :after ((stream decode-stream) &key scheme)
Source

qbase64.lisp.

Method: initialize-instance :after ((stream encode-stream) &key scheme)
Source

qbase64.lisp.

Method: input-stream-p ((stream decode-stream))
Source

qbase64.lisp.

Method: input-stream-p ((stream stream-mixin))
Source

stream-utils.lisp.

Method: open-stream-p ((stream stream-mixin))
Source

stream-utils.lisp.

Method: output-stream-p ((stream encode-stream))
Source

qbase64.lisp.

Method: output-stream-p ((stream stream-mixin))
Source

stream-utils.lisp.

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

qbase64.lisp.

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

qbase64.lisp.

Method: stream-finish-output ((stream encode-stream))
Package

sb-gray.

Source

qbase64.lisp.

Method: stream-force-output ((stream encode-stream))
Package

sb-gray.

Source

qbase64.lisp.

Method: stream-read-byte ((stream decode-stream))
Package

sb-gray.

Source

qbase64.lisp.

Method: stream-read-sequence ((stream decode-stream) sequence start end &key)
Package

trivial-gray-streams.

Source

qbase64.lisp.

Method: stream-write-byte ((stream encode-stream) integer)
Package

sb-gray.

Source

qbase64.lisp.

Method: stream-write-sequence ((stream encode-stream) sequence start end &key)
Package

trivial-gray-streams.

Source

qbase64.lisp.


5.1.4 Structures

Structure: decoder

Use a DECODER to decode base64 characters to bytes. Use MAKE-DECODER to create a decoder, then decode base64 chars using DECODE.

Package

qbase64.

Source

qbase64.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: scheme
Readers

decoder-scheme.

Writers

(setf decoder-scheme).

Slot: pchars
Type

simple-base-string

Initform

(make-string 0 :element-type (quote base-char))

Readers

decoder-pchars.

Writers

(setf decoder-pchars).

Slot: pchars-end
Initform

0

Readers

decoder-pchars-end.

Writers

(setf decoder-pchars-end).

Structure: encoder

Use an ENCODER to encode bytes to string. Create an encoder using MAKE-ENCODER, then start encoding bytes using ENCODE.

Package

qbase64.

Source

qbase64.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: scheme
Type

qbase64::scheme

Initform

:original

Readers

encoder-scheme.

Writers

(setf encoder-scheme).

Slot: pbytes
Type

(simple-array (unsigned-byte 8))

Initform

qbase64::+empty-bytes+

Readers

encoder-pbytes.

Writers

(setf encoder-pbytes).

Slot: pbytes-end
Type

qbase64::positive-fixnum

Initform

0

Readers

encoder-pbytes-end.

Writers

(setf encoder-pbytes-end).

Slot: finish-p
Readers

encoder-finish-p.

Writers

(setf encoder-finish-p).


5.1.5 Classes

Class: decode-stream

A binary input stream that converts base64 chars from an underlying stream to bytes.

Create a DECODE-STREAM using MAKE-INSTANCE. The following initialization keywords are provided:

UNDERLYING-STREAM: The underlying character input stream from which base64 chars are read. Must be given.

SCHEME: The base64 encoding scheme to use. Must
be :ORIGINAL (default) or :URI.

Note that DECODE-STREAM does not close the underlying stream when CLOSE is invoked.

Package

qbase64.

Source

qbase64.lisp.

Direct superclasses
  • fundamental-binary-input-stream.
  • stream-mixin.
  • trivial-gray-stream-mixin.
Direct methods
Direct slots
Slot: underlying-stream
Initargs

:underlying-stream

Slot: decoder
Slot: string
Package

common-lisp.

Initform

qbase64::+empty-string+

Slot: buffer
Initform

(qbase64::make-byte-vector 3)

Slot: buffer-end
Initform

0

Slot: single-byte-vector
Initform

(qbase64::make-byte-vector 1)

Class: encode-stream

A binary output stream that converts bytes to base64 characters and writes them to an underlyihng character output stream.

Create an ENCODE-STREAM using MAKE-INSTANCE. The following initialization keywords are provided:

UNDERLYING-STREAM: The underlying character output stream to which base64 characters are written. Must be given.

SCHEME: The base64 encoding scheme to use. Must
be :ORIGINAL (default) or :URI.

LINEBREAK: If 0 (the default), no linebreaks are written. Otherwise its value must be the max number of characters per line.

Note that ENCODE-STREAM does not close the underlying stream when CLOSE is invoked.

Package

qbase64.

Source

qbase64.lisp.

Direct superclasses
  • fundamental-binary-output-stream.
  • stream-mixin.
  • trivial-gray-stream-mixin.
Direct methods
Direct slots
Slot: underlying-stream
Initargs

:underlying-stream

Slot: encoder
Slot: string
Package

common-lisp.

Initform

qbase64::+empty-string+

Slot: single-byte-vector
Initform

(qbase64::make-byte-vector 1)

Slot: linebreak
Initform

0

Initargs

:linebreak

Slot: column
Initform

0


5.2 Internals


5.2.1 Constants

Constant: +empty-bytes+
Package

qbase64.

Source

qbase64.lisp.

Constant: +empty-string+
Package

qbase64.

Source

qbase64.lisp.

Constant: +original-reverse-set+
Package

qbase64.

Source

qbase64.lisp.

Constant: +original-set+
Package

qbase64.

Source

qbase64.lisp.

Constant: +pad-char+
Package

qbase64.

Source

qbase64.lisp.

Constant: +uri-reverse-set+
Package

qbase64.

Source

qbase64.lisp.

Constant: +uri-set+
Package

qbase64.

Source

qbase64.lisp.


5.2.2 Macros

Macro: define-constant (name value &optional doc)
Package

qbase64.

Source

utils.lisp.

Macro: defun/td (name lambda-list type-decls-list &body body)
Package

qbase64.

Source

utils.lisp.


5.2.3 Ordinary functions

Function: %decode (string bytes &key scheme start1 end1 start2 end2)
Package

qbase64.

Source

qbase64.lisp.

Function: %encode (bytes string &key scheme encode-trailing-bytes start1 end1 start2 end2)
Package

qbase64.

Source

qbase64.lisp.

Function: %make-decoder (&key scheme pchars pchars-end)
Package

qbase64.

Source

qbase64.lisp.

Function: %make-encoder (&key scheme pbytes pbytes-end finish-p)
Package

qbase64.

Source

qbase64.lisp.

Function: %stream-write-sequence (stream sequence start end finish)
Package

qbase64.

Source

qbase64.lisp.

Function: bytes (&rest contents)
Package

qbase64.

Source

utils.lisp.

Function: copy-decoder (instance)
Package

qbase64.

Source

qbase64.lisp.

Function: copy-encoder (instance)
Package

qbase64.

Source

qbase64.lisp.

Function: decode-length (length)
Package

qbase64.

Source

qbase64.lisp.

Function: decoder-p (object)
Package

qbase64.

Source

qbase64.lisp.

Reader: decoder-pchars (instance)
Writer: (setf decoder-pchars) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

pchars.

Reader: decoder-pchars-end (instance)
Writer: (setf decoder-pchars-end) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

pchars-end.

Reader: decoder-scheme (instance)
Writer: (setf decoder-scheme) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

scheme.

Function: encode-length (length encode-trailing-bytes)
Package

qbase64.

Source

qbase64.lisp.

Reader: encoder-finish-p (instance)
Writer: (setf encoder-finish-p) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

finish-p.

Function: encoder-p (object)
Package

qbase64.

Source

qbase64.lisp.

Reader: encoder-pbytes (instance)
Writer: (setf encoder-pbytes) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

pbytes.

Reader: encoder-pbytes-end (instance)
Writer: (setf encoder-pbytes-end) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

pbytes-end.

Reader: encoder-scheme (instance)
Writer: (setf encoder-scheme) (instance)
Package

qbase64.

Source

qbase64.lisp.

Target Slot

scheme.

Function: fill-pchars (decoder string &key start end)
Package

qbase64.

Source

qbase64.lisp.

Function: flush-pending-bytes (stream)
Package

qbase64.

Source

qbase64.lisp.

Function: least-multiple-upfrom (multiple-of upfrom)
Package

qbase64.

Source

utils.lisp.

Function: make-byte-vector (size)
Package

qbase64.

Source

utils.lisp.

Function: parse-body (body &key documentation whole)

Parses BODY into (values remaining-forms declarations doc-string). Documentation strings are recognized only if DOCUMENTATION is true. Syntax errors in body are signalled and WHOLE is used in the signal arguments when given.

Package

qbase64.

Source

utils.lisp.

Function: resize-pchars (pchars pchars-end new-length)
Package

qbase64.

Source

qbase64.lisp.

Function: reverse-set (set)
Package

qbase64.

Source

qbase64.lisp.

Function: whitespace-p (c)

Returns T for a whitespace character.

Package

qbase64.

Source

qbase64.lisp.

Function: write-buffer-to-sequence (stream sequence start end)
Package

qbase64.

Source

qbase64.lisp.


5.2.4 Generic functions

Generic Reader: stream-open-p (object)
Package

qbase64.

Methods
Reader Method: stream-open-p ((stream-mixin stream-mixin))

automatically generated reader method

Source

stream-utils.lisp.

Target Slot

openp.

Generic Writer: (setf stream-open-p) (object)
Package

qbase64.

Methods
Writer Method: (setf stream-open-p) ((stream-mixin stream-mixin))

automatically generated writer method

Source

stream-utils.lisp.

Target Slot

openp.


5.2.5 Classes

Class: stream-mixin
Package

qbase64.

Source

stream-utils.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: openp
Initform

t

Readers

stream-open-p.

Writers

(setf stream-open-p).


5.2.6 Types

Type: positive-fixnum ()
Package

qbase64.

Source

utils.lisp.

Type: scheme ()
Package

qbase64.

Source

qbase64.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
B   C   D   E   F   G   I   L   M   O   P   R   S   W  
Index Entry  Section

%
%decode: Private ordinary functions
%encode: Private ordinary functions
%make-decoder: Private ordinary functions
%make-encoder: Private ordinary functions
%stream-write-sequence: Private ordinary functions

(
(setf decoder-pchars): Private ordinary functions
(setf decoder-pchars-end): Private ordinary functions
(setf decoder-scheme): Private ordinary functions
(setf encoder-finish-p): Private ordinary functions
(setf encoder-pbytes): Private ordinary functions
(setf encoder-pbytes-end): Private ordinary functions
(setf encoder-scheme): Private ordinary functions
(setf stream-open-p): Private generic functions
(setf stream-open-p): Private generic functions

B
bytes: Private ordinary functions

C
close: Public standalone methods
close: Public standalone methods
copy-decoder: Private ordinary functions
copy-encoder: Private ordinary functions

D
decode: Public ordinary functions
decode-length: Private ordinary functions
decode-string: Public ordinary functions
decoder-p: Private ordinary functions
decoder-pchars: Private ordinary functions
decoder-pchars-end: Private ordinary functions
decoder-scheme: Private ordinary functions
define-constant: Private macros
defun/td: Private macros

E
encode: Public ordinary functions
encode-bytes: Public ordinary functions
encode-length: Private ordinary functions
encoder-finish-p: Private ordinary functions
encoder-p: Private ordinary functions
encoder-pbytes: Private ordinary functions
encoder-pbytes-end: Private ordinary functions
encoder-scheme: Private ordinary functions

F
fill-pchars: Private ordinary functions
flush-pending-bytes: Private ordinary functions
Function, %decode: Private ordinary functions
Function, %encode: Private ordinary functions
Function, %make-decoder: Private ordinary functions
Function, %make-encoder: Private ordinary functions
Function, %stream-write-sequence: Private ordinary functions
Function, (setf decoder-pchars): Private ordinary functions
Function, (setf decoder-pchars-end): Private ordinary functions
Function, (setf decoder-scheme): Private ordinary functions
Function, (setf encoder-finish-p): Private ordinary functions
Function, (setf encoder-pbytes): Private ordinary functions
Function, (setf encoder-pbytes-end): Private ordinary functions
Function, (setf encoder-scheme): Private ordinary functions
Function, bytes: Private ordinary functions
Function, copy-decoder: Private ordinary functions
Function, copy-encoder: Private ordinary functions
Function, decode: Public ordinary functions
Function, decode-length: Private ordinary functions
Function, decode-string: Public ordinary functions
Function, decoder-p: Private ordinary functions
Function, decoder-pchars: Private ordinary functions
Function, decoder-pchars-end: Private ordinary functions
Function, decoder-scheme: Private ordinary functions
Function, encode: Public ordinary functions
Function, encode-bytes: Public ordinary functions
Function, encode-length: Private ordinary functions
Function, encoder-finish-p: Private ordinary functions
Function, encoder-p: Private ordinary functions
Function, encoder-pbytes: Private ordinary functions
Function, encoder-pbytes-end: Private ordinary functions
Function, encoder-scheme: Private ordinary functions
Function, fill-pchars: Private ordinary functions
Function, flush-pending-bytes: Private ordinary functions
Function, least-multiple-upfrom: Private ordinary functions
Function, make-byte-vector: Private ordinary functions
Function, make-decoder: Public ordinary functions
Function, make-encoder: Public ordinary functions
Function, parse-body: Private ordinary functions
Function, resize-pchars: Private ordinary functions
Function, reverse-set: Private ordinary functions
Function, whitespace-p: Private ordinary functions
Function, write-buffer-to-sequence: Private ordinary functions

G
Generic Function, (setf stream-open-p): Private generic functions
Generic Function, stream-open-p: Private generic functions

I
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
input-stream-p: Public standalone methods
input-stream-p: Public standalone methods

L
least-multiple-upfrom: Private ordinary functions

M
Macro, define-constant: Private macros
Macro, defun/td: Private macros
make-byte-vector: Private ordinary functions
make-decoder: Public ordinary functions
make-encoder: Public ordinary functions
Method, (setf stream-open-p): Private generic functions
Method, close: Public standalone methods
Method, close: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, input-stream-p: Public standalone methods
Method, input-stream-p: Public standalone methods
Method, open-stream-p: Public standalone methods
Method, output-stream-p: Public standalone methods
Method, output-stream-p: Public standalone methods
Method, stream-element-type: Public standalone methods
Method, stream-element-type: Public standalone methods
Method, stream-finish-output: Public standalone methods
Method, stream-force-output: Public standalone methods
Method, stream-open-p: Private generic functions
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
open-stream-p: Public standalone methods
output-stream-p: Public standalone methods
output-stream-p: Public standalone methods

P
parse-body: Private ordinary functions

R
resize-pchars: Private ordinary functions
reverse-set: Private ordinary functions

S
stream-element-type: Public standalone methods
stream-element-type: Public standalone methods
stream-finish-output: Public standalone methods
stream-force-output: Public standalone methods
stream-open-p: Private generic functions
stream-open-p: Private generic functions
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
whitespace-p: Private ordinary functions
write-buffer-to-sequence: Private ordinary functions


A.3 Variables

Jump to:   +  
B   C   D   E   F   L   O   P   S   U  
Index Entry  Section

+
+empty-bytes+: Private constants
+empty-string+: Private constants
+max-bytes-length+: Public constants
+max-string-length+: Public constants
+original-reverse-set+: Private constants
+original-set+: Private constants
+pad-char+: Private constants
+uri-reverse-set+: Private constants
+uri-set+: Private constants

B
buffer: Public classes
buffer-end: Public classes

C
column: Public classes
Constant, +empty-bytes+: Private constants
Constant, +empty-string+: Private constants
Constant, +max-bytes-length+: Public constants
Constant, +max-string-length+: Public constants
Constant, +original-reverse-set+: Private constants
Constant, +original-set+: Private constants
Constant, +pad-char+: Private constants
Constant, +uri-reverse-set+: Private constants
Constant, +uri-set+: Private constants

D
decoder: Public classes

E
encoder: Public classes

F
finish-p: Public structures

L
linebreak: Public classes

O
openp: Private classes

P
pbytes: Public structures
pbytes-end: Public structures
pchars: Public structures
pchars-end: Public structures

S
scheme: Public structures
scheme: Public structures
single-byte-vector: Public classes
single-byte-vector: Public classes
Slot, buffer: Public classes
Slot, buffer-end: Public classes
Slot, column: Public classes
Slot, decoder: Public classes
Slot, encoder: Public classes
Slot, finish-p: Public structures
Slot, linebreak: Public classes
Slot, openp: Private classes
Slot, pbytes: Public structures
Slot, pbytes-end: Public structures
Slot, pchars: Public structures
Slot, pchars-end: Public structures
Slot, scheme: Public structures
Slot, scheme: Public structures
Slot, single-byte-vector: Public classes
Slot, single-byte-vector: Public classes
Slot, string: Public classes
Slot, string: Public classes
Slot, underlying-stream: Public classes
Slot, underlying-stream: Public classes
string: Public classes
string: Public classes

U
underlying-stream: Public classes
underlying-stream: Public classes