Parsing binary data #191
-
I need to parse a binary chunk of data (mp4 atom) which has optional elements. Specifically, the size part is defined is
I am not seeing how this can be done without implementing custom scan method. However if we were dealing with strings, this would seem to be relatively straightforward. Unfortunately there is a dearth of binary examples - I only found protobuf parser. Ideas are welcome |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ignoring the Unfortunately, if the size isn't immediately followed by the contents, you can't directly use |
Beta Was this translation helpful? Give feedback.
Ignoring the
atom_name
, I'm assuming you want something like this: https://godbolt.org/z/Wcsnb97j1 This parses either a uint32 represenation of 1 (you might want a different endianness), followed by a uint64, or another uint32. It then matches that many bytes.Unfortunately, if the size isn't immediately followed by the contents, you can't directly use
dsl::repeat
without loosing the additional information in the header... I have to add something for that.