top | item 36190816

(no title)

mindv0rtex | 2 years ago

The functionality that I am personally interested in from a binary parsing framework like Kaitai is generating an encoder implementation in addition to a decoder one. In other words, given a description of a binary format, I would like to be able to construct an instance of a class whose memory layout matches the format. For instance, if the format has an int n, then an array `a` of size `n`, and then a double `d`, it would be awesome to be able to construct a corresponding object with fields `n`, `a` and `d` and when I change `n`, then the size of `a` changes accordingly. And then, if I pass a pointer to this object to the decoder, it would be able to parse it correctly, as if the memory representation of the object came from some external buffer.

discuss

order

jchw|2 years ago

Kaitai support for serialization has been a long time issue. It's obviously non-trivial given that it has at least one case that doesn't exist today (instantiating a structure without loading any existing data.)

That said, it does exist in some form.

https://doc.kaitai.io/serialization.html

Restruct supports serialization. I use it all the time to hack on proprietary formats.