c4d.storage.ByteSeq¶
Methods Signatures
ByteSeq.__init__(self, buf, len[, readonly]) |
Allocates a byte sequence. | ||
ByteSeq.__str__(self) |
Creates a string object from the byte sequence. | ||
ByteSeq.__add__(self, other) |
|
||
ByteSeq.__compare__(self, other) |
Compares two byte sequences. | ||
ByteSeq.__iter__(self) |
Iterates over the bytes of the object, interpreted as one-element string. | ||
ByteSeq.__hash__(self) |
Returns a hash of the byte sequence.
|
||
ByteSeq.__len__(self) |
Returns the length of the byte sequence. | ||
ByteSeq.__setitem__(self, key, value) |
Replaces a byte at position key with the new value: | ||
ByteSeq.__getitem__(self, key) |
Gets the bytes at position key: |
ByteSeq.GetClone(self) |
Clones a byte sequence. |
ByteSeq.GetOffset(self, o) |
Returns buffer at offset o in this byte sequence. |
Methods Documentation
-
ByteSeq.
__init__
(self, buf, len, readonly=False)¶ Allocates a byte sequence.
Parameters: - buf (PyCObject or None) – PyCObject address or None to allocate a new pool of memory.
- len (int) – The length of the new byte sequence.
- readonly (bool) – Set to True if the byte sequence should be flagged as read-only, otherwise False.
Return type: Returns: The byte sequence object.
-
ByteSeq.
__str__
(self)¶ Creates a string object from the byte sequence.
Return type: str Returns: The byte-sequence returned as a string.
-
ByteSeq.
__add__
(self, other)¶ Parameters: other (int) – The offset value. Return type: c4d.storage.ByteSeq Returns: New ByteSeq
object.
-
ByteSeq.
__compare__
(self, 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__
(self)¶ Iterates over the bytes of the object, interpreted as one-element string.
import c4d bs = c4d.storage.ByteSeq(None, 101) bs[:len(bs)] = "0" * len(bs) for b in bs: print b
Return type: iter for str Returns: The iterator.
-
ByteSeq.
__hash__
(self)¶ - 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__
(self)¶ Returns the length of the byte sequence.
Return type: int Returns: The length.
-
ByteSeq.
__setitem__
(self, key, value)¶ Replaces a byte at position key with the new value:
import c4d bs = c4d.storage.ByteSeq(None, 101) bs[:len(bs)] = "0" * len(bs) bs[5:7] = "ab" bs[100] = "a" bs[10:90] = "1" * 80 print bs[5:7] # output: "ab" print bs[100] # output "a" print bs[:100] # output "00000ab0001111..."
Raises: TypeError – If byte sequence is flagged as read-only.
Parameters: - key (Union[int, Slice[Any]]) – The index.
- value (int) – The new value, must be between 0-255.
-
ByteSeq.
__getitem__
(self, key)¶ Gets the bytes at position key:
import c4d bs = c4d.storage.ByteSeq(None, 101) bs[:len(bs)] = "0" * len(bs) bs[5:7] = "ab" bs[100] = "a" bs[10:90] = "1" * 80 print bs[5:7] # output: "ab" print bs[100] # output "a" print bs[:100] # output "00000ab0001111..."
Parameters: key (Union[int, Slice[Any]]) – The index Return type: str Returns: The bytes at the requested position.
-
ByteSeq.
GetClone
(self)¶ Clones a byte sequence.
Return type: c4d.storage.ByteSeq Returns: The clone.
-
ByteSeq.
GetOffset
(self, o)¶ Returns buffer at offset o in this byte sequence.
Parameters: o (int) – The offset. Returns: The buffer object.