How to implement conditional multiple parsing?

43 views
Skip to first unread message

cslug...@gmail.com

unread,
Apr 16, 2016, 7:23:45 PM4/16/16
to Construct
Hi,

Would appreciate your kind assistance in the following problem I faced.

I have a data structure that consists of multiple records. Each record has the same structure, and contains an "offset" field that points to the offset of the next record. If there is no next record, the "offset" field will be 0.

May I know how I can write the Construct code to parse this data structure such that the records will be stored in a single array?

Some sample code below:
construct.Struct(
'toc1',
construct.ULInt32('length'),
construct.SLInt16('type'),
construct.UBInt16('flag'),
construct.ULInt32('level'),
construct.ULInt32('offset')) # offset to next ToC (0 if none)


Regards.
Reply all
Reply to author
Forward
0 new messages