dissect.cstruct.types.base¶
Module Contents¶
Classes¶
Attributes¶
- dissect.cstruct.types.base.EOF = -3599¶
- class dissect.cstruct.types.base.MetaType¶
Bases:
typeBase metaclass for cstruct type classes.
- cs: dissect.cstruct.cstruct.cstruct¶
The cstruct instance this type class belongs to.
- size: int | None¶
The size of the type in bytes. Can be
Nonefor dynamic sized types.
- dynamic: bool¶
Whether or not the type is dynamically sized.
- alignment: int | None¶
The alignment of the type in bytes. A value of
Nonewill be treated as 1-byte aligned.
- __call__(*args, **kwargs) typing_extensions.Self¶
Adds support for
TypeClass(bytes | file-like object)parsing syntax.
- __getitem__(num_entries: int | dissect.cstruct.expression.Expression | None) type[BaseArray]¶
Create a new array with the given number of entries.
- __bool__() bool¶
Type class is always truthy.
- __len__() int¶
Return the byte size of the type.
- __default__() typing_extensions.Self¶
Return the default value of this type.
- reads(data: bytes | memoryview | bytearray) typing_extensions.Self¶
Parse the given data from a bytes-like object.
- Parameters:
data – Bytes-like object to parse.
- Returns:
The parsed value of this type.
- read(obj: BinaryIO | bytes | memoryview | bytearray) typing_extensions.Self¶
Parse the given data.
- Parameters:
obj – Data to parse. Can be a bytes-like object or a file-like object.
- Returns:
The parsed value of this type.
- write(stream: BinaryIO, value: Any) int¶
Write a value to a writable file-like object.
- Parameters:
stream – File-like objects that supports writing.
value – Value to write.
- Returns:
The amount of bytes written.
- class dissect.cstruct.types.base.BaseType¶
Base class for cstruct type classes.
- dumps¶
- write¶
- __len__() int¶
Return the byte size of the type.
- dissect.cstruct.types.base.T¶
- class dissect.cstruct.types.base.BaseArray¶
Bases:
BaseTypeImplements a fixed or dynamically sized array type.
Example
When using the default C-style parser, the following syntax is supported:
x[3] -> 3 -> static length. x[] -> None -> null-terminated. x[expr] -> expr -> dynamic length.
- num_entries: ClassVar[int | dissect.cstruct.expression.Expression | None]¶
- null_terminated: ClassVar[bool]¶