Panda3D
|
A StreamWriter object is used to write sequential binary data directly to an ostream. More...
#include "streamWriter.h"
Public Member Functions | |
StreamWriter (ostream &out) | |
StreamWriter (ostream *out, bool owns_stream) | |
StreamWriter (const StreamWriter ©) | |
The copy constructor does not copy ownership of the stream. More... | |
void | add_be_float32 (float value) |
Adds a 32-bit single-precision big-endian floating-point number to the stream. More... | |
void | add_be_float64 (PN_float64 value) |
Adds a 64-bit big-endian floating-point number to the streamWriter. More... | |
void | add_be_int16 (PN_int16 value) |
Adds a signed 16-bit big-endian integer to the streamWriter. More... | |
void | add_be_int32 (PN_int32 value) |
Adds a signed 32-bit big-endian integer to the streamWriter. More... | |
void | add_be_int64 (PN_int64 value) |
Adds a signed 64-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint16 (PN_uint16 value) |
Adds an unsigned 16-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint32 (PN_uint32 value) |
Adds an unsigned 32-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint64 (PN_uint64 value) |
Adds an unsigned 64-bit big-endian integer to the streamWriter. More... | |
void | add_bool (bool value) |
Adds a boolean value to the stream. More... | |
void | add_fixed_string (const string &str, size_t size) |
Adds a fixed-length string to the stream. More... | |
void | add_float32 (float value) |
Adds a 32-bit single-precision floating-point number to the stream. More... | |
void | add_float64 (PN_float64 value) |
Adds a 64-bit floating-point number to the stream. More... | |
void | add_int16 (PN_int16 value) |
Adds a signed 16-bit integer to the stream. More... | |
void | add_int32 (PN_int32 value) |
Adds a signed 32-bit integer to the stream. More... | |
void | add_int64 (PN_int64 value) |
Adds a signed 64-bit integer to the stream. More... | |
void | add_int8 (PN_int8 value) |
Adds a signed 8-bit integer to the stream. More... | |
void | add_string (const string &str) |
Adds a variable-length string to the stream. More... | |
void | add_string32 (const string &str) |
Adds a variable-length string to the stream, using a 32-bit length field. More... | |
void | add_uint16 (PN_uint16 value) |
Adds an unsigned 16-bit integer to the stream. More... | |
void | add_uint32 (PN_uint32 value) |
Adds an unsigned 32-bit integer to the stream. More... | |
void | add_uint64 (PN_uint64 value) |
Adds an unsigned 64-bit integer to the stream. More... | |
void | add_uint8 (PN_uint8 value) |
Adds an unsigned 8-bit integer to the stream. More... | |
void | add_z_string (string str) |
Adds a variable-length string to the stream, as a NULL-terminated string. More... | |
void | append_data (const void *data, size_t size) |
Appends some more raw data to the end of the streamWriter. More... | |
void | append_data (const string &data) |
Appends some more raw data to the end of the streamWriter. More... | |
void | flush () |
Calls flush() on the underlying stream. More... | |
ostream * | get_ostream () const |
Returns the stream in use. More... | |
void | operator= (const StreamWriter ©) |
The copy constructor does not copy ownership of the stream. More... | |
void | pad_bytes (size_t size) |
Adds the indicated number of zero bytes to the stream. More... | |
void | write (const string &str) |
A synonym of append_data(). More... | |
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.
Definition at line 33 of file streamWriter.h.
|
inline |
The copy constructor does not copy ownership of the stream.
Definition at line 47 of file streamWriter.I.
References operator=().
|
inline |
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.
Definition at line 296 of file streamWriter.I.
References add_be_float64(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_uint64().
|
inline |
Adds a 64-bit big-endian floating-point number to the streamWriter.
Definition at line 312 of file streamWriter.I.
References add_string(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_float32().
|
inline |
Adds a signed 16-bit big-endian integer to the streamWriter.
Definition at line 222 of file streamWriter.I.
References add_be_int32(), append_data(), and ReversedNumericData::get_data().
Referenced by add_float64().
|
inline |
Adds a signed 32-bit big-endian integer to the streamWriter.
Definition at line 234 of file streamWriter.I.
References add_be_int64(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_int16().
|
inline |
Adds a signed 64-bit big-endian integer to the streamWriter.
Definition at line 246 of file streamWriter.I.
References add_be_uint16(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_int32().
|
inline |
Adds an unsigned 16-bit big-endian integer to the streamWriter.
Definition at line 258 of file streamWriter.I.
References add_be_uint32(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_int64().
|
inline |
Adds an unsigned 32-bit big-endian integer to the streamWriter.
Definition at line 270 of file streamWriter.I.
References add_be_uint64(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_uint16(), and HashVal::output_binary().
|
inline |
Adds an unsigned 64-bit big-endian integer to the streamWriter.
Definition at line 282 of file streamWriter.I.
References add_be_float32(), append_data(), and ReversedNumericData::get_data().
Referenced by add_be_uint32().
|
inline |
Adds a boolean value to the stream.
Definition at line 96 of file streamWriter.I.
References add_int8(), and add_uint8().
Referenced by get_ostream().
|
inline |
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.
Definition at line 377 of file streamWriter.I.
References append_data(), and pad_bytes().
Referenced by add_z_string().
|
inline |
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.
Definition at line 195 of file streamWriter.I.
References add_float64(), append_data(), and NativeNumericData::get_data().
Referenced by add_uint64().
|
inline |
Adds a 64-bit floating-point number to the stream.
Definition at line 210 of file streamWriter.I.
References add_be_int16(), append_data(), and NativeNumericData::get_data().
Referenced by add_float32(), and DownloadDb::Db::parse_record_header().
|
inline |
Adds a signed 16-bit integer to the stream.
Definition at line 126 of file streamWriter.I.
References add_int32(), append_data(), and NativeNumericData::get_data().
Referenced by add_uint8(), and Multifile::read_subfile().
|
inline |
Adds a signed 32-bit integer to the stream.
Definition at line 137 of file streamWriter.I.
References add_int64(), append_data(), and NativeNumericData::get_data().
Referenced by add_int16(), DownloadDb::get_hash(), DownloadDb::Db::parse_record_header(), and DownloadDb::Db::write_bogus_header().
|
inline |
Adds a signed 64-bit integer to the stream.
Definition at line 148 of file streamWriter.I.
References add_uint16(), append_data(), and NativeNumericData::get_data().
Referenced by add_int32().
|
inline |
Adds a signed 8-bit integer to the stream.
Definition at line 106 of file streamWriter.I.
References add_uint8(), and append_data().
Referenced by add_bool().
|
inline |
Adds a variable-length string to the stream.
This actually adds a count followed by n bytes.
Definition at line 324 of file streamWriter.I.
References add_string32(), add_uint16(), and append_data().
Referenced by add_be_float64().
|
inline |
Adds a variable-length string to the stream, using a 32-bit length field.
Definition at line 342 of file streamWriter.I.
References add_uint32(), add_z_string(), and append_data().
Referenced by add_string().
|
inline |
Adds an unsigned 16-bit integer to the stream.
Definition at line 159 of file streamWriter.I.
References add_uint32(), append_data(), and NativeNumericData::get_data().
Referenced by add_int64(), and add_string().
|
inline |
Adds an unsigned 32-bit integer to the stream.
Definition at line 170 of file streamWriter.I.
References add_uint64(), append_data(), and NativeNumericData::get_data().
Referenced by add_string32(), add_uint16(), DatagramOutputFile::copy_datagram(), Multifile::flush(), HashVal::input_dec(), DatagramOutputFile::put_datagram(), Multifile::read_subfile(), Multifile::update_subfile(), and DownloadDb::Db::write_bogus_header().
|
inline |
Adds an unsigned 64-bit integer to the stream.
Definition at line 181 of file streamWriter.I.
References add_float32(), append_data(), and NativeNumericData::get_data().
Referenced by add_uint32(), DatagramOutputFile::copy_datagram(), and DatagramOutputFile::put_datagram().
|
inline |
Adds an unsigned 8-bit integer to the stream.
Definition at line 116 of file streamWriter.I.
References add_int16(), and append_data().
Referenced by add_bool(), add_int8(), and add_z_string().
|
inline |
Adds a variable-length string to the stream, as a NULL-terminated string.
Definition at line 357 of file streamWriter.I.
References add_fixed_string(), add_uint8(), and append_data().
Referenced by add_string32().
|
inline |
Appends some more raw data to the end of the streamWriter.
Definition at line 394 of file streamWriter.I.
Referenced by add_be_float32(), add_be_float64(), add_be_int16(), add_be_int32(), add_be_int64(), add_be_uint16(), add_be_uint32(), add_be_uint64(), add_fixed_string(), add_float32(), add_float64(), add_int16(), add_int32(), add_int64(), add_int8(), add_string(), add_string32(), add_uint16(), add_uint32(), add_uint64(), add_uint8(), add_z_string(), append_data(), DownloadDb::get_hash(), DownloadDb::Db::parse_record_header(), Multifile::update_subfile(), and write().
|
inline |
Appends some more raw data to the end of the streamWriter.
Definition at line 405 of file streamWriter.I.
References append_data(), and flush().
|
inline |
Calls flush() on the underlying stream.
Definition at line 415 of file streamWriter.I.
References write().
Referenced by append_data().
|
inline |
Returns the stream in use.
Definition at line 86 of file streamWriter.I.
References add_bool().
Referenced by operator=().
|
inline |
The copy constructor does not copy ownership of the stream.
Definition at line 60 of file streamWriter.I.
References get_ostream().
Referenced by StreamWriter().
void StreamWriter::pad_bytes | ( | size_t | size | ) |
Adds the indicated number of zero bytes to the stream.
Definition at line 24 of file streamWriter.cxx.
Referenced by add_fixed_string().
|
inline |
A synonym of append_data().
This is useful when assigning the StreamWriter to sys.stderr and/or sys.stdout in Python.
Definition at line 427 of file streamWriter.I.
References append_data().
Referenced by flush().