#include <datagram.h>
Inheritance diagram for Datagram:
Public Member Functions | |
Datagram () | |
Constructs an empty datagram. | |
Datagram (const void *data, size_t size) | |
Constructs a datagram from an existing block of data. | |
Datagram (const string &data) | |
Constructs a datagram from an existing block of data. | |
Datagram (const Datagram ©) | |
void | operator= (const Datagram ©) |
virtual | ~Datagram () |
virtual void | clear () |
Resets the datagram to empty, in preparation for building up a new datagram. | |
void | dump_hex (ostream &out) const |
Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values. | |
void | add_bool (bool value) |
Adds a boolean value to the datagram. | |
void | add_int8 (PN_int8 value) |
Adds a signed 8-bit integer to the datagram. | |
void | add_uint8 (PN_uint8 value) |
Adds an unsigned 8-bit integer to the datagram. | |
void | add_int16 (PN_int16 value) |
Adds a signed 16-bit integer to the datagram. | |
void | add_int32 (PN_int32 value) |
Adds a signed 32-bit integer to the datagram. | |
void | add_int64 (PN_int64 value) |
Adds a signed 64-bit integer to the datagram. | |
void | add_uint16 (PN_uint16 value) |
Adds an unsigned 16-bit integer to the datagram. | |
void | add_uint32 (PN_uint32 value) |
Adds an unsigned 32-bit integer to the datagram. | |
void | add_uint64 (PN_uint64 value) |
Adds an unsigned 64-bit integer to the datagram. | |
void | add_float32 (float value) |
Adds a 32-bit single-precision floating-point number to the datagram. | |
void | add_float64 (PN_float64 value) |
Adds a 64-bit floating-point number to the datagram. | |
void | add_be_int16 (PN_int16 value) |
Adds a signed 16-bit big-endian integer to the datagram. | |
void | add_be_int32 (PN_int32 value) |
Adds a signed 32-bit big-endian integer to the datagram. | |
void | add_be_int64 (PN_int64 value) |
Adds a signed 64-bit big-endian integer to the datagram. | |
void | add_be_uint16 (PN_uint16 value) |
Adds an unsigned 16-bit big-endian integer to the datagram. | |
void | add_be_uint32 (PN_uint32 value) |
Adds an unsigned 32-bit big-endian integer to the datagram. | |
void | add_be_uint64 (PN_uint64 value) |
Adds an unsigned 64-bit big-endian integer to the datagram. | |
void | add_be_float32 (float value) |
Adds a 32-bit single-precision big-endian floating-point number to the datagram. | |
void | add_be_float64 (PN_float64 value) |
Adds a 64-bit big-endian floating-point number to the datagram. | |
void | add_string (const string &str) |
Adds a variable-length string to the datagram. | |
void | add_z_string (string str) |
Adds a variable-length string to the datagram, as a NULL-terminated string. | |
void | add_fixed_string (const string &str, size_t size) |
Adds a fixed-length string to the datagram. | |
void | pad_bytes (size_t size) |
Adds the indicated number of zero bytes to the datagram. | |
void | append_data (const void *data, size_t size) |
Appends some more raw data to the end of the datagram. | |
void | append_data (const string &data) |
Appends some more raw data to the end of the datagram. | |
string | get_message () const |
Returns the datagram's data as a string. | |
const void * | get_data () const |
Returns a pointer to the beginning of the datagram's data. | |
size_t | get_length () const |
Returns the number of bytes in the datagram. | |
bool | operator== (const Datagram &other) const |
bool | operator!= (const Datagram &other) const |
bool | operator< (const Datagram &other) const |
virtual TypeHandle | get_type () const |
virtual TypeHandle | force_init_type () |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
Static Public Member Functions | |
TypeHandle | get_class_type () |
void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Private Attributes | |
PTA_uchar | _data |
Static Private Attributes | |
TypeHandle | _type_handle |
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.
Definition at line 66 of file datagram.h.
|
Constructs an empty datagram.
Definition at line 31 of file datagram.I. References append_data(), and INLINE. |
|
Constructs a datagram from an existing block of data.
Definition at line 43 of file datagram.I. References append_data(), and INLINE. |
|
Constructs a datagram from an existing block of data.
Definition at line 56 of file datagram.I. |
|
Definition at line 68 of file datagram.I. References add_uint8(), and INLINE. |
|
Definition at line 40 of file datagram.cxx. References _data, and PointerToArray< unsigned char >::clear(). |
|
Adds a 32-bit single-precision big-endian floating-point number to the datagram. Since this kind of float is not necessarily portable across different architectures, special care is required. Definition at line 357 of file datagram.I. References append_data(), and INLINE. |
|
Adds a 64-bit big-endian floating-point number to the datagram.
Definition at line 377 of file datagram.I. References _data, INLINE, and PointerToArray< unsigned char >::p(). |
|
Adds a signed 16-bit big-endian integer to the datagram.
Definition at line 257 of file datagram.I. References append_data(), ReversedNumericData::get_data(), and INLINE. |
|
Adds a signed 32-bit big-endian integer to the datagram.
Definition at line 273 of file datagram.I. References append_data(), ReversedNumericData::get_data(), INLINE, and nassertv. |
|
Adds a signed 64-bit big-endian integer to the datagram.
Definition at line 289 of file datagram.I. References append_data(), ReversedNumericData::get_data(), and INLINE. |
|
Adds an unsigned 16-bit big-endian integer to the datagram.
Definition at line 305 of file datagram.I. |
|
Adds an unsigned 32-bit big-endian integer to the datagram.
Definition at line 321 of file datagram.I. References add_uint8(), append_data(), and size_t. |
|
Adds an unsigned 64-bit big-endian integer to the datagram.
Definition at line 337 of file datagram.I. References append_data(), INLINE, and pad_bytes(). |
|
Adds a boolean value to the datagram.
Definition at line 94 of file datagram.I. References append_data(), and INLINE. Referenced by Camera::add_display_region(). |
|
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. Definition at line 442 of file datagram.I. |
|
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. Definition at line 223 of file datagram.I. References append_data(), ReversedNumericData::get_data(), and INLINE. Referenced by GeomLine::draw_immediate(), GeomLinestrip::explode(), FFTCompressor::get_transpose_quats(), Spotlight::CData::make_copy(), LODSwitch::operator==(), Material::output(), AnimBundle::output(), and PStatCollectorDef::set_parent(). |
|
Adds a 64-bit floating-point number to the datagram.
Definition at line 241 of file datagram.I. References append_data(), ReversedNumericData::get_data(), and INLINE. Referenced by ClassicNurbsCurve::convert_to_nurbs(). |
|
Adds a signed 16-bit integer to the datagram.
Definition at line 133 of file datagram.I. References append_data(), NativeNumericData::get_data(), and INLINE. Referenced by ComputedVerticesMorph< ValueType, MorphValueType >::ComputedVerticesMorph(), and PStatCollectorDef::set_parent(). |
|
Adds a signed 32-bit integer to the datagram.
Definition at line 147 of file datagram.I. References append_data(), NativeNumericData::get_data(), and INLINE. Referenced by Material::output(), and DownloadDb::Db::write(). |
|
Adds a signed 64-bit integer to the datagram.
Definition at line 161 of file datagram.I. |
|
Adds a signed 8-bit integer to the datagram.
Definition at line 107 of file datagram.I. Referenced by ColorAttrib::compare_to_impl(), and ClassicNurbsCurve::convert_to_nurbs(). |
|
Adds a variable-length string to the datagram. This actually adds a count followed by n bytes. Definition at line 393 of file datagram.I. References _data, INLINE, NULL, uchar, and PointerToArray< unsigned char >::v(). Referenced by AnimGroup::output(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), and PStatCollectorDef::set_parent(). |
|
|
Adds an unsigned 32-bit integer to the datagram.
Definition at line 189 of file datagram.I. References append_data(), and NativeNumericData::get_data(). Referenced by Camera::add_display_region(), ClassicNurbsCurve::convert_to_nurbs(), PandaNode::CData::make_copy(), DownloadDb::Db::write(), and DatagramOutputFile::write_header(). |
|
Adds an unsigned 64-bit integer to the datagram.
Definition at line 203 of file datagram.I. |
|
Adds an unsigned 8-bit integer to the datagram.
Definition at line 120 of file datagram.I. References append_data(), NativeNumericData::get_data(), and INLINE. Referenced by add_be_uint32(), Datagram(), GeomSprite::print_draw_immediate(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), Texture::register_with_read_factory(), and CollisionSolid::report_undefined_intersection_test(). |
|
Adds a variable-length string to the datagram, as a NULL-terminated string.
Definition at line 415 of file datagram.I. References operator==(). |
|
Appends some more raw data to the end of the datagram.
Definition at line 463 of file datagram.I. |
|
Appends some more raw data to the end of the datagram.
Definition at line 150 of file datagram.cxx. References _data, size_t, uchar, and PointerToArray< unsigned char >::v(). Referenced by add_be_float32(), add_be_int16(), add_be_int32(), add_be_int64(), add_be_uint32(), add_be_uint64(), add_bool(), add_float32(), add_float64(), add_int16(), add_int32(), add_uint32(), add_uint8(), Datagram(), DownloadDb::Db::Db(), DownloadDb::Db::get_multifile_name(), DownloadDb::insert_new_version(), operator=(), and DownloadDb::Db::parse_header(). |
|
Resets the datagram to empty, in preparation for building up a new datagram.
Reimplemented in NetDatagram. Definition at line 54 of file datagram.cxx. References get_data(), get_length(), and size_t. Referenced by DownloadDb::Db::Db(), DownloadDb::Db::get_multifile_name(), DownloadDb::insert_new_version(), DownloadDb::Db::parse_header(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), and DownloadDb::Db::write(). |
|
Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.
Definition at line 69 of file datagram.cxx. |
|
Implements TypedObject. Reimplemented in NetDatagram. Definition at line 135 of file datagram.h. |
|
Reimplemented from TypedObject. Reimplemented in NetDatagram. Definition at line 124 of file datagram.h. |
|
Returns a pointer to the beginning of the datagram's data.
Definition at line 491 of file datagram.I. Referenced by clear(), DatagramIterator::get_be_int16(), DatagramIterator::get_be_uint64(), DatagramIterator::get_fixed_string(), DatagramIterator::get_float64(), DatagramIterator::get_int64(), DatagramIterator::get_uint16(), DatagramIterator::get_uint32(), DatagramIterator::get_uint64(), and DatagramOutputFile::write_header(). |
|
Returns the number of bytes in the datagram.
Definition at line 504 of file datagram.I. Referenced by clear(), DatagramIterator::get_be_uint64(), ConnectionWriter::send(), and DatagramOutputFile::write_header(). |
|
Returns the datagram's data as a string.
Definition at line 476 of file datagram.I. Referenced by ClientState::ClientState(), DatagramUDPHeader::get_datagram_checksum(), DatagramTCPHeader::get_datagram_size(), HTTPClient::read(), Connection::set_ip_type_of_service(), Connection::set_keep_alive(), and DownloadDb::Db::write(). |
|
Implements TypedObject. Reimplemented in NetDatagram. Definition at line 132 of file datagram.h. |
|
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(). Definition at line 71 of file typedObject.I. References TypeHandle::get_name(), TypedObject::get_type(), and INLINE. |
|
This function is declared non-inline to work around a compiler bug in g++ 2.96. Making it inline seems to cause problems in the optimizer. Reimplemented from TypedObject. Reimplemented in NetDatagram. Definition at line 127 of file datagram.h. Referenced by ConfigureFn(). |
|
Returns true if the current object is the indicated type exactly.
Definition at line 101 of file typedObject.I. Referenced by PT(), and CollisionNode::xform(). |
|
|
Definition at line 534 of file datagram.I. |
|
Definition at line 546 of file datagram.I. |
|
Reimplemented in NetDatagram. Definition at line 81 of file datagram.I. References append_data(), and INLINE. Referenced by NetDatagram::NetDatagram(). |
|
Definition at line 516 of file datagram.I. Referenced by add_z_string(). |
|
Adds the indicated number of zero bytes to the datagram.
Definition at line 112 of file datagram.cxx. References _data, and PointerToArray< unsigned char >::push_back(). Referenced by add_be_uint64(). |
|
Definition at line 120 of file datagram.h. Referenced by add_be_float64(), add_string(), append_data(), pad_bytes(), and ~Datagram(). |
|
Reimplemented from TypedObject. Reimplemented in NetDatagram. Definition at line 30 of file datagram.cxx. |