A specific kind of Datagram, especially for sending across or receiving from a network. More...
#include "netDatagram.h"
Public Member Functions | |
| NetDatagram () | |
| Constructs an empty datagram. More... | |
| NetDatagram (const void *data, size_t size) | |
| Constructs a datagram from an existing block of data. More... | |
| NetDatagram (const Datagram ©) | |
| NetDatagram (const NetDatagram ©) | |
| virtual void | clear () |
| Resets the datagram to empty, in preparation for building up a new datagram. More... | |
| virtual TypeHandle | force_init_type () |
| const NetAddress & | get_address () const |
| Retrieves the host from which the datagram was read, or to which it is scheduled to be sent. More... | |
| virtual TypeHandle | get_type () const |
| bool | operator != (const NetDatagram &other) const |
| bool | operator< (const NetDatagram &other) const |
| void | operator= (const Datagram ©) |
| void | operator= (const NetDatagram ©) |
| bool | operator== (const NetDatagram &other) const |
| PT (Connection) get_connection() const | |
| void | set_address (const NetAddress &address) |
| void | set_connection (const PT(Connection) &connection) |
| Specifies the socket to which the datagram should be written. More... | |
Public Member Functions inherited from Datagram | |
| Datagram (const void *data, size_t size) | |
| Constructs a datagram from an existing block of data. More... | |
| Datagram (vector_uchar data) | |
| Constructs a datagram from an existing block of data. More... | |
| Datagram (const Datagram ©)=default | |
| Datagram (Datagram &&from) noexcept=default | |
| void | add_be_float32 (PN_float32 value) |
| Adds a 32-bit single-precision big-endian floating-point number to the datagram. More... | |
| void | add_be_float64 (PN_float64 value) |
| Adds a 64-bit big-endian floating-point number to the datagram. More... | |
| void | add_be_int16 (int16_t value) |
| Adds a signed 16-bit big-endian integer to the datagram. More... | |
| void | add_be_int32 (int32_t value) |
| Adds a signed 32-bit big-endian integer to the datagram. More... | |
| void | add_be_int64 (int64_t value) |
| Adds a signed 64-bit big-endian integer to the datagram. More... | |
| void | add_be_uint16 (uint16_t value) |
| Adds an unsigned 16-bit big-endian integer to the datagram. More... | |
| void | add_be_uint32 (uint32_t value) |
| Adds an unsigned 32-bit big-endian integer to the datagram. More... | |
| void | add_be_uint64 (uint64_t value) |
| Adds an unsigned 64-bit big-endian integer to the datagram. More... | |
| void | add_blob (const vector_uchar &) |
| Adds a variable-length binary blob to the datagram. More... | |
| void | add_blob32 (const vector_uchar &) |
| Adds a variable-length binary blob to the datagram, using a 32-bit length field to allow very long blobs. More... | |
| void | add_bool (bool value) |
| Adds a boolean value to the datagram. More... | |
| void | add_fixed_string (const std::string &str, size_t size) |
| Adds a fixed-length string to the datagram. More... | |
| void | add_float32 (PN_float32 value) |
| Adds a 32-bit single-precision floating-point number to the datagram. More... | |
| void | add_float64 (PN_float64 value) |
| Adds a 64-bit floating-point number to the datagram. More... | |
| void | add_int16 (int16_t value) |
| Adds a signed 16-bit integer to the datagram. More... | |
| void | add_int32 (int32_t value) |
| Adds a signed 32-bit integer to the datagram. More... | |
| void | add_int64 (int64_t value) |
| Adds a signed 64-bit integer to the datagram. More... | |
| void | add_int8 (int8_t value) |
| Adds a signed 8-bit integer to the datagram. More... | |
| void | add_stdfloat (PN_stdfloat value) |
| Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double(). More... | |
| void | add_string (const std::string &str) |
| Adds a variable-length string to the datagram. More... | |
| void | add_string32 (const std::string &str) |
| Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings. More... | |
| void | add_uint16 (uint16_t value) |
| Adds an unsigned 16-bit integer to the datagram. More... | |
| void | add_uint32 (uint32_t value) |
| Adds an unsigned 32-bit integer to the datagram. More... | |
| void | add_uint64 (uint64_t value) |
| Adds an unsigned 64-bit integer to the datagram. More... | |
| void | add_uint8 (uint8_t value) |
| Adds an unsigned 8-bit integer to the datagram. More... | |
| void | add_wstring (const std::wstring &str) |
| Adds a variable-length wstring to the datagram. More... | |
| void | add_z_string (const std::string &str) |
| Adds a variable-length string to the datagram, 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 datagram. More... | |
| void | append_data (const vector_uchar &data) |
| Appends some more raw data to the end of the datagram. More... | |
| void | assign (const void *data, size_t size) |
| Replaces the datagram's data with the indicated block. More... | |
| void | copy_array (CPTA_uchar data) |
| Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar. More... | |
| void | dump_hex (std::ostream &out, unsigned int indent=0) const |
| Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values. More... | |
| CPTA_uchar | get_array () const |
| Returns a const pointer to the actual data in the Datagram. More... | |
| const void * | get_data () const |
| Returns a pointer to the beginning of the datagram's data. More... | |
| size_t | get_length () const |
| Returns the number of bytes in the datagram. More... | |
| std::string | get_message () const |
| Returns the datagram's data as a string. More... | |
| bool | get_stdfloat_double () const |
| Returns the stdfloat_double flag. More... | |
| PTA_uchar | modify_array () |
| Returns a modifiable pointer to the actual data in the Datagram. More... | |
| bool | operator != (const Datagram &other) const |
| bool | operator< (const Datagram &other) const |
| Datagram & | operator= (const Datagram ©)=default |
| Datagram & | operator= (Datagram &&from) noexcept=default |
| bool | operator== (const Datagram &other) const |
| void | output (std::ostream &out) const |
| Write a string representation of this instance to <out>. More... | |
| void | pad_bytes (size_t size) |
| Adds the indicated number of zero bytes to the datagram. More... | |
| void | set_array (PTA_uchar data) |
| Replaces the data in the Datagram with the data in the indicated PTA_uchar. More... | |
| void | set_stdfloat_double (bool stdfloat_double) |
| Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and DatagramIterator::get_stdfloat(). More... | |
| void | write (std::ostream &out, unsigned int indent=0) const |
| Write a string representation of this instance to <out>. More... | |
Public Member Functions inherited from TypedObject | |
| TypedObject (const TypedObject ©)=default | |
| TypedObject * | as_typed_object () |
| Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
| const TypedObject * | as_typed_object () const |
| Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
| int | get_best_parent_from_Set (const std::set< int > &) const |
| int | get_type_index () const |
| Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
| bool | is_exact_type (TypeHandle handle) const |
| Returns true if the current object is the indicated type exactly. More... | |
| bool | is_of_type (TypeHandle handle) const |
| Returns true if the current object is or derives from the indicated type. More... | |
| TypedObject & | operator= (const TypedObject ©)=default |
Static Public Member Functions | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from Datagram | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
| This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Additional Inherited Members | |
Public Attributes inherited from TypedObject | |
| get_type | |
A specific kind of Datagram, especially for sending across or receiving from a network.
It's different only in that it knows which Connection and/or NetAddress it is to be sent to or was received from.
Definition at line 40 of file netDatagram.h.
| NetDatagram::NetDatagram | ( | ) |
Constructs an empty datagram.
Definition at line 22 of file netDatagram.cxx.
| NetDatagram::NetDatagram | ( | const void * | data, |
| size_t | size | ||
| ) |
Constructs a datagram from an existing block of data.
Definition at line 29 of file netDatagram.cxx.
|
virtual |
Resets the datagram to empty, in preparation for building up a new datagram.
Reimplemented from Datagram.
Definition at line 78 of file netDatagram.cxx.
References NetAddress::clear(), and Datagram::clear().
Referenced by DatagramQueue::extract().
| const NetAddress & NetDatagram::get_address | ( | ) | const |
Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.
Definition at line 114 of file netDatagram.cxx.
Referenced by DirectD::wait_for_servers().
| void NetDatagram::set_connection | ( | const PT(Connection) & | connection | ) |
Specifies the socket to which the datagram should be written.
Definition at line 88 of file netDatagram.cxx.
1.8.15