4.5.1. Sequence#
- class caterpillar.model.Sequence(model, order=None, arch=None, options=None, field_options=None)[source]#
Default implementation for a sequence of fields.
The native Python type mapped to this struct class is
dict. To convert a dictionary into a sequence, you can either use the contructor directly or apply the type converter for this class:>>> to_struct({'a': uint8}) Sequence(fields=['a'])
Changed in version 2.6.0: The
Sequenceclass now internally uses another class (_Member) to store the fields and actions.- has_option(option: Flag) bool[source]#
Check if the struct has a specific option.
- Parameters:
option – The option to check.
- Returns:
True if the struct has the specified option, else False.
- add_field(name: str, field: Field, included: bool = False) None[source]#
Add a field to the struct.
- Parameters:
name – The name of the field.
field – The field to add.
included – True if the field should be included, else False.