Panda3D
Public Member Functions | List of all members
StreamWriter Class Reference

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. More...

Public Member Functions

 __init__ (const StreamWriter copy)
 The copy constructor does not copy ownership of the stream. More...
 
 __init__ (Ostream out, bool owns_stream)
 
 addBeFloat32 (float value)
 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. More...
 
 addBeFloat64 (PNFloat64 value)
 Adds a 64-bit big-endian floating-point number to the streamWriter. More...
 
 addBeInt16 (PNInt16 value)
 Adds a signed 16-bit big-endian integer to the streamWriter. More...
 
 addBeInt32 (PNInt32 value)
 Adds a signed 32-bit big-endian integer to the streamWriter. More...
 
 addBeInt64 (PNInt64 value)
 Adds a signed 64-bit big-endian integer to the streamWriter. More...
 
 addBeUint16 (PNUint16 value)
 Adds an unsigned 16-bit big-endian integer to the streamWriter. More...
 
 addBeUint32 (PNUint32 value)
 Adds an unsigned 32-bit big-endian integer to the streamWriter. More...
 
 addBeUint64 (PNUint64 value)
 Adds an unsigned 64-bit big-endian integer to the streamWriter. More...
 
 addBool (bool value)
 Adds a boolean value to the stream. More...
 
 addFixedString (str str, size_t size)
 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. More...
 
 addFloat32 (float value)
 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. More...
 
 addFloat64 (PNFloat64 value)
 Adds a 64-bit floating-point number to the stream. More...
 
 addInt16 (PNInt16 value)
 Adds a signed 16-bit integer to the stream. More...
 
 addInt32 (PNInt32 value)
 Adds a signed 32-bit integer to the stream. More...
 
 addInt64 (PNInt64 value)
 Adds a signed 64-bit integer to the stream. More...
 
 addInt8 (PNInt8 value)
 Adds a signed 8-bit integer to the stream. More...
 
 addString (str str)
 Adds a variable-length string to the stream. This actually adds a count followed by n bytes. More...
 
 addString32 (str str)
 Adds a variable-length string to the stream, using a 32-bit length field. More...
 
 addUint16 (PNUint16 value)
 Adds an unsigned 16-bit integer to the stream. More...
 
 addUint32 (PNUint32 value)
 Adds an unsigned 32-bit integer to the stream. More...
 
 addUint64 (PNUint64 value)
 Adds an unsigned 64-bit integer to the stream. More...
 
 addUint8 (PNUint8 value)
 Adds an unsigned 8-bit integer to the stream. More...
 
 addZString (str str)
 Adds a variable-length string to the stream, as a NULL-terminated string. More...
 
 appendData (str data)
 Appends some more raw data to the end of the streamWriter. More...
 
 flush ()
 Calls flush() on the underlying stream. More...
 
Ostream getOstream ()
 Returns the stream in use. More...
 
StreamWriter operator= (const StreamWriter copy)
 
 padBytes (size_t size)
 
 write (str str)
 A synonym of append_data(). This is useful when assigning the StreamWriter to sys.stderr and/or sys.stdout in Python. More...
 

Detailed Description

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const StreamWriter  copy)

The copy constructor does not copy ownership of the stream.

◆ __init__() [2/2]

__init__ ( Ostream  out,
bool  owns_stream 
)

◆ addBeFloat32()

addBeFloat32 ( float  value)

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()

addBeFloat64 ( PNFloat64  value)

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

◆ addBeInt16()

addBeInt16 ( PNInt16  value)

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

◆ addBeInt32()

addBeInt32 ( PNInt32  value)

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

◆ addBeInt64()

addBeInt64 ( PNInt64  value)

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

◆ addBeUint16()

addBeUint16 ( PNUint16  value)

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

◆ addBeUint32()

addBeUint32 ( PNUint32  value)

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

◆ addBeUint64()

addBeUint64 ( PNUint64  value)

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

◆ addBool()

addBool ( bool  value)

Adds a boolean value to the stream.

◆ addFixedString()

addFixedString ( str  str,
size_t  size 
)

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()

addFloat32 ( float  value)

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()

addFloat64 ( PNFloat64  value)

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

◆ addInt16()

addInt16 ( PNInt16  value)

Adds a signed 16-bit integer to the stream.

◆ addInt32()

addInt32 ( PNInt32  value)

Adds a signed 32-bit integer to the stream.

◆ addInt64()

addInt64 ( PNInt64  value)

Adds a signed 64-bit integer to the stream.

◆ addInt8()

addInt8 ( PNInt8  value)

Adds a signed 8-bit integer to the stream.

◆ addString()

addString ( str  str)

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

◆ addString32()

addString32 ( str  str)

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

◆ addUint16()

addUint16 ( PNUint16  value)

Adds an unsigned 16-bit integer to the stream.

◆ addUint32()

addUint32 ( PNUint32  value)

Adds an unsigned 32-bit integer to the stream.

◆ addUint64()

addUint64 ( PNUint64  value)

Adds an unsigned 64-bit integer to the stream.

◆ addUint8()

addUint8 ( PNUint8  value)

Adds an unsigned 8-bit integer to the stream.

◆ addZString()

addZString ( str  str)

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

◆ appendData()

appendData ( str  data)

Appends some more raw data to the end of the streamWriter.

◆ flush()

flush ( )

Calls flush() on the underlying stream.

◆ getOstream()

Ostream getOstream ( )

Returns the stream in use.

◆ operator=()

StreamWriter operator= ( const StreamWriter  copy)

◆ padBytes()

padBytes ( size_t  size)

◆ write()

write ( str  str)

A synonym of append_data(). This is useful when assigning the StreamWriter to sys.stderr and/or sys.stdout in Python.