You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`cstruct.LITTLE_ENDIAN` - Little endian byte order, standard size, no padding.
167
+
*`cstruct.BIG_ENDIAN` - Big endian byte order, standard size, no padding.
168
+
*`cstruct.NATIVE_ORDER` - Native byte order, native size, padding. Native byte order is big-endian or little-endian, depending on the host system.
169
+
170
+
Standard size depends only on the format character while native size depends on the host system.
171
+
For native order, padding is automatically added to align the structure members.
172
+
173
+
For more information, see the [struct - Byte Order, Size, and Padding](https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment) section.
169
174
170
175
```python
171
176
classNative(cstruct.MemCStruct):
@@ -321,6 +326,24 @@ class MBR(cstruct.MemCStruct):
321
326
"""
322
327
```
323
328
329
+
### Accessing Field Definitions
330
+
331
+
Python-CStruct provides the `__fields_types__` attribute at the class level, which allows you to inspect the metadata of each field.
332
+
The dictionary contains each field's name as a key and its metadata as a value.
333
+
Each field has the following attributes:
334
+
335
+
| Attribute | Description |
336
+
|------------------|------------|
337
+
|`kind`| Indicates whether the field is a primitive type or a nested struct. |
338
+
|`c_type`| The corresponding C type. |
339
+
|`ref`| If the field is a nested struct, this contains a reference to the class representing that struct. |
340
+
|`vlen_ex`| The number of elements in the field. |
341
+
|`flexible_array`| Indicates whether the field is a flexible array. |
342
+
|`byte_order`| The byte order of the field. |
343
+
|`offset`| The relative position of the field within the struct. |
344
+
|`padding`| The number of bytes added before this field for alignment. |
345
+
346
+
324
347
### Ispect memory
325
348
326
349
The [`inspect`](https://python-cstruct.readthedocs.io/en/latest/api/abstract/#cstruct.abstract.AbstractCStruct.inspect) methods displays memory contents in hexadecimal.
0 commit comments