changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/dat/pkg.lisp

changeset 439: ea4f008ad13f
parent: 52608bbc3a7c
child: 8d7aa0af2367
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 12 Jun 2024 17:34:07 -0400
permissions: -rw-r--r--
description: packy work, added json-trailing-whitespace-p variable for json readers
1 ;;; dat/pkg.lisp --- Data
2 
3 ;;; Code:
4 (defpackage :dat/proto
5  (:use :cl :std)
6  (:export :serialize :deserialize
7  :serializer-error :deserializer-error
8  :serde :serde-error :dat-error))
9 
10 (defpackage :dat/sxp
11  (:nicknames :sxp)
12  (:use :cl :sb-mop :std)
13  (:import-from :uiop :read-file-forms :slurp-stream-forms :with-output-file)
14  ;; TODO: hot-patch readtables into sxp classes/parsers
15  (:import-from :std/named-readtables :defreadtable :in-readtable)
16  (:export
17  :sxp-fmt-designator
18  :form :formp :sxp-error :sxp-fmt-error :sxp-syntax-error :reader :writer :fmt
19  :wrap :wrap! :wrap-from-string! :unwrap :unwrap! :unwrap-or
20  :sxpp :build-ast :load-ast :ast
21  :define-macro :define-fmt :read-sxp-file :write-sxp-file
22  :read-sxp-string :write-sxp-string :read-sxp-stream :write-sxp-stream
23  :make-sxp :sxp :formp :form
24  :file-read-forms
25  :wrap-object :unwrap-object))
26 
27 (defpackage :dat/csv
28  (:use :cl :std :dat/proto)
29  (:export
30  :read-csv-file
31  :*csv-separator*
32  #:read-csv-stream
33  :write-csv-file
34  :write-csv-stream
35  :read-csv-file-and-sort
36  :parse-csv-string))
37 
38 (defpackage :dat/toml
39  (:use :cl :std :dat/proto :obj/time)
40  (:export
41  #:parse
42  #:parse-toml-blocks
43  #:toml-collection
44  #:children
45  #:toml-table
46  #:inline-toml-table
47  #:toml-table-array
48  #:toml-redefine-table-error
49  #:toml-redefine-property-error
50  #:toml-modify-inline-table-error
51  #:toml-dotted-key-redefine-table-error
52  #:toml-dotted-key-open-table-array-error))
53 
54 (defpackage :dat/arff
55  (:use :cl :std :dat/proto :dat/csv)
56  (:export
57  :arff :arff-relation :arff-attributes :arff-data :arff-path
58  :parse-arff :parse-arff-string :parse-arff-stream
59  :remove-attribute-by-name))
60 
61 (defpackage :dat/json
62  (:use :cl :std :dat/proto)
63  (:export
64  :*allow-json-trailing-commas*
65  :json-trailing-commas-p
66  #:json-decode
67  #:json-encode
68  #:json-read
69  #:json-enable-reader-macro
70  #:json-object
71  #:json-object-members
72  #:json-getf
73  #:json-setf))
74 
75 (defpackage :dat/base64
76  (:use :cl :std :dat/proto)
77  (:export #:base64-stream-to-integer
78  #:base64-stream-to-string
79  #:base64-stream-to-stream
80  #:base64-stream-to-usb8-array
81  #:base64-string-to-integer
82  #:base64-string-to-string
83  #:base64-string-to-stream
84  #:base64-string-to-usb8-array
85  #:string-to-base64-string
86  #:string-to-base64-stream
87  #:usb8-array-to-base64-string
88  #:usb8-array-to-base64-stream
89  #:stream-to-base64-string
90  #:stream-to-base64-stream
91  #:integer-to-base64-string
92  #:integer-to-base64-stream
93  ;; Conditions.
94  #:base64-error
95  #:bad-base64-character
96  #:incomplete-base64-data
97  ;; For creating custom encode/decode tables.
98  #:make-decode-table
99  #:+decode-table+
100  #:+uri-decode-table+))
101 
102 (defpackage :dat/html
103  (:use :cl :std :dat/proto)
104  (:import-from :sb-ext :defglobal)
105  (:export
106  :parse-html5
107  :parse-html5-fragment
108  :transform-html5-dom
109  :xml-escape-name
110  :xml-unescape-name
111  ;; A simple DOM
112  :make-document
113  :make-fragment
114  :make-doctype
115  :make-comment
116  :make-element
117  :make-text-node
118  :node-type
119  :node-name
120  :node-namespace
121  :node-value
122  :node-public-id
123  :node-system-id
124  :element-attribute
125  :node-append-child
126  :node-insert-before
127  :node-remove-child
128  :node-parent
129  :node-first-child
130  :node-last-child
131  :node-previous-sibling
132  :node-next-sibling
133  :element-map-attributes
134  :element-map-attributes*
135  :element-map-children))
136 
137 (defpackage :dat/xml
138  (:use :cl :std :dat/proto :log)
139  (:shadow :read-char :unread-char)
140  (:export
141  :xml-node-name
142  :xml-node-ns
143  :xml-node-attrs
144  :xml-node-children
145  :make-xml-node
146  :xml-parse
147  :to-xml
148  :write-xml
149  :xml-node-p
150  :xml-node ; needed to support use in typep
151  ;; processing instruction objects
152  :proc-inst-p
153  :proc-inst-target
154  :proc-inst-contents
155  :write-prologue
156  :write-prolog
157  ;; rpg utils
158  :make-xmlrep :xmlrep-add-child!
159  :xmlrep-tag :xmlrep-tagmatch
160  :xmlrep-attribs :xmlrep-children
161  :xmlrep-string-child :xmlrep-integer-child
162  :xmlrep-find-child-tags :xmlrep-find-child-tag
163  :xmlrep-attrib-value :xmlrep-boolean-attrib-value
164  ;; tree searching from Daniel Eliason
165  :extract-path-list
166  :extract-path))
167 
168 (defpackage :dat/mime
169  (:use :cl :std :dat/proto :dat/xml)
170  (:export :*mime-database*
171  :load-mime-info :update-mime-database
172  :mime-magic :mime-magic-offset :mime-magic-type :mime-magic-value
173  :mime-type :mime-type-name :mime-type-superclasses :mime-type-glob
174  :mime-type-glob :mime-type-magic
175  :mime :get-mime :get-mime*))
176 
177 (defpackage :dat/bencode
178  (:use :cl :std :dat/proto :sb-gray)
179  (:export
180  :bencode-encode
181  :bencode-decode
182  :*bencode-binary-key-p*))
183 
184 (defpackage :dat/midi
185  (:nicknames :midi)
186  (:use :cl :std :dat/proto)
187  (:export #:read-midi-file #:write-midi-file
188  #:midifile
189  #:midifile-format #:midifile-tracks #:midifile-division
190  #:message #:note-off-message #:note-on-message #:tempo-message
191  #:program-change-message #:pitch-bend-message
192  #:key-signature-message #:time-signature-message
193  #:smpte-offset-message
194  #:sequence/track-name-message
195  #:message-channel #:message-key #:message-time
196  #:message-velocity #:message-numerator #:message-denominator
197  #:message-sf #:message-mi #:message-tempo #:message-program
198  #:message-value
199  #:header #:header-type
200  #:unknown-event #:status #:data-byte #:dd #:bb #:cc #:nn))
201 
202 (defpackage :dat/qrcode
203  (:nicknames :qrcode)
204  (:use :cl :std :dat/proto)
205  (:export
206  :encode-symbol
207  ;; QR code representation
208  ;; this should be enough to write another backend for QR symbol
209  :qr-symbol
210  :matrix
211  :modules
212  :dark-module-p
213  :read-file-content))
214 
215 (defpackage :dat/gif
216  (:nicknames :gif)
217  (:use :cl :std :dat/proto)
218  (:export))
219 
220 (defpackage :dat/png
221  (:use :cl :std :dat/proto #+png :png)
222  (:export))
223 
224 (defpackage :dat/tar
225  (:use :cl :std :dat/proto)
226  (:export))
227 
228 (pkg:defpkg :dat
229  (:use-reexport :dat/proto :dat/csv :dat/arff
230  :dat/toml :dat/json :dat/sxp :dat/xml
231  :dat/bencode :dat/qrcode))