smee / binary

Clojure API for binary format I/O using java's stream apis
74 stars 10 forks source link

Update README.md #21

Closed PaulSchulz closed 3 years ago

PaulSchulz commented 3 years ago

Minor typo

smee commented 3 years ago

Thanks!

PaulSchulz commented 3 years ago

Quick question..

How do parse/input a list of ints (:uint-le) where the first contains the number of ints to read?

Do I need to read the first (:size) and then parse the rest with 'repeat' with parameter (as code) or is there a way to set this in the data specification?

Cheers, Paul

On Fri, 4 Jun 2021, 00:47 Steffen Dienst, @.***> wrote:

Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smee/binary/pull/21#issuecomment-853948511, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVLAPQVDRT3IMZRTT5Y33TQ6MC5ANCNFSM46AH5HHQ .

smee commented 3 years ago

You could either use (repeated :uint-le :prefix :uint-le) for repeated elements with a length prefix, or the more generalized (header :uint-le (fn [len] (repeated :uint-le :length len)) count) which can be used for any kind of header/body encoding. For examples please refer to the tests, for example at https://github.com/smee/binary/blob/master/test/org/clojars/smee/binary/codectests.clj#L125 or https://github.com/smee/binary/blob/master/test/org/clojars/smee/binary/codectests.clj#L204

PaulSchulz commented 3 years ago

Awesome. Thats exactly what I needed.

On Fri, 4 Jun 2021, 16:58 Steffen Dienst, @.***> wrote:

You could either use (repeated :uint-le :prefix :uint-le) for repeated elements with a length prefix, or the more generalized (header :uint-le (fn [len] (repeated :uint-le :length len)) count) which can be used for any kind of header/body encoding. For examples please refer to the tests, for example at https://github.com/smee/binary/blob/master/test/org/clojars/smee/binary/codectests.clj#L92 or https://github.com/smee/binary/blob/master/test/org/clojars/smee/binary/codectests.clj#L204

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smee/binary/pull/21#issuecomment-854438022, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVLAP2JRFRFD6DDKREW23TRB57JANCNFSM46AH5HHQ .