The pack Reference Manual

Table of Contents

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

The pack Reference Manual

This is the pack Reference Manual, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:21:50 2018 GMT+0.


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

1 Introduction

Python struct hack in Common Lisp written by Death (see https://gist.github.com/266945)

Modified to use ieee-floats instead of sb-kernel to increase compatibility.
Tested on SBCL linux, windows and CLISP windows.


pack spec &rest args => array

Packs arguments according to spec as an octet buffer (simple array
with 8-bit unsigned bytes).

The spec string should be formatted as given in
http://docs.python.org/library/struct.html#byte-order-size-and-alignment


pack-into spec stream &rest args => stream

Packs arguments according to spec into stream, which should obey the
stream struct protocol, i.e. a specialized method
struct-stream-protocol should exist for the stream. See below.


unpack spec stream => list

Unpacks bytes from stream according to spec and returns them in a list.


calc-size spec => size

Calculates and returns the size (in octets) that the spec specifies.


struct-stream-protocol stream => reader writer

A method for the stream object returning reader and writer
functions. For an arbitrary object, these should be closures over that
object. The reader function should return the current octet in the
object and increment its position by one. It takes no arguments. The
writer function should write the given octet to the object and
increment its position by one.

See this example from the pack.lisp source, which ensures vectors can
be used as streams for the pack-into and unpack functions:

(defmethod struct-stream-protocol ((vector vector))
  (values
   (let ((i 0))
     (lambda ()
       (prog1 (aref vector i)
         (incf i))))
   (let ((i 0))
     (lambda (octet)
       (setf (aref vector i) octet)
       (incf i)))))


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

2 Systems

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


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

2.1 pack

Author

Death

License

Public Domain

Description

Pack and unpack binary data via Python-like struct strings.

Dependencies
Source

pack.asd (file)

Components

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

3 Files

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


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

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 pack.asd

Location

pack.asd

Systems

pack (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 pack/package.lisp

Parent

pack (system)

Location

package.lisp

Packages

pack


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 pack/pack.lisp

Dependency

package.lisp (file)

Parent

pack (system)

Location

pack.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 pack

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Compiler macros

Compiler Macro: calc-size STRING
Package

pack

Source

pack.lisp (file)

Compiler Macro: pack STRING &rest ARGS
Package

pack

Source

pack.lisp (file)

Compiler Macro: pack-into STRING STREAM &rest ARGS
Package

pack

Source

pack.lisp (file)

Compiler Macro: unpack STRING STREAM
Package

pack

Source

pack.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: calc-size STRING
Package

pack

Source

pack.lisp (file)

Function: compile-struct-string STRING
Package

pack

Source

pack.lisp (file)

Function: pack STRING &rest ARGS
Package

pack

Source

pack.lisp (file)

Function: pack* COMPILED STREAM &rest ARGS
Package

pack

Source

pack.lisp (file)

Function: pack-into STRING STREAM &rest ARGS
Package

pack

Source

pack.lisp (file)

Function: unpack STRING STREAM
Package

pack

Source

pack.lisp (file)

Function: unpack* COMPILED STREAM
Package

pack

Source

pack.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: struct-stream-protocol STREAM
Package

pack

Source

pack.lisp (file)

Methods
Method: struct-stream-protocol (VECTOR vector)
Method: struct-stream-protocol (STREAM stream)

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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *offset*
Package

pack

Source

pack.lisp (file)

Special Variable: *pack-args*
Package

pack

Source

pack.lisp (file)

Special Variable: *reader*
Package

pack

Source

pack.lisp (file)

Special Variable: *writer*
Package

pack

Source

pack.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: read-signed-be SIZE
Package

pack

Source

pack.lisp (file)

Macro: read-signed-le SIZE
Package

pack

Source

pack.lisp (file)

Macro: read-unsigned-be SIZE
Package

pack

Source

pack.lisp (file)

Macro: read-unsigned-le SIZE
Package

pack

Source

pack.lisp (file)

Macro: write-signed-be VALUE SIZE
Package

pack

Source

pack.lisp (file)

Macro: write-signed-le VALUE SIZE
Package

pack

Source

pack.lisp (file)

Macro: write-unsigned-be VALUE SIZE
Package

pack

Source

pack.lisp (file)

Macro: write-unsigned-le VALUE SIZE
Package

pack

Source

pack.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: bool-to-byte BOOL
Package

pack

Source

pack.lisp (file)

Function: byte-to-bool BYTE
Package

pack

Source

pack.lisp (file)

Function: byte-to-char CHAR-OR-BYTE
Package

pack

Source

pack.lisp (file)

Function: char-to-byte CHAR-OR-BYTE
Package

pack

Source

pack.lisp (file)

Function: divisible-by-p N D
Package

pack

Source

pack.lisp (file)

Function: offset ()
Function: (setf offset) NEW-VALUE
Package

pack

Source

pack.lisp (file)

Function: pack-arg ()
Package

pack

Source

pack.lisp (file)

Function: read-double-be ()
Package

pack

Source

pack.lisp (file)

Function: read-double-le ()
Package

pack

Source

pack.lisp (file)

Function: read-fixlen-string SIZE
Package

pack

Source

pack.lisp (file)

Function: read-float-be ()
Package

pack

Source

pack.lisp (file)

Function: read-float-le ()
Package

pack

Source

pack.lisp (file)

Function: read-octet ()
Package

pack

Source

pack.lisp (file)

Function: read-pad SIZE
Package

pack

Source

pack.lisp (file)

Function: read-pascal-string SIZE
Package

pack

Source

pack.lisp (file)

Function: signed-to-unsigned VALUE SIZE
Package

pack

Source

pack.lisp (file)

Function: unsigned-to-signed VALUE SIZE
Package

pack

Source

pack.lisp (file)

Function: write-double-be VALUE
Package

pack

Source

pack.lisp (file)

Function: write-double-le VALUE
Package

pack

Source

pack.lisp (file)

Function: write-fixlen-string VALUE SIZE
Package

pack

Source

pack.lisp (file)

Function: write-float-be VALUE
Package

pack

Source

pack.lisp (file)

Function: write-float-le VALUE
Package

pack

Source

pack.lisp (file)

Function: write-octet OCTET
Package

pack

Source

pack.lisp (file)

Function: write-pad SIZE
Package

pack

Source

pack.lisp (file)

Function: write-pascal-string VALUE SIZE
Package

pack

Source

pack.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   P  
Index Entry  Section

F
File, Lisp, pack.asd: The pack<dot>asd file
File, Lisp, pack/pack.lisp: The pack/pack<dot>lisp file
File, Lisp, pack/package.lisp: The pack/package<dot>lisp file

L
Lisp File, pack.asd: The pack<dot>asd file
Lisp File, pack/pack.lisp: The pack/pack<dot>lisp file
Lisp File, pack/package.lisp: The pack/package<dot>lisp file

P
pack.asd: The pack<dot>asd file
pack/pack.lisp: The pack/pack<dot>lisp file
pack/package.lisp: The pack/package<dot>lisp file

Jump to:   F   L   P  

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

A.2 Functions

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

(
(setf offset): Internal functions

B
bool-to-byte: Internal functions
byte-to-bool: Internal functions
byte-to-char: Internal functions

C
calc-size: Exported compiler macros
calc-size: Exported functions
char-to-byte: Internal functions
compile-struct-string: Exported functions
Compiler Macro, calc-size: Exported compiler macros
Compiler Macro, pack: Exported compiler macros
Compiler Macro, pack-into: Exported compiler macros
Compiler Macro, unpack: Exported compiler macros

D
divisible-by-p: Internal functions

F
Function, (setf offset): Internal functions
Function, bool-to-byte: Internal functions
Function, byte-to-bool: Internal functions
Function, byte-to-char: Internal functions
Function, calc-size: Exported functions
Function, char-to-byte: Internal functions
Function, compile-struct-string: Exported functions
Function, divisible-by-p: Internal functions
Function, offset: Internal functions
Function, pack: Exported functions
Function, pack*: Exported functions
Function, pack-arg: Internal functions
Function, pack-into: Exported functions
Function, read-double-be: Internal functions
Function, read-double-le: Internal functions
Function, read-fixlen-string: Internal functions
Function, read-float-be: Internal functions
Function, read-float-le: Internal functions
Function, read-octet: Internal functions
Function, read-pad: Internal functions
Function, read-pascal-string: Internal functions
Function, signed-to-unsigned: Internal functions
Function, unpack: Exported functions
Function, unpack*: Exported functions
Function, unsigned-to-signed: Internal functions
Function, write-double-be: Internal functions
Function, write-double-le: Internal functions
Function, write-fixlen-string: Internal functions
Function, write-float-be: Internal functions
Function, write-float-le: Internal functions
Function, write-octet: Internal functions
Function, write-pad: Internal functions
Function, write-pascal-string: Internal functions

G
Generic Function, struct-stream-protocol: Exported generic functions

M
Macro, read-signed-be: Internal macros
Macro, read-signed-le: Internal macros
Macro, read-unsigned-be: Internal macros
Macro, read-unsigned-le: Internal macros
Macro, write-signed-be: Internal macros
Macro, write-signed-le: Internal macros
Macro, write-unsigned-be: Internal macros
Macro, write-unsigned-le: Internal macros
Method, struct-stream-protocol: Exported generic functions
Method, struct-stream-protocol: Exported generic functions

O
offset: Internal functions

P
pack: Exported compiler macros
pack: Exported functions
pack*: Exported functions
pack-arg: Internal functions
pack-into: Exported compiler macros
pack-into: Exported functions

R
read-double-be: Internal functions
read-double-le: Internal functions
read-fixlen-string: Internal functions
read-float-be: Internal functions
read-float-le: Internal functions
read-octet: Internal functions
read-pad: Internal functions
read-pascal-string: Internal functions
read-signed-be: Internal macros
read-signed-le: Internal macros
read-unsigned-be: Internal macros
read-unsigned-le: Internal macros

S
signed-to-unsigned: Internal functions
struct-stream-protocol: Exported generic functions
struct-stream-protocol: Exported generic functions
struct-stream-protocol: Exported generic functions

U
unpack: Exported compiler macros
unpack: Exported functions
unpack*: Exported functions
unsigned-to-signed: Internal functions

W
write-double-be: Internal functions
write-double-le: Internal functions
write-fixlen-string: Internal functions
write-float-be: Internal functions
write-float-le: Internal functions
write-octet: Internal functions
write-pad: Internal functions
write-pascal-string: Internal functions
write-signed-be: Internal macros
write-signed-le: Internal macros
write-unsigned-be: Internal macros
write-unsigned-le: Internal macros

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

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

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*offset*: Internal special variables
*pack-args*: Internal special variables
*reader*: Internal special variables
*writer*: Internal special variables

S
Special Variable, *offset*: Internal special variables
Special Variable, *pack-args*: Internal special variables
Special Variable, *reader*: Internal special variables
Special Variable, *writer*: Internal special variables

Jump to:   *  
S  

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

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
pack: The pack system
pack: The pack package
Package, pack: The pack package

S
System, pack: The pack system

Jump to:   P   S