Re: ANN: Another binary parser combinator - this time for java's streams

2014-02-04 Thread Stathis Sideris
Thanks, header seems very useful and relevant to what I was doing, but I ended up doing something slightly different because I needed to include the information retrieved using the chunk header codec in the final result (specifically, the type of the chunk). Here is some code:

Re: ANN: Another binary parser combinator - this time for java's streams

2014-02-03 Thread Stathis Sideris
Hello, Is it possible to use 'repeated with a dynamic size if the length-defining prefix does not directly precede the content? For example, see PNG chunks: http://en.wikipedia.org/wiki/Portable_Network_Graphics#.22Chunks.22_within_the_file The codec would be: (def chunk (b/ordered-map

Re: ANN: Another binary parser combinator - this time for java's streams

2014-02-03 Thread Steffen Dienst
I would use header for this: (def chunk (header :int-be #(ordered-map :type (b/repeated :byte :length 4) :data (b/repeated :byte :length %) :crc (b/repeated :byte :length 4)) #(count (:data % The

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-31 Thread Steffen Dienst
Thanks, I fixed the documentation issues. Feel free to share your id3 tags parser, if you like :) You can see that mine is still stuck at the very beginning.. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 01:36 , Steffen steffen.die...@gmail.com wrote: If you would like to use a specific codec other than :byte or :ubyte but also restrict the number of bytes read this would only work if you expected to have some kind of optional padding after your objects, like:

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Steffen Dienst
Am Donnerstag, 30. Januar 2014 14:05:07 UTC+1 schrieb Michael Gardner: On Jan 30, 2014, at 01:36 , Steffen steffen...@gmail.com javascript: wrote: If you would like to use a specific codec other than :byte or :ubyte but also restrict the number of bytes read this would only work if you

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 08:10 , Steffen Dienst steffen.die...@gmail.com wrote: That's exactly what padding is designed to do: Let's say you know there is a run of bytes with a known length (from a header field maybe) and you want to parse an unbounded number of objects within this area. You

ANN: Another binary parser combinator - this time for java's streams

2014-01-29 Thread Steffen
Hello Clojure community, there are already two excellent libraries for reading/writing/manipulating binary data: Zach's Lamina and Clojurewerkz' Buffy for java's ByteBuffers. I would like to offer another library for java's Input/OutputStreams. It is inspired by Lamina but not compatible in

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-29 Thread Michael Gardner
Looks good! A few questions: 1) Is it possible to specify a byte length for a 'repeated codec, rather than a number of objects? 2) Would you consider an enum type, for convenience? Something like: (defn enum [type m] (compile-codec type m (clojure.set/map-invert m))) 3) In the

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-29 Thread Steffen
Please see below. Am Mittwoch, 29. Januar 2014 17:49:56 UTC+1 schrieb Michael Gardner: Looks good! A few questions: Thanks. 1) Is it possible to specify a byte length for a 'repeated codec, rather than a number of objects? If your 'object' is a byte,sure: (repeated :byte :length