Skip to content

features #8

Closed
tomerfiliba opened this Issue Sep 7, 2012 · 0 comments

1 participant

@tomerfiliba
construct member

Tomer,

I checked out the versions of Construct and the last version that did what I needed it to do was version 2.04.

One of the capabilities I needed was a way to display the parsing in the order of the constructs...later versions did not allow me to do this. It is far faster to find things and fix things when they are in order on a large parse.

The seconds capability I needed was a way to display a table with one row showing the dot notation needed to access and element and the other column containing the value of the object....again all this in parse order.

With version 2.04 I was able to achieve these two capabilities...but not with the later versions of Construct.

This email however, is a request for an additional capability (possible as a parameter to set 'True' or 'False'). The capability is to have Construct generate an exception whenever a Construct has embedded within it another structure that would overwrite existing names at the same level...an example:

  • This would NOT generate an exception (since a,b,c,d do not overwrite one another):
>>> foo = Struct("foo",
...     UBInt8("a"),
...     UBInt8("b"),
... )
>>> bar= Struct("bar",
...     Embed(foo, overwrite=True),  # this places "foo" at same level as "bar"
...     UBInt8("c"),
...     UBInt8("d"),
... )
>>> bar.parse("abcd")
Container(a = 97, b = 98, c = 99, d = 100)
  • This WOULD generate an exception (since a,b get overwritten):
>>> foo = Struct("foo",
...     UBInt8("a"),
...     UBInt8("b"),
... )
>>> bar= Struct("bar",
...     Embed(foo, overwrite=False),    # this would generate exception if overwrite takes place
...     UBInt8("a"),
...     UBInt8("b"),
... )
>>> bar.parse("abcd")
EXCEPTION GENERATED...

This capability would help immensely in my very large parsing project.
If you can either add this capability or show me how I can add it, it would be a huge time saver.
Construct is an amazing tool and I'm glad you wrote it.

Thanks Tomer,
-Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.