-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
I am working with a really complex binary spec (LLRP).
Some of its fields are prefixed by a size followed by that number of data
elements (array).
It would be really useful to have an syntax to describe these elements in
bitstring.
Consider adding the following syntax:
SizeSpec[DataSpec]
That is, a SizeSpec followed by a DataSpec enclosed in square brackets to
indicate that an array follows.
Examples:
uintbe:16[bytes:8] # A 16-bit length array of bytes. Returns a string (i.e. "abcdef")
uintbe:32[uintbe:32] # A 32-bit length array of words. Returns a list of numbers (i.e. [1,2,3,4])
It would also be great to support composite arrays. For example:
uint:32[uint:32, uint:16, uint:16]
# A 32-bit length array of elements consisting of 32, 16 and 16 bit numbers. Returns a list of lists (i.e. [[1,2,3],[4,5,6],[7,8,9]])
Finally, and I know this is a tall one, it would be great to support arrays
inside arrays. For example:
uintbe:16[uintbe:8[bytes:8]]
# A 16-bit length array of 8-bit length prefixed strings. Returns a list of strings (i.e. ['abc', 'def'])
uintbe:16[uintbe:32, uintbe:8[bytes:8]]
# A 16-bit length array of elements consisting of a 32 bit number followed by a length-prefixed string. Returns a list of lists (i.e. [[12,'Buckle my shoe'], [56, 'Pick up sticks']])
I recognize that this could complicate things *a lot*, but I figured I could
always ask anyway.
Thanks much. Your library has saved me days of work already.
Original issue reported on code.google.com by edward.s...@gmail.com on 6 Dec 2012 at 3:31