Panda3D

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Datagram Class Reference

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

`#include "datagram.h"`

Inheritance diagram for Datagram:

## Public Member Functions
| Datagram (const Datagram &copy)=default
| Datagram (const void *data, size_t size)
| Constructs a datagram from an existing block of data.
| Datagram (Datagram &&from) noexcept=default
| Datagram (vector_uchar data)
| Constructs a datagram from an existing block of data.
void | add_be_float32 (PN_float32 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_be_int16 (int16_t value)
| Adds a signed 16-bit big-endian integer to the datagram.
void | add_be_int32 (int32_t value)
| Adds a signed 32-bit big-endian integer to the datagram.
void | add_be_int64 (int64_t value)
| Adds a signed 64-bit big-endian integer to the datagram.
void | add_be_uint16 (uint16_t value)
| Adds an unsigned 16-bit big-endian integer to the datagram.
void | add_be_uint32 (uint32_t value)
| Adds an unsigned 32-bit big-endian integer to the datagram.
void | add_be_uint64 (uint64_t value)
| Adds an unsigned 64-bit big-endian integer to the datagram.
void | add_blob (const vector_uchar &)
| Adds a variable-length binary blob to the datagram.
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.
void | add_bool (bool value)
| Adds a boolean value to the datagram.
void | add_fixed_string (const std::string &str, size_t size)
| Adds a fixed-length string to the datagram.
void | add_float32 (PN_float32 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_int16 (int16_t value)
| Adds a signed 16-bit integer to the datagram.
void | add_int32 (int32_t value)
| Adds a signed 32-bit integer to the datagram.
void | add_int64 (int64_t value)
| Adds a signed 64-bit integer to the datagram.
void | add_int8 (int8_t value)
| Adds a signed 8-bit integer to the datagram.
void | add_stdfloat (PN_stdfloat value)
| Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void | add_string (const std::string &str)
| Adds a variable-length string to the datagram.
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.
void | add_uint16 (uint16_t value)
| Adds an unsigned 16-bit integer to the datagram.
void | add_uint32 (uint32_t value)
| Adds an unsigned 32-bit integer to the datagram.
void | add_uint64 (uint64_t value)
| Adds an unsigned 64-bit integer to the datagram.
void | add_uint8 (uint8_t value)
| Adds an unsigned 8-bit integer to the datagram.
void | add_wstring (const std::wstring &str)
| Adds a variable-length wstring to the datagram.
void | add_z_string (const std::string &str)
| Adds a variable-length string to the datagram, as a NULL-terminated string.
void | append_data (const vector_uchar &data)
| Appends some more raw data to the end of the datagram.
void | append_data (const void *data, size_t size)
| Appends some more raw data to the end of the datagram.
void | assign (const void *data, size_t size)
| Replaces the datagram's data with the indicated block.
virtual void | clear ()
| Resets the datagram to empty, in preparation for building up a new datagram.
void | copy_array (CPTA_uchar data)
| Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar.
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.
virtual TypeHandle | force_init_type ()
CPTA_uchar | get_array () const
| Returns a const pointer to the actual data in the Datagram.
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.
std::string | get_message () const
| Returns the datagram's data as a string.
bool | get_stdfloat_double () const
| Returns the stdfloat_double flag.
virtual TypeHandle | get_type () const
PTA_uchar | modify_array ()
| Returns a modifiable pointer to the actual data in the Datagram.
bool | operator!= (const Datagram &other) const
bool | operator< (const Datagram &other) const
Datagram & | operator= (const Datagram &copy)=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>.
void | pad_bytes (size_t size)
| Adds the indicated number of zero bytes to the datagram.
void | set_array (PTA_uchar data)
| Replaces the data in the Datagram with the data in the indicated PTA_uchar.
void | set_stdfloat_double (bool stdfloat_double)
| Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and DatagramIterator::get_stdfloat().
void | write (std::ostream &out, unsigned int indent=0) const
| Write a string representation of this instance to <out>.
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=default
TypedObject * | as_typed_object ()
| Returns the object, upcast (if necessary) to a TypedObject pointer.
const TypedObject * | as_typed_object () const
| Returns the object, upcast (if necessary) to a TypedObject pointer.
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.
bool | is_exact_type (TypeHandle handle) const
| Returns true if the current object is the indicated type exactly.
bool | is_of_type (TypeHandle handle) const
| Returns true if the current object is or derives from the indicated type.
TypedObject & | operator= (const TypedObject &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)

## Static Public Member Functions
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.

## Additional Inherited Members
Public Attributes inherited from TypedObject
| get_type

## 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.

Definition at line 38 of file datagram.h.

## Constructor & Destructor Documentation

## ◆ Datagram() [1/2]

Datagram::Datagram | ( | const void * | data,
|  | size_t | size )
| inline

Constructs a datagram from an existing block of data.

Definition at line 17 of file datagram.I.

References append_data().

## ◆ Datagram() [2/2]

Datagram::Datagram | ( | vector_uchar | data | ) |
| inline explicit

Constructs a datagram from an existing block of data.

Definition at line 25 of file datagram.I.

## ◆ ~Datagram()

Datagram::~Datagram | ( |  | ) |
| virtual

Definition at line 26 of file datagram.cxx.

## Member Function Documentation

## ◆ add_be_float32()

void Datagram::add_be_float32 | ( | PN_float32 | value | ) |
| inline

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

Definition at line 199 of file datagram.I.

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

Referenced by FltMaterial::build_14_record(), and FltLocalVertexPool::build_record().

## ◆ add_be_float64()

void Datagram::add_be_float64 | ( | PN_float64 | value | ) |
| inline

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

Definition at line 208 of file datagram.I.

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

Referenced by FltLocalVertexPool::build_record().

## ◆ add_be_int16()

void Datagram::add_be_int16 | ( | int16_t | value | ) |
| inline

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

Definition at line 144 of file datagram.I.

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

Referenced by FltRecordWriter::advance().

## ◆ add_be_int32()

void Datagram::add_be_int32 | ( | int32_t | value | ) |
| inline

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

Definition at line 153 of file datagram.I.

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

Referenced by FltLocalVertexPool::build_record().

## ◆ add_be_int64()

void Datagram::add_be_int64 | ( | int64_t | value | ) |
| inline

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

Definition at line 162 of file datagram.I.

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

## ◆ add_be_uint16()

void Datagram::add_be_uint16 | ( | uint16_t | value | ) |
| inline

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

Definition at line 171 of file datagram.I.

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

## ◆ add_be_uint32()

void Datagram::add_be_uint32 | ( | uint32_t | value | ) |
| inline

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

Definition at line 180 of file datagram.I.

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

Referenced by FltMaterial::build_14_record().

## ◆ add_be_uint64()

void Datagram::add_be_uint64 | ( | uint64_t | value | ) |
| inline

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

Definition at line 189 of file datagram.I.

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

## ◆ add_blob()

void Datagram::add_blob | ( | const vector_uchar & | data | ) |
| inline

Adds a variable-length binary blob to the datagram.

This actually adds a count followed by n bytes.

Definition at line 277 of file datagram.I.

References add_uint16(), and append_data().

## ◆ add_blob32()

void Datagram::add_blob32 | ( | const vector_uchar & | data | ) |
| inline

Adds a variable-length binary blob to the datagram, using a 32-bit length field to allow very long blobs.

Definition at line 293 of file datagram.I.

References add_uint32(), and append_data().

## ◆ add_bool()

void Datagram::add_bool | ( | bool | value | ) |
| inline

Adds a boolean value to the datagram.

Definition at line 33 of file datagram.I.

References add_uint8().

Referenced by BamWriter::init(), MouseRecorder::record_frame(), AnimChannelMatrixXfmTable::write_datagram(), AnimChannelScalarTable::write_datagram(), AudioVolumeAttrib::write_datagram(), BillboardEffect::write_datagram(), BulletBodyNode::write_datagram(), BulletDebugNode::write_datagram(), BulletTriangleMesh::write_datagram(), BulletTriangleMeshShape::write_datagram(), Camera::write_datagram(), ClipPlaneAttrib::write_datagram(), CollisionHandlerGravity::write_datagram(), CollisionHandlerPusher::write_datagram(), ColorScaleAttrib::write_datagram(), CullFaceAttrib::write_datagram(), DirectionalLight::write_datagram(), EggFile::write_datagram(), GeomVertexAnimationSpec::write_datagram(), ImageFile::write_datagram(), LensNode::write_datagram(), LightAttrib::write_datagram(), LightLensNode::write_datagram(), MovieVideo::write_datagram(), PaletteGroup::write_datagram(), PaletteImage::write_datagram(), Palettizer::write_datagram(), PointLight::write_datagram(), RecorderFrame::write_datagram(), RenderModeAttrib::write_datagram(), ScissorAttrib::write_datagram(), ScissorEffect::write_datagram(), Shader::write_datagram(), ShaderBuffer::write_datagram(), ShowBoundsEffect::write_datagram(), SparseArray::write_datagram(), Spotlight::write_datagram(), TextureAttrib::write_datagram(), TextureImage::write_datagram(), TexturePlacement::write_datagram(), TextureProperties::write_datagram(), TextureReference::write_datagram(), TextureStage::write_datagram(), and FFTCompressor::write_reals().

## ◆ add_fixed_string()

void Datagram::add_fixed_string | ( | const std::string & | str,
|  | size_t | size )
| inline

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 262 of file datagram.I.

References append_data(), and pad_bytes().

Referenced by FltMaterial::build_14_record().

## ◆ add_float32()

void Datagram::add_float32 | ( | PN_float32 | value | ) |
| inline

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 113 of file datagram.I.

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

Referenced by add_stdfloat(), PStatCollectorDef::write_datagram(), PStatFrameData::write_datagram(), and Shader::ShaderPtrData::write_datagram().

## ◆ add_float64()

void Datagram::add_float64 | ( | PN_float64 | value | ) |
| inline

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

Definition at line 122 of file datagram.I.

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

Referenced by add_stdfloat(), CollisionHandlerFloor::write_datagram(), CollisionHandlerGravity::write_datagram(), Palettizer::write_datagram(), RecorderFrame::write_datagram(), Shader::ShaderPtrData::write_datagram(), TextureImage::write_datagram(), TexturePosition::write_datagram(), TextureReference::write_datagram(), and FFTCompressor::write_header().

## ◆ add_int16()

void Datagram::add_int16 | ( | int16_t | value | ) |
| inline

Adds a signed 16-bit integer to the datagram.

Definition at line 57 of file datagram.I.

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

Referenced by MovieAudioCursor::read_samples(), PaletteGroup::write_datagram(), PStatCollectorDef::write_datagram(), SamplerState::write_datagram(), and TextureImage::write_datagram().

## ◆ add_int32()

void Datagram::add_int32 | ( | int32_t | value | ) |
| inline

Adds a signed 32-bit integer to the datagram.

Definition at line 66 of file datagram.I.

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

Referenced by NodePath::encode_to_bam_stream(), AnimPreloadTable::write_datagram(), AuxBitplaneAttrib::write_datagram(), BulletConvexPointCloudShape::write_datagram(), BulletHeightfieldShape::write_datagram(), BulletMultiSphereShape::write_datagram(), BulletTriangleMesh::write_datagram(), CullBinAttrib::write_datagram(), DepthOffsetAttrib::write_datagram(), ImageFile::write_datagram(), LightLensNode::write_datagram(), Material::write_datagram(), PaletteGroup::write_datagram(), Palettizer::write_datagram(), ParamTextureImage::write_datagram(), PlaneNode::write_datagram(), RecorderHeader::write_datagram(), RenderState::write_datagram(), Shader::ShaderPtrData::write_datagram(), SparseArray::write_datagram(), StencilAttrib::write_datagram(), TexMatrixAttrib::write_datagram(), TextureAttrib::write_datagram(), TexturePlacement::write_datagram(), TexturePosition::write_datagram(), TextureProperties::write_datagram(), TextureReference::write_datagram(), TextureStage::write_datagram(), DownloadDb::Db::write_header(), and FFTCompressor::write_reals().

## ◆ add_int64()

void Datagram::add_int64 | ( | int64_t | value | ) |
| inline

Adds a signed 64-bit integer to the datagram.

Definition at line 75 of file datagram.I.

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

## ◆ add_int8()

void Datagram::add_int8 | ( | int8_t | value | ) |
| inline

Adds a signed 8-bit integer to the datagram.

Definition at line 41 of file datagram.I.

References append_data().

Referenced by CConnectionRepository::send_message_bundle(), AlphaTestAttrib::write_datagram(), BulletCapsuleShape::write_datagram(), BulletConeShape::write_datagram(), BulletCylinderShape::write_datagram(), BulletHeightfieldShape::write_datagram(), ColorAttrib::write_datagram(), CullFaceAttrib::write_datagram(), DepthTestAttrib::write_datagram(), DepthWriteAttrib::write_datagram(), Fog::write_datagram(), HermiteCurveCV::write_datagram(), LightRampAttrib::write_datagram(), ParamTextureImage::write_datagram(), RenderModeAttrib::write_datagram(), RescaleNormalAttrib::write_datagram(), ShadeModelAttrib::write_datagram(), TransparencyAttrib::write_datagram(), and FFTCompressor::write_header().

## ◆ add_stdfloat()

void Datagram::add_stdfloat | ( | PN_stdfloat | value | ) |
| inline

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

Definition at line 132 of file datagram.I.

References add_float32(), and add_float64().

Referenced by AlphaTestAttrib::write_datagram(), AnimChannelMatrixXfmTable::write_datagram(), AnimChannelScalarDynamic::write_datagram(), AnimChannelScalarTable::write_datagram(), AnimPreloadTable::write_datagram(), AudioVolumeAttrib::write_datagram(), BillboardEffect::write_datagram(), BulletBodyNode::write_datagram(), BulletBoxShape::write_datagram(), BulletCapsuleShape::write_datagram(), BulletConeShape::write_datagram(), BulletConvexHullShape::write_datagram(), BulletCylinderShape::write_datagram(), BulletHeightfieldShape::write_datagram(), BulletMinkowskiSumShape::write_datagram(), BulletMultiSphereShape::write_datagram(), BulletPlaneShape::write_datagram(), BulletRigidBodyNode::write_datagram(), BulletSphereShape::write_datagram(), BulletTriangleMesh::write_datagram(), BulletTriangleMeshShape::write_datagram(), Camera::write_datagram(), CollisionBox::write_datagram(), CollisionCapsule::write_datagram(), CollisionFloorMesh::write_datagram(), CollisionParabola::write_datagram(), CollisionSphere::write_datagram(), DepthOffsetAttrib::write_datagram(), Fog::write_datagram(), LightRampAttrib::write_datagram(), Material::write_datagram(), PolylightNode::write_datagram(), RenderModeAttrib::write_datagram(), SamplerState::write_datagram(), STTransform::write_datagram(), TimedCycle::write_datagram(), TransformBlend::write_datagram(), UvScrollNode::write_datagram(), and FFTCompressor::write_reals().

## ◆ add_string()

void Datagram::add_string | ( | const std::string & | str | ) |
| inline

Adds a variable-length string to the datagram.

This actually adds a count followed by n bytes.

Definition at line 218 of file datagram.I.

References add_uint16(), and append_data().

Referenced by PStatClientControlMessage::encode(), PStatServerControlMessage::encode(), DirectD::send_command(), CConnectionRepository::send_message_bundle(), AnimPreloadTable::write_datagram(), BamCacheRecord::write_datagram(), ButtonEvent::write_datagram(), CollisionHandlerEvent::write_datagram(), CullBinAttrib::write_datagram(), EggFile::write_datagram(), GeomVertexData::write_datagram(), HermiteCurveCV::write_datagram(), ImageFile::write_datagram(), InternalName::write_datagram(), Material::write_datagram(), MovieVideo::write_datagram(), PaletteGroup::write_datagram(), PaletteImage::write_datagram(), PalettePage::write_datagram(), Palettizer::write_datagram(), PandaNode::write_datagram(), PartGroup::write_datagram(), PStatCollectorDef::write_datagram(), RecorderTable::write_datagram(), Shader::ShaderFile::write_datagram(), Shader::write_datagram(), ShaderBuffer::write_datagram(), SpeedTreeNode::InstanceList::write_datagram(), TextureImage::write_datagram(), TextureReference::write_datagram(), TextureStage::write_datagram(), BamWriter::write_handle(), and PandaNode::write_recorder().

## ◆ add_string32()

void Datagram::add_string32 | ( | const std::string & | str | ) |
| inline

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

Definition at line 234 of file datagram.I.

References add_uint32(), and append_data().

## ◆ add_uint16()

void Datagram::add_uint16 | ( | uint16_t | value | ) |
| inline

Adds an unsigned 16-bit integer to the datagram.

Definition at line 84 of file datagram.I.

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

Referenced by add_blob(), add_string(), add_wstring(), PStatClientControlMessage::encode(), PStatServerControlMessage::encode(), BamWriter::init(), AnimChannelBase::write_datagram(), AnimChannelMatrixXfmTable::write_datagram(), AnimChannelScalarTable::write_datagram(), AnimPreloadTable::write_datagram(), AntialiasAttrib::write_datagram(), BamCacheRecord::write_datagram(), ButtonEvent::write_datagram(), ButtonEventList::write_datagram(), Character::write_datagram(), CharacterJoint::write_datagram(), ClipPlaneAttrib::write_datagram(), CollisionBox::write_datagram(), CollisionFloorMesh::write_datagram(), CollisionNode::write_datagram(), CollisionPolygon::write_datagram(), CompassEffect::write_datagram(), ComputeNode::Dispatcher::CData::write_datagram(), DataNodeTransmit::write_datagram(), GeomPatches::write_datagram(), GeomVertexAnimationSpec::write_datagram(), GeomVertexArrayFormat::write_datagram(), GeomVertexColumn::write_datagram(), GeomVertexFormat::write_datagram(), LensNode::write_datagram(), LightAttrib::write_datagram(), ModelNode::write_datagram(), OccluderEffect::write_datagram(), OccluderNode::write_datagram(), PartBundleNode::write_datagram(), PartGroup::write_datagram(), PortalNode::write_datagram(), PStatFrameData::write_datagram(), RecorderTable::write_datagram(), RenderEffects::write_datagram(), RenderState::write_datagram(), ScissorEffect::write_datagram(), SliderTable::write_datagram(), TexGenAttrib::write_datagram(), TexMatrixAttrib::write_datagram(), TexProjectorEffect::write_datagram(), TextureAttrib::write_datagram(), TimedCycle::write_datagram(), TransformBlend::write_datagram(), TransformBlendTable::write_datagram(), TransformTable::write_datagram(), and BamWriter::write_handle().

## ◆ add_uint32()

void Datagram::add_uint32 | ( | uint32_t | value | ) |
| inline

Adds an unsigned 32-bit integer to the datagram.

Definition at line 93 of file datagram.I.

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

Referenced by add_blob32(), add_string32(), add_wstring(), BamCacheIndex::write_datagram(), BamCacheRecord::write_datagram(), BitArray::write_datagram(), BulletConvexHullShape::write_datagram(), Camera::write_datagram(), CollisionFloorMesh::write_datagram(), CollisionHandlerEvent::write_datagram(), CollisionNode::write_datagram(), EggFile::write_datagram(), PaletteGroup::write_datagram(), PaletteGroups::write_datagram(), PaletteImage::write_datagram(), PalettePage::write_datagram(), RecorderFrame::write_datagram(), RecorderHeader::write_datagram(), Shader::ShaderPtrData::write_datagram(), Shader::write_datagram(), SparseArray::write_datagram(), SpeedTreeNode::InstanceList::write_datagram(), SpeedTreeNode::write_datagram(), StencilAttrib::write_datagram(), TextureImage::write_datagram(), TransformState::write_datagram(), and DownloadDb::Db::write_header().

## ◆ add_uint64()

void Datagram::add_uint64 | ( | uint64_t | value | ) |
| inline

Adds an unsigned 64-bit integer to the datagram.

Definition at line 102 of file datagram.I.

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

Referenced by CConnectionRepository::send_message_bundle(), BamCacheRecord::write_datagram(), and ShaderBuffer::write_datagram().

## ◆ add_uint8()

void Datagram::add_uint8 | ( | uint8_t | value | ) |
| inline

Adds an unsigned 8-bit integer to the datagram.

Definition at line 49 of file datagram.I.

References append_data().

Referenced by add_bool(), add_z_string(), PStatClientControlMessage::encode(), PStatServerControlMessage::encode(), NodePath::encode_to_bam_stream(), BamWriter::init(), AnimChannelScalarTable::write_datagram(), BitArray::write_datagram(), ButtonEvent::write_datagram(), CollisionSolid::write_datagram(), ColorBlendAttrib::write_datagram(), ColorWriteAttrib::write_datagram(), GeomVertexAnimationSpec::write_datagram(), GeomVertexArrayFormat::write_datagram(), GeomVertexColumn::write_datagram(), ImageFile::write_datagram(), LogicOpAttrib::write_datagram(), MatrixLens::write_datagram(), ModelNode::write_datagram(), Palettizer::write_datagram(), ParamTextureImage::write_datagram(), PlaneNode::write_datagram(), SamplerState::write_datagram(), Shader::ShaderFile::write_datagram(), Shader::ShaderPtrData::write_datagram(), Shader::write_datagram(), ShaderBuffer::write_datagram(), TexGenAttrib::write_datagram(), TextureImage::write_datagram(), TextureStage::write_datagram(), BamWriter::write_file_data(), BamWriter::write_file_data(), BamWriter::write_handle(), and BamWriter::write_object().

## ◆ add_wstring()

void Datagram::add_wstring | ( | const std::wstring & | str | ) |

Adds a variable-length wstring to the datagram.

Definition at line 82 of file datagram.cxx.

References add_uint16(), and add_uint32().

## ◆ add_z_string()

void Datagram::add_z_string | ( | const std::string & | str | ) |
| inline

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

Definition at line 246 of file datagram.I.

References add_uint8(), and append_data().

## ◆ append_data() [1/2]

void Datagram::append_data | ( | const vector_uchar & | data | ) |
| inline

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

Definition at line 305 of file datagram.I.

References append_data().

## ◆ append_data() [2/2]

void Datagram::append_data | ( | const void * | data,
|  | size_t | size )

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

Definition at line 128 of file datagram.cxx.

Referenced by Datagram(), add_be_float32(), add_be_float64(), add_be_int16(), add_be_int32(), add_be_int64(), add_be_uint16(), add_be_uint32(), add_be_uint64(), add_blob(), add_blob32(), add_fixed_string(), add_float32(), add_float64(), add_int16(), add_int32(), add_int64(), add_int8(), add_string(), add_string32(), add_uint16(), add_uint32(), add_uint64(), add_uint8(), add_z_string(), append_data(), and ShaderBuffer::write_datagram().

## ◆ assign()

void Datagram::assign | ( | const void * | data,
|  | size_t | size )

Replaces the datagram's data with the indicated block.

Definition at line 159 of file datagram.cxx.

## ◆ clear()

void Datagram::clear | ( |  | ) |
| virtual

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

Reimplemented in NetDatagram.

Definition at line 34 of file datagram.cxx.

Referenced by NetDatagram::clear(), PStatClientControlMessage::encode(), and PStatServerControlMessage::encode().

## ◆ copy_array()

void Datagram::copy_array | ( | CPTA_uchar | data | ) |
| inline

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.

Definition at line 354 of file datagram.I.

## ◆ dump_hex()

void Datagram::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.

Definition at line 43 of file datagram.cxx.

References get_data(), get_length(), and indent().

Referenced by GeomVertexData::describe_vertex(), CConnectionRepository::send_datagram(), DatagramTCPHeader::verify_datagram(), DatagramUDPHeader::verify_datagram(), DirectD::wait_for_servers(), and write().

## ◆ force_init_type()

virtual TypeHandle Datagram::force_init_type | ( |  | ) |
| inline virtual

Implements TypedObject.

Definition at line 141 of file datagram.h.

## ◆ get_array()

CPTA_uchar Datagram::get_array | ( |  | ) | const
| inline

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

Definition at line 363 of file datagram.I.

## ◆ get_class_type()

static TypeHandle Datagram::get_class_type | ( |  | ) |
| inline static

Definition at line 130 of file datagram.h.

## ◆ get_data()

const void * Datagram::get_data | ( |  | ) | const
| inline

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

Definition at line 326 of file datagram.I.

Referenced by DatagramUDPHeader::DatagramUDPHeader(), FltRecordWriter::advance(), HashVal::as_bin(), dump_hex(), IffInputFile::get_id(), GeomVertexArrayData::read_raw_data(), EggJointData::score_reparent_to(), CConnectionRepository::send_datagram(), Buffered_DatagramConnection::SendMessage(), DatagramUDPHeader::verify_datagram(), FltTexture::write_attr_data(), and DownloadDb::Db::write_header().

## ◆ get_length()

size_t Datagram::get_length | ( |  | ) | const
| inline

Returns the number of bytes in the datagram.

Definition at line 334 of file datagram.I.

Referenced by DatagramTCPHeader::DatagramTCPHeader(), DatagramUDPHeader::DatagramUDPHeader(), FltRecordWriter::advance(), HashVal::as_bin(), dump_hex(), BamReader::init(), ConnectionWriter::is_valid_for_udp(), EggJointData::score_reparent_to(), ConnectionWriter::send(), Buffered_DatagramConnection::SendMessage(), DatagramTCPHeader::verify_datagram(), DatagramUDPHeader::verify_datagram(), DatagramIterator::write(), FltTexture::write_attr_data(), and DownloadDb::Db::write_header().

## ◆ get_message()

std::string Datagram::get_message | ( |  | ) | const
| inline

Returns the datagram's data as a string.

Definition at line 313 of file datagram.I.

## ◆ get_stdfloat_double()

bool Datagram::get_stdfloat_double | ( |  | ) | const
| inline

Returns the stdfloat_double flag.

See set_stdfloat_double().

Definition at line 402 of file datagram.I.

## ◆ get_type()

virtual TypeHandle Datagram::get_type | ( |  | ) | const
| inline virtual

Implements TypedObject.

Definition at line 138 of file datagram.h.

## ◆ init_type()

static void Datagram::init_type | ( |  | ) |
| inline static

Definition at line 133 of file datagram.h.

## ◆ modify_array()

PTA_uchar Datagram::modify_array | ( |  | ) |
| inline

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

Definition at line 371 of file datagram.I.

Referenced by PStatFrameData::write_datagram().

## ◆ operator!=()

bool Datagram::operator!= | ( | const Datagram & | other | ) | const
| inline

Definition at line 424 of file datagram.I.

## ◆ operator<()

bool Datagram::operator< | ( | const Datagram & | other | ) | const
| inline

Definition at line 432 of file datagram.I.

## ◆ operator==()

bool Datagram::operator== | ( | const Datagram & | other | ) | const
| inline

Definition at line 410 of file datagram.I.

## ◆ output()

void Datagram::output | ( | std::ostream & | out | ) | const

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

Definition at line 171 of file datagram.cxx.

## ◆ pad_bytes()

void Datagram::pad_bytes | ( | size_t | size | ) |

Adds the indicated number of zero bytes to the datagram.

Definition at line 98 of file datagram.cxx.

Referenced by add_fixed_string(), and FltMaterial::build_14_record().

## ◆ set_array()

void Datagram::set_array | ( | PTA_uchar | data | ) |
| inline

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.

Definition at line 344 of file datagram.I.

## ◆ set_stdfloat_double()

void Datagram::set_stdfloat_double | ( | bool | stdfloat_double | ) |
| inline

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.

Definition at line 394 of file datagram.I.

## ◆ write()

void Datagram::write | ( | std::ostream & | out,
|  | unsigned int | indent = 0 ) const

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

Definition at line 181 of file datagram.cxx.

References dump_hex(), and indent().

Referenced by DatagramIterator::write().

The documentation for this class was generated from the following files:

- panda/src/express/datagram.h
- panda/src/express/datagram.cxx
- panda/src/express/datagram.I