18 StreamWriter(std::ostream &out) :
31 StreamWriter(std::ostream *out,
bool owns_stream) :
36 _owns_stream(owns_stream)
78 INLINE std::ostream *StreamWriter::
171 nassertv(
sizeof(value) == 4);
249 nassertv(
sizeof(value) == 4);
270 nassertv(str.length() <= (uint16_t)0xffff);
297 size_t null_pos = str.find(
'\0');
312 if (str.length() < size) {
326 _out->write((
const char *)data, size);
A StreamWriter object is used to write sequential binary data directly to an ostream.
void add_float32(float value)
Adds a 32-bit single-precision floating-point number to the stream.
void add_be_int64(int64_t value)
Adds a signed 64-bit big-endian integer to the streamWriter.
void append_data(const void *data, size_t size)
Appends some more raw data to the end of the streamWriter.
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the streamWriter.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the stream.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the stream.
void add_string(const std::string &str)
Adds a variable-length string to the stream.
void add_be_uint16(uint16_t value)
Adds an unsigned 16-bit big-endian integer to the streamWriter.
void add_be_uint64(uint64_t value)
Adds an unsigned 64-bit big-endian integer to the streamWriter.
void operator=(const StreamWriter ©)
The copy constructor does not copy ownership of the stream.
void add_be_uint32(uint32_t value)
Adds an unsigned 32-bit big-endian integer to the streamWriter.
void add_int16(int16_t value)
Adds a signed 16-bit integer to the stream.
void add_be_float32(float value)
Adds a 32-bit single-precision big-endian floating-point number to the stream.
void flush()
Calls flush() on the underlying stream.
void add_bool(bool value)
Adds a boolean value to the stream.
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed,...
void write(const std::string &str)
A synonym of append_data().
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the stream.
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
void add_int8(int8_t value)
Adds a signed 8-bit integer to the stream.
void add_fixed_string(const std::string &str, size_t size)
Adds a fixed-length string to the stream.
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
void add_z_string(std::string str)
Adds a variable-length string to the stream, as a NULL-terminated string.
void add_be_int16(int16_t value)
Adds a signed 16-bit big-endian integer to the streamWriter.
void add_uint64(uint64_t value)
Adds an unsigned 64-bit integer to the stream.
void add_string32(const std::string &str)
Adds a variable-length string to the stream, using a 32-bit length field.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the stream.
void add_float64(PN_float64 value)
Adds a 64-bit floating-point number to the stream.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the stream.
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed,...
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the streamWriter.
void add_int64(int64_t value)
Adds a signed 64-bit integer to the stream.