Buffer
Buffer(padding=0, byteorder='little')
Create binary data incrementally.
| PARAMETER | DESCRIPTION |
|---|---|
padding
|
byte value to use for padding
TYPE:
|
byteorder
|
byte order to use for multi-byte values
TYPE:
|
add_byte(byte, count=1)
Add one or more bytes to buffer.
| PARAMETER | DESCRIPTION |
|---|---|
byte
|
byte value to add
TYPE:
|
count
|
number of times to add byte
TYPE:
|
add_data(data, length=0, padding=None)
Add data to buffer, with optional padding.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
data to add (bytes or string)
TYPE:
|
length
|
pad data to this length if it is shorter
TYPE:
|
padding
|
byte value to use for padding
TYPE:
|
add_int(value, size, byteorder=None)
Add an integer of given size to buffer.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
integer value to add
TYPE:
|
size
|
size of integer in bytes
TYPE:
|
byteorder
|
override default byte order
TYPE:
|
add_long(value, byteorder=None)
Add a long (4 bytes) to buffer.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
long value to add
TYPE:
|
byteorder
|
override default byte order
TYPE:
|
add_word(word, byteorder=None)
Add a word (2 bytes) to buffer.
| PARAMETER | DESCRIPTION |
|---|---|
word
|
word value to add
TYPE:
|
byteorder
|
override default byte order
TYPE:
|
add_zeros(length)
Add given number of zero bytes to buffer.
| PARAMETER | DESCRIPTION |
|---|---|
length
|
number of zero bytes to add
TYPE:
|
clear()
Clear buffer contents.
output(file)
Write buffer contents to file.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
file object to write to
TYPE:
|
pad(length, padding=None)
Pad buffer to given length.
| PARAMETER | DESCRIPTION |
|---|---|
length
|
length of buffer after padding
TYPE:
|
padding
|
padding byte
TYPE:
|