In [1]:
from konfoo import Index, Byteorder, String
Item type of the field
class.
In [2]:
String.item_type
Out[2]:
Checks if the field
class is a bit
field.
In [3]:
String.is_bit()
Out[3]:
Checks if the field
class is a boolean
field.
In [4]:
String.is_bool()
Out[4]:
Checks if the field
class is a decimal
number field.
In [5]:
String.is_decimal()
Out[5]:
Checks if the field
class is a floating point
number field.
In [6]:
String.is_float()
Out[6]:
Checks if the field
class is a pointer
field.
In [7]:
String.is_pointer()
Out[7]:
Checks if the field
class is a stream
field.
In [8]:
String.is_stream()
Out[8]:
Checks if the field
class is a string
field.
In [9]:
String.is_string()
Out[9]:
In [10]:
string = String(size=0)
In [11]:
string = String()
In [12]:
string
Out[12]:
In [13]:
str(string)
Out[13]:
In [14]:
repr(string)
Out[14]:
In [15]:
string.name
Out[15]:
In [16]:
string.index
Out[16]:
Byte index
of the field
within the byte stream
.
In [17]:
string.index.byte
Out[17]:
Bit offset relative to the byte index
of the field
within the byte stream
.
In [18]:
string.index.bit
Out[18]:
Absolute address of the field
within the data source
.
In [19]:
string.index.address
Out[19]:
Base address of the byte stream
within the data source
.
In [20]:
string.index.base_address
Out[20]:
Indexes the field
and returns the index
after the field
.
In [21]:
string.index_field(index=Index())
Out[21]:
In [22]:
string.alignment
Out[22]:
Byte size of the aligned field group
.
In [23]:
string.alignment.byte_size
Out[23]:
Bit offset of field
in the aligned field group
.
In [24]:
string.alignment.bit_offset
Out[24]:
In [25]:
string.bit_size
Out[25]:
In [26]:
len(string)
Out[26]:
In [27]:
bool(string)
Out[27]:
In [28]:
string.byte_order
Out[28]:
In [29]:
string.byte_order.value
Out[29]:
In [30]:
string.byte_order.name
Out[30]:
In [31]:
string.byte_order = 'auto'
In [32]:
string.byte_order = Byteorder.auto
Checks if the string field
is zero-terminated.
In [33]:
string.is_terminated()
Out[33]:
Returns the string field
value as an ascii encoded string.
In [34]:
string.value
Out[34]:
Returns the string field
value as a number of bytes.
In [35]:
bytes(string)
Out[35]:
In [36]:
bytes(string).hex()
Out[36]:
Returns the string field
value as a lowercase hexadecimal encoded string.
In [37]:
string.hex()
Out[37]:
Returns the meatadata
of the field
as an ordered dictionary.
In [38]:
string.describe()
Out[38]:
Resizing the string
field.
In [39]:
string.resize(6)
View of the string
field.
In [40]:
string
Out[40]:
Index of the string
field.
In [41]:
string.index
Out[41]:
Name of the string
field.
In [42]:
string.name
Out[42]:
Alignment of the string
field.
In [43]:
string.alignment
Out[43]:
Bit size of the string
field.
In [44]:
string.bit_size
Out[44]:
Byte length of the string
field.
In [45]:
len(string)
Out[45]:
In [46]:
bool(string)
Out[46]:
Value of the string
field
In [47]:
string.value
Out[47]:
In [48]:
bytes(string)
Out[48]:
In [49]:
bytes(string).hex()
Out[49]:
In [50]:
string.hex()
Out[50]:
In [51]:
string.is_terminated()
Out[51]:
In [52]:
string.deserialize(b'Konfoo')
Out[52]:
In [53]:
string.value
Out[53]:
In [54]:
bytes(string)
Out[54]:
In [55]:
bytes(string).hex()
Out[55]:
In [56]:
string.hex()
Out[56]:
In [57]:
buffer = bytearray()
In [58]:
string.value = 'Konfoo'
In [59]:
string.value = b'Konfoo'
In [60]:
string.serialize(buffer)
Out[60]:
In [61]:
buffer.hex()
Out[61]:
In [62]:
bytes(string).hex()
Out[62]:
In [ ]: