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: > > (padding inner-codec 4096). Yes, that's exactly what I need. I didn't try 'padding because the docs seemed to say that it works only when encoding. My only problem is that when decoding, I don't know how many objects to expect before the padding (this is for parsing ID3v2 tags). Ideally I'd like to say something like (padding (repeated frame-codec) byte-count), with the padding taking over once the inner codec fails to parse the next available bytes (but see the next point). > (defn enum [type m] > (compile-codec type m > (clojure.set/map-invert m))) > So m would be a map of for example keywords to a native datatype like int > that would allow you to represent a fixed number of things with distinct > binary representations? Looks good to me. What do you think should be the > behaviour in case of an unspecified value (not in m)? I'd expect an exception to be thrown in case of an unspecified value. But when decoding, it would be nice if the exception were (optionally?) swallowed when occurring inside a 'padding construct, to allow something like the above example. Though I don't know how many other binary formats would require something like that; I imagine most aren't as dumb as ID3v2. > Currently the index in the vector is the index of the bit. Yes, that means > LSB-first. Then the docs seem to be wrong (or at least confusing), since the example code for 'bits says the first item corresponds to the "highest" bit. -- -- 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.