Datagram

from panda3d.core import Datagram
class Datagram

Bases: TypedObject

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.

Inheritance diagram

Inheritance diagram of Datagram

Bytes()

C++ Interface: __bytes__(Datagram self)

__init__(*args, **kwargs)
addBeFloat32()

C++ Interface: add_be_float32(const Datagram self, float value)

/**
  • Adds a 32-bit single-precision big-endian floating-point number to the

  • datagram.

*/

addBeFloat64()

C++ Interface: add_be_float64(const Datagram self, double value)

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

*/

addBeInt16()

C++ Interface: add_be_int16(const Datagram self, int value)

// These functions pack numbers big-endian, in case that’s desired.

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

*/

addBeInt32()

C++ Interface: add_be_int32(const Datagram self, int value)

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

*/

addBeInt64()

C++ Interface: add_be_int64(const Datagram self, long value)

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

*/

addBeUint16()

C++ Interface: add_be_uint16(const Datagram self, int value)

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

*/

addBeUint32()

C++ Interface: add_be_uint32(const Datagram self, int value)

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

*/

addBeUint64()

C++ Interface: add_be_uint64(const Datagram self, long value)

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

*/

addBlob()

C++ Interface: add_blob(const Datagram self, bytes param0)

/**
  • Adds a variable-length binary blob to the datagram. This actually adds a

  • count followed by n bytes.

*/

addBlob32()

C++ Interface: add_blob32(const Datagram self, bytes param0)

/**
  • Adds a variable-length binary blob to the datagram, using a 32-bit length

  • field to allow very long blobs.

*/

addBool()

C++ Interface: add_bool(const Datagram self, bool value)

/**
  • Adds a boolean value to the datagram.

*/

addFixedString()

