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 resulting data structure would not contain the field length in this case. Length only gets used to configure the inner codec for the body (the map with :type, :data and :crc). You can read this codec as: "Read a big-endian integer, then use this value to construct a new codec to read the body. When writing, count the :data field, write the length using :type and then write the body". Steffen 2014-02-03 Stathis Sideris <side...@gmail.com>: > 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 > :length :int-be > :type (b/repeated :byte :length 4) > :data (b/repeated :byte :length ???) > :crc (b/repeated :byte :length 4))) > > What do I put in the place of "???" > > Thanks, > > Stathis > > > On Friday, 31 January 2014 08:12:23 UTC, Steffen Dienst wrote: >> >> 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 clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/2c9-oXfKlp0/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.