c4d.storage.ByteSeq
¶
Several objects and hooks in Cinema 4D allow Python to access the internal data on low-level. These functions can be used to handle raw data.
ByteSeq
is similar to the built-in
Buffer Object
but is optimized to work with Cinema 4D.
c4d.storage.
ByteSeq
¶
ByteSeq.__str__()
ByteSeq.__add__()
ByteSeq.__iter__()
ByteSeq.__compare__()
ByteSeq.__hash__()
ByteSeq.__len__()
ByteSeq.__setitem__()
ByteSeq.__getitem__()
ByteSeq.
__init__
(
buf
,
len
[
,
readonly=False
]
)
¶
Allocates a byte sequence.
Parameters: |
|
---|---|
Return type: | |
Returns: |
The byte sequence object. |
ByteSeq.
__str__
(
)
¶
Creates a string object from the byte sequence.
Return type: | str |
---|---|
Returns: | The byte-sequence returned as a string. |
ByteSeq.
__add__
(
other
)
¶
Parameters: | other ( int ) – The offset value. |
---|---|
Return type: | c4d.storage.ByteSeq |
Returns: |
New
ByteSeq
object.
|
ByteSeq.
__compare__
(
other
)
¶
Compares two byte sequences.
Parameters: | other ( c4d.storage.ByteSeq ) – The other byte sequence. |
---|---|
Return type: | bool |
Returns: | True if the byte sequences are equal, otherwise False . |
ByteSeq.
__iter__
(
)
¶
Iterates over the bytes of the object, interpreted as one-element string:
for b in bs: print b
Return type: | iter for str |
---|---|
Returns: | The iterator. |
ByteSeq.
__hash__
(
)
¶
Returns a hash of the byte sequence. The hash value is cached if the object owns the byte sequence and it is flagged as read-only:
print hash(bs)
Return type: | int |
---|---|
Returns: | The hash. |
ByteSeq.
__len__
(
)
¶
Returns the length of the byte sequence.
Return type: | int |
---|---|
Returns: | The length. |
ByteSeq.
__setitem__
(
key
,
value
)
¶
Replaces a byte at position key with the new value :
bs1[5:7] = "ab" bs2[100] = "a" bs3[:100] = "0"*100
Raises: |
TypeError – If byte sequence is flagged as read-only. |
---|---|
Parameters: |
|
ByteSeq.
__getitem__
(
key
)
¶
Gets the bytes at position key:
print bs1[5:7] #output: "ab" print bs2[100] # output "a" print bs3[:100] # output "0000..."
Parameters: | key ( int or slice ) – The index |
---|---|
Return type: | str |
Returns: | The bytes at the requested position. |
ByteSeq.
GetClone
(
)
¶
Clones a byte sequence.
Return type: | c4d.storage.ByteSeq |
---|---|
Returns: | The clone. |
ByteSeq.
GetOffset
(
o
)
¶
Returns buffer at offset o in this byte sequence.
Parameters: | o ( int ) – The offset. |
---|---|
Returns: | The buffer object. |