C++ Interface: add_fixed_string(const Datagram self, str str, int 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()

C++ Interface: add_float32(const Datagram self, float 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()

C++ Interface: add_float64(const Datagram self, double value)

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

*/

addInt16()

C++ Interface: add_int16(const Datagram self, int value)

// The default numeric packing is little-endian.

/**
  • Adds a signed 16-bit integer to the datagram.

*/

addInt32()

C++ Interface: add_int32(const Datagram self, int value)

/**
  • Adds a signed 32-bit integer to the datagram.

*/

addInt64()

C++ Interface: add_int64(const Datagram self, long value)

/**
  • Adds a signed 64-bit integer to the datagram.

*/

addInt8()

C++ Interface: add_int8(const Datagram self, int value)

/**
  • Adds a signed 8-bit integer to the datagram.

*/

addStdfloat()

C++ Interface: add_stdfloat(const Datagram self, float value)

/**
  • Adds either a 32-bit or a 64-bit floating-point number, according to

  • set_stdfloat_double().

*/

addString()

C++ Interface: add_string(const Datagram self, str str)

/**
  • Adds a variable-length string to the datagram. This actually adds a count

  • followed by n bytes.

*/

addString32()

C++ Interface: add_string32(const Datagram self, str str)

/**
  • Adds a variable-length string to the datagram, using a 32-bit length field

  • to allow very long strings.

*/

addUint16()

C++ Interface: add_uint16(const Datagram self, int value)

/**
  • Adds an unsigned 16-bit integer to the datagram.

*/

addUint32()

C++ Interface: add_uint32(const Datagram self, int value)

/**
  • Adds an unsigned 32-bit integer to the datagram.

*/

addUint64()

C++ Interface: add_uint64(const Datagram self, long value)

/**
  • Adds an unsigned 64-bit integer to the datagram.

*/

addUint8()

C++ Interface: add_uint8(const Datagram self, int value)

/**
  • Adds an unsigned 8-bit integer to the datagram.

*/

addWstring()

C++ Interface: add_wstring(const Datagram self, unicode str)

/**
  • Adds a variable-length wstring to the datagram.

*/

addZString()

C++ Interface: add_z_string(const Datagram self, str str)

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

*/

add_be_float32()

C++ Interface: add_be_float32(const Datagram self, float value)

/**
  • Adds a 32-bit single-precision big-endian floating-point number to the

  • datagram.

*/

add_be_float64()

C++ Interface: add_be_float64(const Datagram self, double value)

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

*/

add_be_int16()

C++ Interface: add_be_int16(const Datagram self, int value)

// These functions pack numbers big-endian, in case that’s desired.

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

*/

add_be_int32()

C++ Interface: add_be_int32(const Datagram self, int value)

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

*/

add_be_int64()

C++ Interface: add_be_int64(const Datagram self, long value)

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

*/

add_be_uint16()

C++ Interface: add_be_uint16(const Datagram self, int value)

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

*/

add_be_uint32()

C++ Interface: add_be_uint32(const Datagram self, int value)

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

*/

add_be_uint64()

C++ Interface: add_be_uint64(const Datagram self, long value)

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

*/

add_blob()

C++ Interface: add_blob(const Datagram self, bytes param0)

/**
  • Adds a variable-length binary blob to the datagram. This actually adds a

  • count followed by n bytes.

*/

add_blob32()

C++ Interface: add_blob32(const Datagram self, bytes param0)

/**
  • Adds a variable-length binary blob to the datagram, using a 32-bit length

  • field to allow very long blobs.

*/

add_bool()

C++ Interface: add_bool(const Datagram self, bool value)

/**
  • Adds a boolean value to the datagram.

*/

add_fixed_string()

C++ Interface: add_fixed_string(const Datagram self, str str, int 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.

*/

add_float32()

C++ Interface: add_float32(const Datagram self, float 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.

*/

add_float64()

C++ Interface: add_float64(const Datagram self, double value)

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

*/

add_int16()

C++ Interface: add_int16(const Datagram self, int value)

// The default numeric packing is little-endian.

/**
  • Adds a signed 16-bit integer to the datagram.

*/

add_int32()

C++ Interface: add_int32(const Datagram self, int value)

/**
  • Adds a signed 32-bit integer to the datagram.

*/

add_int64()

C++ Interface: add_int64(const Datagram self, long value)

/**
  • Adds a signed 64-bit integer to the datagram.

*/

add_int8()

C++ Interface: add_int8(const Datagram self, int value)

/**
  • Adds a signed 8-bit integer to the datagram.

*/

add_stdfloat()

C++ Interface: add_stdfloat(const Datagram self, float value)

/**
  • Adds either a 32-bit or a 64-bit floating-point number, according to

  • set_stdfloat_double().

*/

add_string()

C++ Interface: add_string(const Datagram self, str str)

/**
  • Adds a variable-length string to the datagram. This actually adds a count

  • followed by n bytes.

*/

add_string32()

C++ Interface: add_string32(const Datagram self, str str)

/**
  • Adds a variable-length string to the datagram, using a 32-bit length field

  • to allow very long strings.

*/

add_uint16()

C++ Interface: add_uint16(const Datagram self, int value)

/**
  • Adds an unsigned 16-bit integer to the datagram.

*/

add_uint32()

C++ Interface: add_uint32(const Datagram self, int value)

/**
  • Adds an unsigned 32-bit integer to the datagram.

*/

add_uint64()

C++ Interface: add_uint64(const Datagram self, long value)

/**
  • Adds an unsigned 64-bit integer to the datagram.

*/

add_uint8()

C++ Interface: add_uint8(const Datagram self, int value)

/**
  • Adds an unsigned 8-bit integer to the datagram.

*/

add_wstring()

C++ Interface: add_wstring(const Datagram self, unicode str)

/**
  • Adds a variable-length wstring to the datagram.

*/

add_z_string()

C++ Interface: add_z_string(const Datagram self, str str)

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

*/

appendData()

C++ Interface: append_data(const Datagram self, bytes data)

/**
  • Appends some more raw data to the end of the datagram.

*/

/**
  • Appends some more raw data to the end of the datagram.

*/

append_data()

C++ Interface: append_data(const Datagram self, bytes data)

/**
  • Appends some more raw data to the end of the datagram.

*/

/**
  • Appends some more raw data to the end of the datagram.

*/

assign()

C++ Interface: assign(const Datagram self, const Datagram copy)

clear()

C++ Interface: clear(const Datagram self)

/**
  • Resets the datagram to empty, in preparation for building up a new

  • datagram.

*/

copyArray()

C++ Interface: copy_array(const Datagram self, ConstPointerToArray 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.

*/

copy_array()

C++ Interface: copy_array(const Datagram self, ConstPointerToArray 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()

C++ Interface: dump_hex(Datagram self, ostream out, int indent)

/**
  • Writes a representation of the entire datagram contents, as a sequence of

  • hex (and ASCII) values.

*/

dump_hex()

C++ Interface: dump_hex(Datagram self, ostream out, int indent)

/**
  • Writes a representation of the entire datagram contents, as a sequence of

  • hex (and ASCII) values.

*/

getArray()

C++ Interface: get_array(Datagram self)

/**
  • Returns a const pointer to the actual data in the Datagram.

*/

getClassType()

C++ Interface: get_class_type()

getLength()

C++ Interface: get_length(Datagram self)

/**
  • Returns the number of bytes in the datagram.

*/

getMessage()

C++ Interface: get_message(Datagram self)

/**
  • Returns the datagram’s data as a string.

*/

getStdfloatDouble()

C++ Interface: get_stdfloat_double(Datagram self)

/**
  • Returns the stdfloat_double flag. See set_stdfloat_double().

*/

get_array()

C++ Interface: get_array(Datagram self)

/**
  • Returns a const pointer to the actual data in the Datagram.

*/

get_class_type()

C++ Interface: get_class_type()

get_length()

C++ Interface: get_length(Datagram self)

/**
  • Returns the number of bytes in the datagram.

*/

get_message()

C++ Interface: get_message(Datagram self)

/**
  • Returns the datagram’s data as a string.

*/

get_stdfloat_double()

C++ Interface: get_stdfloat_double(Datagram self)

/**
  • Returns the stdfloat_double flag. See set_stdfloat_double().

*/

modifyArray()

C++ Interface: modify_array(const Datagram self)

/**
  • Returns a modifiable pointer to the actual data in the Datagram.

*/

modify_array()

C++ Interface: modify_array(const Datagram self)

/**
  • Returns a modifiable pointer to the actual data in the Datagram.

*/

output()

C++ Interface: output(Datagram self, ostream out)

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

*/

padBytes()

C++ Interface: pad_bytes(const Datagram self, int size)

/**
  • Adds the indicated number of zero bytes to the datagram.

*/

pad_bytes()

C++ Interface: pad_bytes(const Datagram self, int size)

/**
  • Adds the indicated number of zero bytes to the datagram.

*/

setArray()

C++ Interface: set_array(const Datagram self, PointerToArray 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()

C++ Interface: set_stdfloat_double(const Datagram self, 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.

*/

set_array()

C++ Interface: set_array(const Datagram self, PointerToArray 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.

*/

set_stdfloat_double()

C++ Interface: set_stdfloat_double(const Datagram self, 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()

C++ Interface: write(Datagram self, ostream out, int indent)

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

*/