Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

StreamWriter Class Reference

A StreamWriter object is used to write sequential binary data directly to an ostream. More...

#include <streamWriter.h>

List of all members.

Public Member Functions

 StreamWriter (ostream &out)
 StreamWriter (ostream *out)
 StreamWriter (const StreamWriter &copy)
void operator= (const StreamWriter &copy)
 ~StreamWriter ()
ostream * get_ostream () const
 Returns the stream in use.

void add_bool (bool value)
 Adds a boolean value to the stream.

void add_int8 (PN_int8 value)
 Adds a signed 8-bit integer to the stream.

void add_uint8 (PN_uint8 value)
 Adds an unsigned 8-bit integer to the stream.

void add_int16 (PN_int16 value)
 Adds a signed 16-bit integer to the stream.

void add_int32 (PN_int32 value)
 Adds a signed 32-bit integer to the stream.

void add_int64 (PN_int64 value)
 Adds a signed 64-bit integer to the stream.

void add_uint16 (PN_uint16 value)
 Adds an unsigned 16-bit integer to the stream.

void add_uint32 (PN_uint32 value)
 Adds an unsigned 32-bit integer to the stream.

void add_uint64 (PN_uint64 value)
 Adds an unsigned 64-bit integer to the stream.

void add_float32 (float value)
 Adds a 32-bit single-precision floating-point number to the stream.

void add_float64 (PN_float64 value)
 Adds a 64-bit floating-point number to the stream.

void add_be_int16 (PN_int16 value)
 Adds a signed 16-bit big-endian integer to the streamWriter.

void add_be_int32 (PN_int32 value)
 Adds a signed 32-bit big-endian integer to the streamWriter.

void add_be_int64 (PN_int64 value)
 Adds a signed 64-bit big-endian integer to the streamWriter.

void add_be_uint16 (PN_uint16 value)
 Adds an unsigned 16-bit big-endian integer to the streamWriter.

void add_be_uint32 (PN_uint32 value)
 Adds an unsigned 32-bit big-endian integer to the streamWriter.

void add_be_uint64 (PN_uint64 value)
 Adds an unsigned 64-bit big-endian integer to the streamWriter.

void add_be_float32 (float value)
 Adds a 32-bit single-precision big-endian floating-point number to the stream.

void add_be_float64 (PN_float64 value)
 Adds a 64-bit big-endian floating-point number to the streamWriter.

void add_string (const string &str)
 Adds a variable-length string to the stream.

void add_z_string (string str)
 Adds a variable-length string to the stream, as a NULL-terminated string.

void add_fixed_string (const string &str, size_t size)
 Adds a fixed-length string to the stream.

void pad_bytes (size_t size)
 Adds the indicated number of zero bytes to the stream.

void append_data (const void *data, size_t size)
 Appends some more raw data to the end of the streamWriter.

void append_data (const string &data)
 Appends some more raw data to the end of the streamWriter.


Private Attributes

ostream * _out


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.

Definition at line 48 of file streamWriter.h.


Constructor & Destructor Documentation

StreamWriter::StreamWriter ostream &  out  )  [inline]
 

Definition at line 32 of file streamWriter.I.

References INLINE.

StreamWriter::StreamWriter ostream *  out  )  [inline]
 

Definition at line 46 of file streamWriter.I.

References INLINE.

StreamWriter::StreamWriter const StreamWriter &  copy  )  [inline]
 

Definition at line 59 of file streamWriter.I.

References _out.

StreamWriter::~StreamWriter  )  [inline]
 

Definition at line 84 of file streamWriter.I.

References add_uint8(), and INLINE.


Member Function Documentation

void StreamWriter::add_be_float32 float  value  )  [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 372 of file streamWriter.I.

References _out.

void StreamWriter::add_be_float64 PN_float64  value  )  [inline]
 

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

Definition at line 392 of file streamWriter.I.

void StreamWriter::add_be_int16 PN_int16  value  )  [inline]
 

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

Definition at line 272 of file streamWriter.I.

References append_data(), ReversedNumericData::get_data(), and INLINE.

void StreamWriter::add_be_int32 PN_int32  value  )  [inline]
 

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

Definition at line 288 of file streamWriter.I.

References append_data(), ReversedNumericData::get_data(), and nassertv.

void StreamWriter::add_be_int64 PN_int64  value  )  [inline]
 

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

Definition at line 304 of file streamWriter.I.

References append_data(), and ReversedNumericData::get_data().

void StreamWriter::add_be_uint16 PN_uint16  value  )  [inline]
 

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

Definition at line 320 of file streamWriter.I.

void StreamWriter::add_be_uint32 PN_uint32  value  )  [inline]
 

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

Definition at line 336 of file streamWriter.I.

References size_t.

void StreamWriter::add_be_uint64 PN_uint64  value  )  [inline]
 

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

Definition at line 352 of file streamWriter.I.

References append_data(), INLINE, and pad_bytes().

void StreamWriter::add_bool bool  value  )  [inline]
 

Adds a boolean value to the stream.

Definition at line 109 of file streamWriter.I.

void StreamWriter::add_fixed_string const string &  str,
size_t  size
[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 457 of file streamWriter.I.

void StreamWriter::add_float32 float  value  )  [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 238 of file streamWriter.I.

References append_data(), and ReversedNumericData::get_data().

void StreamWriter::add_float64 PN_float64  value  )  [inline]
 

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

Definition at line 256 of file streamWriter.I.

References append_data(), ReversedNumericData::get_data(), and INLINE.

void StreamWriter::add_int16 PN_int16  value  )  [inline]
 

Adds a signed 16-bit integer to the stream.

Definition at line 148 of file streamWriter.I.

References append_data(), NativeNumericData::get_data(), and INLINE.

void StreamWriter::add_int32 PN_int32  value  )  [inline]
 

Adds a signed 32-bit integer to the stream.

Definition at line 162 of file streamWriter.I.

References append_data(), and NativeNumericData::get_data().

void StreamWriter::add_int64 PN_int64  value  )  [inline]
 

Adds a signed 64-bit integer to the stream.

Definition at line 176 of file streamWriter.I.

void StreamWriter::add_int8 PN_int8  value  )  [inline]
 

Adds a signed 8-bit integer to the stream.

Definition at line 122 of file streamWriter.I.

References append_data(), NativeNumericData::get_data(), and INLINE.

void StreamWriter::add_string const string &  str  )  [inline]
 

Adds a variable-length string to the stream.

This actually adds a count followed by n bytes.

Definition at line 408 of file streamWriter.I.

void StreamWriter::add_uint16 PN_uint16  value  )  [inline]
 

Adds an unsigned 16-bit integer to the stream.

Definition at line 190 of file streamWriter.I.

void StreamWriter::add_uint32 PN_uint32  value  )  [inline]
 

Adds an unsigned 32-bit integer to the stream.

Definition at line 204 of file streamWriter.I.

void StreamWriter::add_uint64 PN_uint64  value  )  [inline]
 

Adds an unsigned 64-bit integer to the stream.

Definition at line 218 of file streamWriter.I.

References append_data(), ReversedNumericData::get_data(), and INLINE.

void StreamWriter::add_uint8 PN_uint8  value  )  [inline]
 

Adds an unsigned 8-bit integer to the stream.

Definition at line 135 of file streamWriter.I.

References append_data(), NativeNumericData::get_data(), and INLINE.

Referenced by ~StreamWriter().

void StreamWriter::add_z_string string  str  )  [inline]
 

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

Definition at line 430 of file streamWriter.I.

void StreamWriter::append_data const string &  data  )  [inline]
 

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

Definition at line 493 of file streamWriter.I.

void StreamWriter::append_data const void *  data,
size_t  size
[inline]
 

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

Definition at line 478 of file streamWriter.I.

Referenced by add_be_int16(), add_be_int32(), add_be_int64(), add_be_uint64(), add_float32(), add_float64(), add_int16(), add_int32(), add_int8(), add_uint64(), add_uint8(), and get_ostream().

ostream * StreamWriter::get_ostream  )  const [inline]
 

Returns the stream in use.

Definition at line 96 of file streamWriter.I.

References append_data(), and INLINE.

void StreamWriter::operator= const StreamWriter &  copy  )  [inline]
 

Definition at line 72 of file streamWriter.I.

References _out, and INLINE.

void StreamWriter::pad_bytes size_t  size  ) 
 

Adds the indicated number of zero bytes to the stream.

Definition at line 35 of file streamWriter.cxx.

Referenced by add_be_uint64().


Member Data Documentation

ostream* StreamWriter::_out [private]
 

Definition at line 92 of file streamWriter.h.

Referenced by add_be_float32(), operator=(), and StreamWriter().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:55:20 2003 for Panda by doxygen1.3