dissect.cstruct.types.enum
#
Module Contents#
Classes#
Implements an Enum type. |
|
Implements a value instance of an Enum |
- class dissect.cstruct.types.enum.Enum(cstruct: Enum.__init__.cstruct, name: str, type_: dissect.cstruct.types.BaseType, values: Dict[str, int])#
Bases:
dissect.cstruct.types.RawType
Implements an Enum type.
Enums can be made using any type. The API for accessing enums and their values is very similar to Python 3 native enums.
Example
When using the default C-style parser, the following syntax is supported:
- enum <name> [: <type>] {
<values>
};
For example, an enum that has A=1, B=5 and C=6 could be written like so:
- enum Testuint16 {
A, B=5, C
};
- __call__(value: Union[int, BinaryIO]) EnumInstance #
- __getitem__(attr: str) EnumInstance #
- __getattr__(attr: str) EnumInstance #
- __contains__(attr: str) bool #
- default() EnumInstance #
Return a default value of this type.
- default_array(count: int) List[EnumInstance] #
Return a default array of this type.
- class dissect.cstruct.types.enum.EnumInstance(enum: Enum, value: int)#
Implements a value instance of an Enum
- property name: str#
- __eq__(value: Union[int, EnumInstance]) bool #
Return self==value.
- __ne__(value: Union[int, EnumInstance]) bool #
Return self!=value.
- __hash__() int #
Return hash(self).
- __str__() str #
Return str(self).
- __repr__() str #
Return repr(self).