I have different binary file formats that I need to dump into some kind of text format, edit, and then recompile (possibly into a slightly different version of the binary format). Of course, I could write a bunch of utility code in C / C ++ to do this, and maybe use a library for the text part of things (XML or JSON or something else), but this is a task template that continues to arise in my work, and it seems to me that probably there should already be some kind of general-purpose tool for this kind of work.
Obviously, there must be some way of describing binary file formats — a scheme or some such — that would support all the obvious data types (strings, ints of various sizes, bools, etc., a float would be nice too), and things like reference fields, length fields, indentation / alignment, etc., handle all the typical things that you find in the data file. It would also be useful to have Endianness support, since the binary file may have a different consistency than the platform on which we work.
I would be very surprised if something like this no longer exists, but so far I have not been lucky with Google (how do you describe such a utility or library succinctly?). The closest to what I have ever seen is the Apple compiler / decompiler utilities that were used during the "classic" Mac OS. They used C type syntax, with resource template definitions in header files to describe the formats of various binary resources, and you could compile / decompile between this C source syntax and binary resources.
source
share