# StreamWriter

from pandac.PandaModules import StreamWriter

Class : StreamWriter
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.

## Inheritance:

StreamWriter:

## Methods of StreamWriter:

StreamWriter (Constructor)
addBeFloat32
addBeFloat64
addBeInt16
addBeInt32
addBeInt64
addBeUint16
addBeUint32
addBeUint64
addBool
addFixedString
addFloat32
addFloat64
addInt16
addInt32
addInt64
addInt8
addString
addString32
addUint16
addUint32
addUint64
addUint8
addZString
appendData
flush
getOstream
operator =
padBytes

StreamWriter StreamWriter::StreamWriter(ostream *out, bool owns_stream); Description: Description: The copy constructor does not copy ownership of the stream.

addBeFloat32 void StreamWriter::add_be_float32(float value); Description: 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 void StreamWriter::add_be_float64(double value); Description: Adds a 64-bit big-endian floating-point number to the streamWriter.

addBeInt16 void StreamWriter::add_be_int16(short int value); These functions pack numbers big-endian, in case that's desired. Description: Adds a signed 16-bit big-endian integer to the streamWriter.

addBeInt32 void StreamWriter::add_be_int32(int value); These functions pack numbers big-endian, in case that's desired. Description: Adds a signed 32-bit big-endian integer to the streamWriter.

addBeInt64 void StreamWriter::add_be_int64(long int value); Description: Adds a signed 64-bit big-endian integer to the streamWriter.

addBeUint16 void StreamWriter::add_be_uint16(unsigned short int value); Description: Adds an unsigned 16-bit big-endian integer to the streamWriter.

addBeUint32 void StreamWriter::add_be_uint32(unsigned int value); Description: Adds an unsigned 32-bit big-endian integer to the streamWriter.

addBeUint64 void StreamWriter::add_be_uint64(unsigned long int value); Description: Adds an unsigned 64-bit big-endian integer to the streamWriter.

addBool void StreamWriter::add_bool(bool value); Description: Adds a boolean value to the stream.

addFixedString void StreamWriter::add_fixed_string(string const &str, unsigned int size); Description: 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 void StreamWriter::add_float32(float value); Description: 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 void StreamWriter::add_float64(double value); Description: Adds a 64-bit floating-point number to the stream.

addInt16 void StreamWriter::add_int16(short int value); The default numeric packing is little-endian. Description: Adds a signed 16-bit integer to the stream.

addInt32 void StreamWriter::add_int32(int value); The default numeric packing is little-endian. Description: Adds a signed 32-bit integer to the stream.

addInt64 void StreamWriter::add_int64(long int value); Description: Adds a signed 64-bit integer to the stream.

addInt8 void StreamWriter::add_int8(signed char value); Description: Adds a signed 8-bit integer to the stream.

addString void StreamWriter::add_string(string const &str); Description: Adds a variable-length string to the stream. This actually adds a count followed by n bytes.

addString32 void StreamWriter::add_string32(string const &str); Description: Adds a variable-length string to the stream, using a 32-bit length field.

addUint16 void StreamWriter::add_uint16(unsigned short int value); Description: Adds an unsigned 16-bit integer to the stream.

addUint32 void StreamWriter::add_uint32(unsigned int value); Description: Adds an unsigned 32-bit integer to the stream.

addUint64 void StreamWriter::add_uint64(unsigned long int value); Description: Adds an unsigned 64-bit integer to the stream.

addUint8 void StreamWriter::add_uint8(unsigned char value); Description: Adds an unsigned 8-bit integer to the stream.

addZString void StreamWriter::add_z_string(string str); Description: Adds a variable-length string to the stream, as a NULL-terminated string.

appendData void StreamWriter::append_data(void const *data, unsigned int size); Description: Appends some more raw data to the end of the streamWriter.

flush void StreamWriter::flush(void); Description: Calls flush() on the underlying stream.

getOstream ostream *StreamWriter::get_ostream(void) const; Description: Returns the stream in use.

operator = void StreamWriter::operator =(StreamWriter const &copy); Description: The copy constructor does not copy ownership of the stream.

padBytes void StreamWriter::pad_bytes(unsigned int size); Undocumented function.