A StreamWriter object is used to write sequential binary data directly to an ostream. More...
#include "streamWriter.h"
Public Member Functions | |
StreamWriter (std::ostream &out) | |
StreamWriter (std::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 (int16_t value) |
Adds a signed 16-bit big-endian integer to the streamWriter. More... | |
void | add_be_int32 (int32_t value) |
Adds a signed 32-bit big-endian integer to the streamWriter. More... | |
void | add_be_int64 (int64_t value) |
Adds a signed 64-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint16 (uint16_t value) |
Adds an unsigned 16-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint32 (uint32_t value) |
Adds an unsigned 32-bit big-endian integer to the streamWriter. More... | |
void | add_be_uint64 (uint64_t 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 std::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 (int16_t value) |
Adds a signed 16-bit integer to the stream. More... | |
void | add_int32 (int32_t value) |
Adds a signed 32-bit integer to the stream. More... | |
void | add_int64 (int64_t value) |
Adds a signed 64-bit integer to the stream. More... | |
void | add_int8 (int8_t value) |
Adds a signed 8-bit integer to the stream. More... | |
void | add_string (const std::string &str) |
Adds a variable-length string to the stream. More... | |
void | add_string32 (const std::string &str) |
Adds a variable-length string to the stream, using a 32-bit length field. More... | |
void | add_uint16 (uint16_t value) |
Adds an unsigned 16-bit integer to the stream. More... | |
void | add_uint32 (uint32_t value) |
Adds an unsigned 32-bit integer to the stream. More... | |
void | add_uint64 (uint64_t value) |
Adds an unsigned 64-bit integer to the stream. More... | |
void | add_uint8 (uint8_t value) |
Adds an unsigned 8-bit integer to the stream. More... | |
void | add_z_string (std::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 std::string &data) |
Appends some more raw data to the end of the streamWriter. More... | |
void | flush () |
Calls flush() on the underlying stream. More... | |
std::ostream * | get_ostream () const |
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 std::string &str) |
A synonym of append_data(). More... | |
Public Attributes | |
get_ostream | |
Returns the stream in use. 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 29 of file streamWriter.h.
|
inline |
The copy constructor does not copy ownership of the stream.
Definition at line 44 of file streamWriter.I.
|
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 245 of file streamWriter.I.
|
inline |
Adds a 64-bit big-endian floating-point number to the streamWriter.
Definition at line 258 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds a signed 16-bit big-endian integer to the streamWriter.
Definition at line 189 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds a signed 32-bit big-endian integer to the streamWriter.
Definition at line 198 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds a signed 64-bit big-endian integer to the streamWriter.
Definition at line 207 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds an unsigned 16-bit big-endian integer to the streamWriter.
Definition at line 216 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds an unsigned 32-bit big-endian integer to the streamWriter.
Definition at line 225 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
Referenced by HashVal::output_binary().
|
inline |
Adds an unsigned 64-bit big-endian integer to the streamWriter.
Definition at line 234 of file streamWriter.I.
References append_data(), and ReversedNumericData::get_data().
|
inline |
Adds a boolean value to the stream.
Definition at line 87 of file streamWriter.I.
References add_uint8().
|
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 311 of file streamWriter.I.
References append_data(), and pad_bytes().
|
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 167 of file streamWriter.I.
|
inline |
Adds a 64-bit floating-point number to the stream.
Definition at line 180 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
|
inline |
Adds a signed 16-bit integer to the stream.
Definition at line 111 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
|
inline |
Adds a signed 32-bit integer to the stream.
Definition at line 120 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
Referenced by DownloadDb::Db::write_bogus_header().
|
inline |
Adds a signed 64-bit integer to the stream.
Definition at line 129 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
|
inline |
Adds a signed 8-bit integer to the stream.
Definition at line 95 of file streamWriter.I.
References append_data().
|
inline |
Adds a variable-length string to the stream.
This actually adds a count followed by n bytes.
Definition at line 268 of file streamWriter.I.
|
inline |
Adds a variable-length string to the stream, using a 32-bit length field.
Definition at line 283 of file streamWriter.I.
References add_uint32(), and append_data().
|
inline |
Adds an unsigned 16-bit integer to the stream.
Definition at line 138 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
|
inline |
Adds an unsigned 32-bit integer to the stream.
Definition at line 147 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
Referenced by add_string32(), and DownloadDb::Db::write_bogus_header().
|
inline |
Adds an unsigned 64-bit integer to the stream.
Definition at line 156 of file streamWriter.I.
References append_data(), and NativeNumericData::get_data().
|
inline |
Adds an unsigned 8-bit integer to the stream.
Definition at line 103 of file streamWriter.I.
References append_data().
Referenced by add_bool(), and add_z_string().
|
inline |
Adds a variable-length string to the stream, as a NULL-terminated string.
Definition at line 295 of file streamWriter.I.
References add_uint8(), and append_data().
|
inline |
Appends some more raw data to the end of the streamWriter.
Definition at line 325 of file streamWriter.I.
Referenced by 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_float64(), add_int16(), add_int32(), add_int64(), add_int8(), add_string32(), add_uint16(), add_uint32(), add_uint64(), add_uint8(), and add_z_string().
|
inline |
Appends some more raw data to the end of the streamWriter.
Definition at line 333 of file streamWriter.I.
|
inline |
Calls flush() on the underlying stream.
Definition at line 341 of file streamWriter.I.
|
inline |
The copy constructor does not copy ownership of the stream.
Definition at line 57 of file streamWriter.I.
void StreamWriter::pad_bytes | ( | size_t | size | ) |
Adds the indicated number of zero bytes to the stream.
Definition at line 20 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 350 of file streamWriter.I.
|
inline |
Returns the stream in use.
Definition at line 39 of file streamWriter.h.