Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider addding support for sequence with variable element size? #13

Open
joachimmetz opened this issue Jun 16, 2018 · 2 comments
Open
Assignees

Comments

@joachimmetz
Copy link
Member

joachimmetz commented Jun 16, 2018

Consider addding support for sequence with variable element size? or add a higher (abstract) level data type for this?

For now, dtFabric will error on sequence with variable size element data type

@joachimmetz joachimmetz self-assigned this Jul 6, 2018
@joachimmetz joachimmetz changed the title add support for sequence with variable element size? Consider addding support for sequence with variable element size? Jul 11, 2018
@joachimmetz
Copy link
Member Author

joachimmetz commented Aug 8, 2018

Structure that defines a string array

name: char
type: integer
attributes:
  format: signed
  size: 1
  units: bytes
---
name: uint32
type: integer
attributes:
  format: signed
  size: 4
  units: bytes
---
name: cstring
type: string
encoding: ascii
element_data_type: char
elements_terminator: "\x00"
---
name: string_array
type: structure
attributes:
  byte_order: little-endian
members:
- name: number_of_strings
  data_type: uint32
- name: strings
  type: sequence
  element_data_type: cstring
  number_of_elements: string_array.number_of_strings

Which currently raises:

Traceback (most recent call last):
  File "./dtfabric/tests/reader.py", line 1123, in testReadFileObjectStructureWithStringArray
    definitions_reader.ReadFileObject(definitions_registry, file_object)
  File "./dtfabric/reader.py", line 947, in ReadFileObject
    raise errors.FormatError(error_message)
FormatError: in: string_array in: strings unsupported variable size element data type: cstring

Check the element data type and allow string?

@joachimmetz
Copy link
Member Author

Alternatively have specific type for a sequence of strings?

name: char
type: integer
attributes:
  format: signed
  size: 1
  units: bytes
---
name: uint32
type: integer
attributes:
  format: signed
  size: 4
  units: bytes
---
name: string_array
type: structure
attributes:
  byte_order: little-endian
members:
- name: number_of_strings
  data_type: uint32
- name: strings
  type: sequence_of_strings
  number_of_elements: string_array.number_of_strings
  string_encoding: ascii
  string_data_type: char
  string_terminator: "\x00"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant