An ordered list of data elements, formatted in memory for transmission over a socket or writing to a data file. More...

Inheritance diagram for Datagram:
TypedObject MemoryBase PyDatagram NetDatagram

Public Member Functions

 __init__ ()
 Constructs an empty datagram. More...
 
 __init__ (const Datagram copy)
 
 __init__ (str data)
 Constructs a datagram from an existing block of data. More...
 
 addBeFloat32 (PNFloat32 value)
 Adds a 32-bit single-precision big-endian floating-point number to the datagram. More...
 
 addBeFloat64 (PNFloat64 value)
 Adds a 64-bit big-endian floating-point number to the datagram. More...
 
 addBeInt16 (PNInt16 value)
 Adds a signed 16-bit big-endian integer to the datagram. More...
 
 addBeInt32 (PNInt32 value)
 Adds a signed 32-bit big-endian integer to the datagram. More...
 
 addBeInt64 (PNInt64 value)
 Adds a signed 64-bit big-endian integer to the datagram. More...
 
 addBeUint16 (PNUint16 value)
 Adds an unsigned 16-bit big-endian integer to the datagram. More...
 
 addBeUint32 (PNUint32 value)
 Adds an unsigned 32-bit big-endian integer to the datagram. More...
 
 addBeUint64 (PNUint64 value)
 Adds an unsigned 64-bit big-endian integer to the datagram. More...
 
 addBool (bool value)
 Adds a boolean value to the datagram. More...
 
 addFixedString (str str, size_t size)
 Adds a fixed-length string to the datagram. 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. More...
 
 addFloat32 (PNFloat32 value)
 Adds a 32-bit single-precision floating-point number to the datagram. Since this kind of float is not necessarily portable across different architectures, special care is required. More...
 
 addFloat64 (PNFloat64 value)
 Adds a 64-bit floating-point number to the datagram. More...
 
 addInt16 (PNInt16 value)
 Adds a signed 16-bit integer to the datagram. More...
 
 addInt32 (PNInt32 value)
 Adds a signed 32-bit integer to the datagram. More...
 
 addInt64 (PNInt64 value)
 Adds a signed 64-bit integer to the datagram. More...
 
 addInt8 (PNInt8 value)
 Adds a signed 8-bit integer to the datagram. More...
 
 addStdfloat (float value)
 Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double(). More...
 
 addString (str str)
 Adds a variable-length string to the datagram. This actually adds a count followed by n bytes. More...
 
 addString32 (str str)
 Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings. More...
 
 addUint16 (PNUint16 value)
 Adds an unsigned 16-bit integer to the datagram. More...
 
 addUint32 (PNUint32 value)
 Adds an unsigned 32-bit integer to the datagram. More...
 
 addUint64 (PNUint64 value)
 Adds an unsigned 64-bit integer to the datagram. More...
 
 addUint8 (PNUint8 value)
 Adds an unsigned 8-bit integer to the datagram. More...
 
 addWstring (str str)
 Adds a variable-length wstring to the datagram. More...
 
 addZString (str str)
 Adds a variable-length string to the datagram, as a NULL-terminated string. More...
 
 appendData (str data)
 Appends some more raw data to the end of the datagram. More...
 
 clear ()
 Resets the datagram to empty, in preparation for building up a new datagram. More...
 
 copyArray (CPTAUchar data)
 Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar. Unlike set_array(), a complete copy is made of the data; subsequent changes to the Datagram will not change the source CPTA_uchar. More...
 
 dumpHex (Ostream out, unsigned int indent)
 Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values. More...
 
CPTAUchar getArray ()
 Returns a const pointer to the actual data in the Datagram. More...
 
 getData ()
 Returns a pointer to the beginning of the datagram's data. More...
 
size_t getLength ()
 Returns the number of bytes in the datagram. More...
 
str getMessage ()
 Returns the datagram's data as a string. More...
 
bool getStdfloatDouble ()
 Returns the stdfloat_double flag. See set_stdfloat_double(). More...
 
PTAUchar modifyArray ()
 Returns a modifiable pointer to the actual data in the Datagram. More...
 
bool operator!= (const Datagram other)
 
bool operator< (const Datagram other)
 
Datagram operator= (const Datagram copy)
 
bool operator== (const Datagram other)
 
 output (Ostream out)
 Write a string representation of this instance to <out>. More...
 
 padBytes (size_t size)
 Adds the indicated number of zero bytes to the datagram. More...
 
 setArray (PTAUchar data)
 Replaces the data in the Datagram with the data in the indicated PTA_uchar. This is assignment by reference: subsequent changes to the Datagram will also change the source PTA_uchar. More...
 
 setStdfloatDouble (bool stdfloat_double)
 Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and DatagramIterator::get_stdfloat(). When this is true, add_stdfloat() adds a 64-bit floating-point number; when it is false, it adds a 32-bit floating-point number. The default is based on the STDFLOAT_DOUBLE compilation flag. More...
 
 write (Ostream out, unsigned int indent)
 Write a string representation of this instance to <out>. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 Derived classes should override this function to return get_class_type(). More...
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 

Detailed Description

An ordered list of data elements, formatted in memory for transmission over a socket or writing to a data file.

Data elements should be added one at a time, in order, to the Datagram. The nature and contents of the data elements are totally up to the user. When a Datagram has been transmitted and received, its data elements may be extracted using a DatagramIterator; it is up to the caller to know the correct type of each data element in order.

A Datagram is itself headerless; it is simply a collection of data elements.

Member Function Documentation

__init__ ( )

Constructs an empty datagram.

__init__ ( const Datagram  copy)
__init__ ( str  data)

Constructs a datagram from an existing block of data.

addBeFloat32 ( PNFloat32  value)

Adds a 32-bit single-precision big-endian floating-point number to the datagram.

addBeFloat64 ( PNFloat64  value)

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

addBeInt16 ( PNInt16  value)

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

addBeInt32 ( PNInt32  value)

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

addBeInt64 ( PNInt64  value)

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

addBeUint16 ( PNUint16  value)

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

addBeUint32 ( PNUint32  value)

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

addBeUint64 ( PNUint64  value)

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

addBool ( bool  value)

Adds a boolean value to the datagram.

addFixedString ( str  str,
size_t  size 
)

Adds a fixed-length string to the datagram. 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 ( PNFloat32  value)

Adds a 32-bit single-precision floating-point number to the datagram. Since this kind of float is not necessarily portable across different architectures, special care is required.

addFloat64 ( PNFloat64  value)

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

addInt16 ( PNInt16  value)

Adds a signed 16-bit integer to the datagram.

addInt32 ( PNInt32  value)

Adds a signed 32-bit integer to the datagram.

addInt64 ( PNInt64  value)

Adds a signed 64-bit integer to the datagram.

addInt8 ( PNInt8  value)

Adds a signed 8-bit integer to the datagram.

addStdfloat ( float  value)

Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().

addString ( str  str)

Adds a variable-length string to the datagram. This actually adds a count followed by n bytes.

addString32 ( str  str)

Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings.

addUint16 ( PNUint16  value)

Adds an unsigned 16-bit integer to the datagram.

addUint32 ( PNUint32  value)

Adds an unsigned 32-bit integer to the datagram.

addUint64 ( PNUint64  value)

Adds an unsigned 64-bit integer to the datagram.

addUint8 ( PNUint8  value)

Adds an unsigned 8-bit integer to the datagram.

addWstring ( str  str)

Adds a variable-length wstring to the datagram.

addZString ( str  str)

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

appendData ( str  data)

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

clear ( )

Resets the datagram to empty, in preparation for building up a new datagram.

copyArray ( CPTAUchar  data)

Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar. Unlike set_array(), a complete copy is made of the data; subsequent changes to the Datagram will not change the source CPTA_uchar.

dumpHex ( Ostream  out,
unsigned int  indent 
)

Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.

CPTAUchar getArray ( )

Returns a const pointer to the actual data in the Datagram.

static TypeHandle getClassType ( )
static
getData ( )

Returns a pointer to the beginning of the datagram's data.

size_t getLength ( )

Returns the number of bytes in the datagram.

str getMessage ( )

Returns the datagram's data as a string.

bool getStdfloatDouble ( )

Returns the stdfloat_double flag. See set_stdfloat_double().

PTAUchar modifyArray ( )

Returns a modifiable pointer to the actual data in the Datagram.

bool operator!= ( const Datagram  other)
bool operator< ( const Datagram  other)
Datagram operator= ( const Datagram  copy)
bool operator== ( const Datagram  other)
output ( Ostream  out)

Write a string representation of this instance to <out>.

padBytes ( size_t  size)

Adds the indicated number of zero bytes to the datagram.

setArray ( PTAUchar  data)

Replaces the data in the Datagram with the data in the indicated PTA_uchar. This is assignment by reference: subsequent changes to the Datagram will also change the source PTA_uchar.

setStdfloatDouble ( bool  stdfloat_double)

Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and DatagramIterator::get_stdfloat(). When this is true, add_stdfloat() adds a 64-bit floating-point number; when it is false, it adds a 32-bit floating-point number. The default is based on the STDFLOAT_DOUBLE compilation flag.

write ( Ostream  out,
unsigned int  indent 
)

Write a string representation of this instance to <out>.