The trivial-hashtable-serialize Reference Manual

Table of Contents

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

The trivial-hashtable-serialize Reference Manual

This is the trivial-hashtable-serialize Reference Manual, version 0.1.3, generated automatically by Declt version 2.4 patchlevel 1 "Will Decker" on Mon Jul 29 16:50:42 2019 GMT+0.


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

1 Introduction

Trivial Hash-Table Serialization Manual

[in package TRIVIAL-HASHTABLE-SERIALIZE]

pipeline status Quicklisp

Description

This simple library allows for simple serialization and deserialization of hash-tables.

Installing trivial-hashtable-serialize

This project is available in the latest QuickLisp distribution, so installing it is reduced to calling:

(ql:quickload :trivial-hashtable-serialize)

Working Example

The code block below shows how to export/import a simple hashtable using the default serialization methods. Keep in mind, that this default does simply (format) the key and value. This makes serialization of keywords and strings erroneous. To overcome this limitation, use a more elaborate (de)serialization function, as described further below.

(let ((table (make-hash-table)))
  (setf (gethash 'a table) 9)
  (setf (gethash 'b table) 8)
  (setf (gethash 'c table) 7)
  (save-hashtable table "~/hashtable-export.txt"))

(let ((imported (load-hashtable "~/hashtable-export.txt")))
  (format t "Value of 'a is: ~a~%" (gethash 'a imported))
  (format t "Value of 'b is: ~a~%" (gethash 'b imported))
  (format t "Value of 'c is: ~a~%" (gethash 'c imported)))

As mentioned before, here a better implementation of the serialize function using trivial-json-codec.

(defun json-serialize-fn (stream key value)
  (declare (type stream stream))
  (format stream "~a~%" (trivial-json-codec:serialize-json (list key value))))

(defun json-deserialize-fn (line)
  (let ((r (trivial-json-codec:deserialize-json line)))
    (values (car r) (cadr r))))

(let ((table (make-hash-table)))
  (setf (gethash "a" table) '(1 2 3))
  (setf (gethash "b" table) '(4 5 (7 8)))
  (setf (gethash "c" table) (make-array 4 :initial-contents '(7 6 5 4)))
  (save-hashtable table "~/hashtable-export-json.txt" :serialize-fn #'json-serialize-fn))

(let ((imported (load-hashtable "~/hashtable-export-json.txt" :deserialize-fn #'json-deserialize-fn)))
  (format t "Value of 'a' is: ~a~%" (gethash "a" imported))
  (format t "Value of 'b' is: ~a~%" (gethash "b" imported))
  (format t "Value of 'c' is: ~a~%" (gethash "c" imported)))

Exported Symbols

License Information

This library is released under the MIT License. Please refer to the LICENSE to get the full licensing text.

Contributing to this project

Please refer to the CONTRIBUTING document for more information.


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 trivial-hashtable-serialize

Author

Eric Diethelm <ediethelm@yahoo.com>

License

MIT

Description

A simple method to serialize and deserialize hash-tables.

Version

0.1.3

Dependencies
Source

trivial-hashtable-serialize.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 trivial-hashtable-serialize.asd

Location

trivial-hashtable-serialize.asd

Systems

trivial-hashtable-serialize (system)


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

3.1.2 trivial-hashtable-serialize/package.lisp

Parent

trivial-hashtable-serialize (system)

Location

package.lisp

Packages

trivial-hashtable-serialize


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

3.1.3 trivial-hashtable-serialize/trivial-hashtable-serialize.lisp

Parent

trivial-hashtable-serialize (system)

Location

trivial-hashtable-serialize.lisp

Exported Definitions
Internal Definitions

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

3.1.4 trivial-hashtable-serialize/documentation.lisp

Parent

trivial-hashtable-serialize (system)

Location

documentation.lisp

Exported Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 trivial-hashtable-serialize

trivial-hashtable-serialize provides a simple and probably naïve way to serialize hash-tables.

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 Special variables

Special Variable: @trivial-hashtable-serialize-contributing
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-description
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-example
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-exported
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-installing
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-license
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)

Special Variable: @trivial-hashtable-serialize-manual
Package

trivial-hashtable-serialize

Source

documentation.lisp (file)


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

5.1.2 Functions

Function: load-hashtable FILE-NAME &key IF-DOES-NOT-EXIST DESERIALIZE-FN

Read the contents of *FILE-NAME* and deserialize it into a new hash-table. *IF-DOES-NOT-EXIST* accepts the same values as the equaly named key in *WITH-OPEN-FILE*. *DESERIALIZE-FN* can be defined to use a non-default serialization function.

The signature of *DESERIALIZE-FN* is (function (line) (values key value)).

Package

trivial-hashtable-serialize

Source

trivial-hashtable-serialize.lisp (file)

Function: save-hashtable TABLE FILE-NAME &key SERIALIZE-FN

Serializes the hash-table *TABLE* into the file identified by *FILE-NAME*. A non-default serialization function can be given through *SERIALIZE-FN*.
The signature of *SERIALIZE-FN* is (function (stream key value) null).

Package

trivial-hashtable-serialize

Source

trivial-hashtable-serialize.lisp (file)


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

5.2 Internal definitions


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

5.2.1 Functions

Function: default-deserialize-fn LINE

This function deserializes key/value pairs serialized by *DEFAULT-SERIALIZE-FN*.

Package

trivial-hashtable-serialize

Source

trivial-hashtable-serialize.lisp (file)

Function: default-serialize-fn STREAM KEY VALUE

This is the default serialization function. It uses #$ to separate key and values.

See also *DEFAULT-DESERIALIZE-FN*.

Package

trivial-hashtable-serialize

Source

trivial-hashtable-serialize.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   T  
Index Entry  Section

F
File, Lisp, trivial-hashtable-serialize.asd: The trivial-hashtable-serialize<dot>asd file
File, Lisp, trivial-hashtable-serialize/documentation.lisp: The trivial-hashtable-serialize/documentation<dot>lisp file
File, Lisp, trivial-hashtable-serialize/package.lisp: The trivial-hashtable-serialize/package<dot>lisp file
File, Lisp, trivial-hashtable-serialize/trivial-hashtable-serialize.lisp: The trivial-hashtable-serialize/trivial-hashtable-serialize<dot>lisp file

L
Lisp File, trivial-hashtable-serialize.asd: The trivial-hashtable-serialize<dot>asd file
Lisp File, trivial-hashtable-serialize/documentation.lisp: The trivial-hashtable-serialize/documentation<dot>lisp file
Lisp File, trivial-hashtable-serialize/package.lisp: The trivial-hashtable-serialize/package<dot>lisp file
Lisp File, trivial-hashtable-serialize/trivial-hashtable-serialize.lisp: The trivial-hashtable-serialize/trivial-hashtable-serialize<dot>lisp file

T
trivial-hashtable-serialize.asd: The trivial-hashtable-serialize<dot>asd file
trivial-hashtable-serialize/documentation.lisp: The trivial-hashtable-serialize/documentation<dot>lisp file
trivial-hashtable-serialize/package.lisp: The trivial-hashtable-serialize/package<dot>lisp file
trivial-hashtable-serialize/trivial-hashtable-serialize.lisp: The trivial-hashtable-serialize/trivial-hashtable-serialize<dot>lisp file

Jump to:   F   L   T  

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

A.2 Functions

Jump to:   D   F   L   S  
Index Entry  Section

D
default-deserialize-fn: Internal functions
default-serialize-fn: Internal functions

F
Function, default-deserialize-fn: Internal functions
Function, default-serialize-fn: Internal functions
Function, load-hashtable: Exported functions
Function, save-hashtable: Exported functions

L
load-hashtable: Exported functions

S
save-hashtable: Exported functions

Jump to:   D   F   L   S  

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

A.3 Variables

Jump to:   @  
S  
Index Entry  Section

@
@trivial-hashtable-serialize-contributing: Exported special variables
@trivial-hashtable-serialize-description: Exported special variables
@trivial-hashtable-serialize-example: Exported special variables
@trivial-hashtable-serialize-exported: Exported special variables
@trivial-hashtable-serialize-installing: Exported special variables
@trivial-hashtable-serialize-license: Exported special variables
@trivial-hashtable-serialize-manual: Exported special variables

S
Special Variable, @trivial-hashtable-serialize-contributing: Exported special variables
Special Variable, @trivial-hashtable-serialize-description: Exported special variables
Special Variable, @trivial-hashtable-serialize-example: Exported special variables
Special Variable, @trivial-hashtable-serialize-exported: Exported special variables
Special Variable, @trivial-hashtable-serialize-installing: Exported special variables
Special Variable, @trivial-hashtable-serialize-license: Exported special variables
Special Variable, @trivial-hashtable-serialize-manual: Exported special variables

Jump to:   @  
S  

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

A.4 Data types

Jump to:   P   S   T  
Index Entry  Section

P
Package, trivial-hashtable-serialize: The trivial-hashtable-serialize package

S
System, trivial-hashtable-serialize: The trivial-hashtable-serialize system

T
trivial-hashtable-serialize: The trivial-hashtable-serialize system
trivial-hashtable-serialize: The trivial-hashtable-serialize package

Jump to:   P   S   T