MostAwesomeDude/construct — Issue #13: Differential Encoding
Author: ZiglioNZ
Created: 2012-01-08 09:57:31+00:00
State: open

Hi,

I'm trying to build a Construct for a specific protocol and am a bit stuck. I wonder whether you guys can give me a tip.
Our message contains a list of records. The first entry is uncompressed, the following entries are compressed. That means that each field of a compressed entry depends on the value of the previous entry.

Message = Struct("Message",
Embed( Uncompressed ),
OptionalGreedyRange( Compressed )
)

At the moment I've parsing the raw bits of a Compressed entry as am not sure what I should do to refer to the previous entry.
I can think of two strategies:
1. Implement an Adapter for each field of the Compressed message where somehow I can refer to the previous entry (it could be a global)
2. Use the Context. But I haven't been example other than unit tests that use Repeaters or the Context. I would avoid using meta construct if possible

Ideally my struct would return a list containing all entries. Right now, with the above Struct, I'm getting the fields of the uncompressed entry plus a list of the other entries.

Thank you!! I love Construct and have been making progress with my port to Java: https://github.com/ziglionz/construct