[cl-store-devel] Combining ASCII data with Binary cl-store objects?

Theam Yong Chew senatorzergling at gmail.com
Fri Aug 20 04:30:03 UTC 2010


On 8/20/10, Gary Zu <clstoreuser at gmail.com> wrote:
> Dear All,
>
> I have been using cl-store for saving and restoring my objects on Lispworks
> 1.6.0.01. It has been working great.
>
> Currently I am trying to accomplish a weird goal: the first line of my saved
> file must be ALL human readable strings (supposed to be ASCII with a newline
> delimiter "\n") to end. Then the rest of the file can be the whole
> serialized cl-store binary data. What could be the easiest way to accomplish
> this using/customizing existing cl-store's APIs? (now I am thinking of *ix
> IO redirect utilities to break files, and sort of things, which is kind of
> clumsy)

Would this help?

CL-USER> (flexi-streams:with-output-to-sequence (s)
           (format (flexi-streams:make-flexi-stream s :external-format :utf-8)
                   "First line of file~%")
           (cl-store:store (list "a" 3 '(a b (c . d) e)) s))
#(70 105 114 115 116 32 108 105 110 101 32 111 102 32 102 105 108 101 13 10 67
  76 45 83 11 24 0 1 3 35 1 1 97 24 0 1 3 11 24 0 1 4 10 35 1 1 65 35 1 16 67
  79 77 77 79 78 45 76 73 83 80 45 85 83 69 82 10 35 1 1 66 1 1 6 11 24 0 1 1
  10 35 1 1 67 1 1 6 10 35 1 1 68 1 1 6 10 35 1 1 69 1 1 6 10 35 1 3 78 73 76
  35 1 11 67 79 77 77 79 78 45 76 73 83 80 1 1 20)
CL-USER> (flexi-streams:with-input-from-sequence (s *)
           (list (read-line (flexi-streams:make-flexi-stream s
:external-format :utf-8))
                 (cl-store:restore s)))
("First line of file" ("a" 3 (A B (C . D) E)))

You don't have to use flexi-streams of course. Any way to translate your string
to a sequence of octets would do.

>
> Thanks so much for your attention and any help/suggestions are greatly
> appreciated!
>
> a cl-store user
>




More information about the cl-store-devel mailing list