panda3d.core.StreamWriter

class StreamWriter

A StreamWriter object is used to write sequential binary data directly to an ostream. Its interface is very similar to Datagram by design; it’s primarily intended as a convenience to eliminate the overhead of writing bytes to a Datagram and then writing the Datagram to a stream.

Inheritance diagram

Inheritance diagram of StreamWriter

__init__(copy: StreamWriter) → None

The copy constructor does not copy ownership of the stream.

__init__(out: ostream, owns_stream: bool) → None
addBeFloat32(value: float) → None

Adds a 32-bit single-precision big-endian floating-point number to the stream. Since this kind of float is not necessarily portable across different architectures, special care is required.

addBeFloat64(value: PN_float64) → None

Adds a 64-bit big-endian floating-point number to the streamWriter.

addBeInt16(value: int16_t) → None

Adds a signed 16-bit big-endian integer to the streamWriter.

addBeInt32(value: int32_t) → None

Adds a signed 32-bit big-endian integer to the streamWriter.

addBeInt64(value: int64_t) → None

Adds a signed 64-bit big-endian integer to the streamWriter.

addBeUint16(value: uint16_t) → None

Adds an unsigned 16-bit big-endian integer to the streamWriter.

addBeUint32(value: uint32_t) → None

Adds an unsigned 32-bit big-endian integer to the streamWriter.

addBeUint64(value: uint64_t) → None

Adds an unsigned 64-bit big-endian integer to the streamWriter.

addBool(value: bool) → None

Adds a boolean value to the stream.

addFixedString(str: str, size: size_t) → None

Adds a fixed-length string to the stream. If the string given is less than the requested size, this will pad the string out with zeroes; if it is greater than the requested size, this will silently truncate the string.

addFloat32(value: float) → None

Adds a 32-bit single-precision floating-point number to the stream. Since this kind of float is not necessarily portable across different architectures, special care is required.

addFloat64(value: PN_float64) → None

Adds a 64-bit floating-point number to the stream.

addInt16(value: int16_t) → None

Adds a signed 16-bit integer to the stream.

addInt32(value: int32_t) → None

Adds a signed 32-bit integer to the stream.

addInt64(value: int64_t) → None

Adds a signed 64-bit integer to the stream.

addInt8(value: int8_t) → None

Adds a signed 8-bit integer to the stream.

addString(str: str) → None

Adds a variable-length string to the stream. This actually adds a count followed by n bytes.

addString32(str: str) → None

Adds a variable-length string to the stream, using a 32-bit length field.

addUint16(value: uint16_t) → None

Adds an unsigned 16-bit integer to the stream.

addUint32(value: uint32_t) → None

Adds an unsigned 32-bit integer to the stream.

addUint64(value: uint64_t) → None

Adds an unsigned 64-bit integer to the stream.

addUint8(value: uint8_t) → None

Adds an unsigned 8-bit integer to the stream.

addZString(str: str) → None

Adds a variable-length string to the stream, as a NULL-terminated string.

appendData(data: object) → None
assign(copy: StreamWriter) → StreamWriter
Return type

StreamWriter

flush() → None

Calls flush() on the underlying stream.

getOstream() → ostream

Returns the stream in use.

Return type

ostream

property ostream

Returns the ostream this object is wrapping.

Return type

ostream

padBytes(size: size_t) → None

Adds the indicated number of zero bytes to the stream.

property softspace

Python 2 needs this for printing to work correctly.

Getter

getter for int StreamWriter::softspace;

Setter

setter for int StreamWriter::softspace;

Return type

int

write(str: str) → None

A synonym of :class:`~StreamWriter().appendData`. This is useful when assigning the StreamWriter to sys.stderr and/or sys.stdout in Python.