Open
Description
Hello,
Apologies if this is the wrong venue for questions, but... I am working on a project to implement a Kaitai Struct reader for a complicated storage format.
I would like to use the endian calc feature, but the endian key occurs after useful metadata (convenient!). This is the start of the metadata spec:
seq:
- id: magic
contents: [ 0xbe, 0xbe, 0xbe, 0xbe ]
doc: |
casa magic unsigned int 3200171710 190 190 190 190
- id: size
type: u4
- id: type
type: string
- id: version
type: u4
- id: nrows
type:
switch-on: version
cases:
1: u4
2: u4
3: u8
- id: little_endian
size: 4
The 4 little_endian
bytes will be either [ 0x0, 0x0, 0x0, 0x0]
or [ 0x0, 0x0, 0x0, 0x1]
. What is the best way to handle this need to "look ahead" to determine the endianness to be able to get the proper size
and version
values? The extended metadata ksy (with endianness hard-coded) can be found here.
Many thanks, in advance, for any help.