Panda3D
Public Member Functions | Static Public Member Functions | List of all members
DatagramIterator Class Reference

A class to retrieve the individual data elements previously stored in a Datagram. More...

#include "datagramIterator.h"

Public Member Functions

 DatagramIterator (const Datagram &datagram, size_t offset=0)
 
 DatagramIterator (const DatagramIterator &copy)
 
void assign (Datagram &datagram, size_t offset=0)
 direct Assignment to a Datagram More...
 
string extract_bytes (size_t size)
 Extracts the indicated number of bytes in the datagram and returns them as a string. More...
 
size_t extract_bytes (unsigned char *into, size_t size)
 Extracts the indicated number of bytes in the datagram into the given character buffer. More...
 
PN_float32 get_be_float32 ()
 Extracts a 32-bit big-endian single-precision floating-point number. More...
 
PN_float64 get_be_float64 ()
 Extracts a 64-bit big-endian floating-point number. More...
 
PN_int16 get_be_int16 ()
 Extracts a signed 16-bit big-endian integer. More...
 
PN_int32 get_be_int32 ()
 Extracts a signed 32-bit big-endian integer. More...
 
PN_int64 get_be_int64 ()
 Extracts a signed 64-bit big-endian integer. More...
 
PN_uint16 get_be_uint16 ()
 Extracts an unsigned 16-bit big-endian integer. More...
 
PN_uint32 get_be_uint32 ()
 Extracts an unsigned 32-bit big-endian integer. More...
 
PN_uint64 get_be_uint64 ()
 Extracts an unsigned 64-bit big-endian integer. More...
 
bool get_bool ()
 Extracts a boolean value. More...
 
size_t get_current_index () const
 Returns the current position within the datagram of the next piece of data to extract. More...
 
const Datagramget_datagram () const
 Return the datagram of this iterator. More...
 
string get_fixed_string (size_t size)
 Extracts a fixed-length string. More...
 
PN_float32 get_float32 ()
 Extracts a 32-bit single-precision floating-point number. More...
 
PN_float64 get_float64 ()
 Extracts a 64-bit floating-point number. More...
 
PN_int16 get_int16 ()
 Extracts a signed 16-bit integer. More...
 
PN_int32 get_int32 ()
 Extracts a signed 32-bit integer. More...
 
PN_int64 get_int64 ()
 Extracts a signed 64-bit integer. More...
 
PN_int8 get_int8 ()
 Extracts a signed 8-bit integer. More...
 
string get_remaining_bytes () const
 Returns the remaining bytes in the datagram as a string, but does not extract them from the iterator. More...
 
int get_remaining_size () const
 Return the bytes left in the datagram. More...
 
PN_stdfloat get_stdfloat ()
 Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_double(). More...
 
string get_string ()
 Extracts a variable-length string. More...
 
string get_string32 ()
 Extracts a variable-length string with a 32-bit length field. More...
 
PN_uint16 get_uint16 ()
 Extracts an unsigned 16-bit integer. More...
 
PN_uint32 get_uint32 ()
 Extracts an unsigned 32-bit integer. More...
 
PN_uint64 get_uint64 ()
 Extracts an unsigned 64-bit integer. More...
 
PN_uint8 get_uint8 ()
 Extracts an unsigned 8-bit integer. More...
 
wstring get_wstring ()
 Extracts a variable-length wstring (with a 32-bit length field). More...
 
string get_z_string ()
 Extracts a variable-length string, as a NULL-terminated string. More...
 
void operator= (const DatagramIterator &copy)
 
void output (ostream &out) const
 Write a string representation of this instance to <out>. More...
 
void skip_bytes (size_t size)
 Skips over the indicated number of bytes in the datagram. More...
 
void write (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 

Detailed Description

A class to retrieve the individual data elements previously stored in a Datagram.

Elements may be retrieved one at a time; it is up to the caller to know the correct type and order of each element.

Definition at line 30 of file datagramIterator.h.

Member Function Documentation

◆ assign()

void DatagramIterator::assign ( Datagram datagram,
size_t  offset = 0 
)
inline

direct Assignment to a Datagram

Definition at line 65 of file datagramIterator.I.

References get_bool().

◆ extract_bytes() [1/2]

string DatagramIterator::extract_bytes ( size_t  size)

Extracts the indicated number of bytes in the datagram and returns them as a string.

Definition at line 140 of file datagramIterator.cxx.

References Datagram::get_data().

Referenced by Texture::finalize(), get_wstring(), and DownloadDb::Db::parse_record_header().

◆ extract_bytes() [2/2]

size_t DatagramIterator::extract_bytes ( unsigned char *  into,
size_t  size 
)

Extracts the indicated number of bytes in the datagram into the given character buffer.

Assumes that the buffer is big enough to hold the requested number of bytes. Returns the number of bytes that were successfully written.

Definition at line 163 of file datagramIterator.cxx.

References Datagram::get_data(), and output().

◆ get_be_float32()

PN_float32 DatagramIterator::get_be_float32 ( )
inline

◆ get_be_float64()

PN_float64 DatagramIterator::get_be_float64 ( )
inline

Extracts a 64-bit big-endian floating-point number.

Definition at line 468 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), skip_bytes(), and ReversedNumericData::store_value().

Referenced by get_be_float32(), FltVertex::set_rgb(), and FltTexture::write_attr_data().

◆ get_be_int16()

PN_int16 DatagramIterator::get_be_int16 ( )
inline

◆ get_be_int32()

PN_int32 DatagramIterator::get_be_int32 ( )
inline

◆ get_be_int64()

PN_int64 DatagramIterator::get_be_int64 ( )
inline

Extracts a signed 64-bit big-endian integer.

Definition at line 362 of file datagramIterator.I.

References get_be_uint16(), Datagram::get_data(), and Datagram::get_length().

Referenced by get_be_int32().

◆ get_be_uint16()

PN_uint16 DatagramIterator::get_be_uint16 ( )
inline

Extracts an unsigned 16-bit big-endian integer.

Definition at line 383 of file datagramIterator.I.

References get_be_uint32(), Datagram::get_data(), and Datagram::get_length().

Referenced by FltRecordReader::error(), FltGeometry::get_alt_rgb(), get_be_int64(), IffInputFile::get_be_uint16(), and FltVertex::set_rgb().

◆ get_be_uint32()

PN_uint32 DatagramIterator::get_be_uint32 ( )
inline

Extracts an unsigned 32-bit big-endian integer.

Definition at line 404 of file datagramIterator.I.

References get_be_uint64(), Datagram::get_data(), and Datagram::get_length().

Referenced by FltMaterial::extract_14_record(), FltGeometry::get_alt_rgb(), get_be_uint16(), and IffInputFile::get_be_uint32().

◆ get_be_uint64()

PN_uint64 DatagramIterator::get_be_uint64 ( )
inline

Extracts an unsigned 64-bit big-endian integer.

Definition at line 425 of file datagramIterator.I.

References get_be_float32(), Datagram::get_data(), and Datagram::get_length().

Referenced by get_be_uint32().

◆ get_bool()

bool DatagramIterator::get_bool ( )
inline

◆ get_current_index()

size_t DatagramIterator::get_current_index ( ) const
inline

◆ get_datagram()

const Datagram & DatagramIterator::get_datagram ( ) const
inline

◆ get_fixed_string()

string DatagramIterator::get_fixed_string ( size_t  size)

Extracts a fixed-length string.

However, if a zero byte occurs within the string, it marks the end of the string.

Definition at line 96 of file datagramIterator.cxx.

References Datagram::get_data(), and get_wstring().

Referenced by FltMaterial::extract_14_record(), get_z_string(), FltBeadID::output(), FltExternalReference::set_ref_filename(), and FltTexture::write_attr_data().

◆ get_float32()

PN_float32 DatagramIterator::get_float32 ( )
inline

◆ get_float64()

PN_float64 DatagramIterator::get_float64 ( )
inline

◆ get_int16()

PN_int16 DatagramIterator::get_int16 ( )
inline

◆ get_int32()

PN_int32 DatagramIterator::get_int32 ( )
inline

Extracts a signed 32-bit integer.

Definition at line 155 of file datagramIterator.I.

References Datagram::get_data(), get_int64(), and Datagram::get_length().

Referenced by ImageFile::complete_pointers(), TexMatrixAttrib::complete_pointers(), ParamTextureImage::complete_pointers(), TextureReference::complete_pointers(), TexturePlacement::complete_pointers(), TextureAttrib::complete_pointers(), TexturePosition::fillin(), PaletteGroups::fillin(), TextureProperties::fillin(), PaletteGroup::finalize(), Palettizer::finalize(), GeomPrimitive::finalize(), RenderState::finalize(), Texture::finalize(), FFTCompressor::free_storage(), get_current_index(), get_int16(), AnimInterface::get_num_frames(), Light::get_viz(), AnimPreloadTable::make_from_bam(), TextureStage::make_TextureStage(), DownloadDb::Db::parse_header(), DownloadDb::Db::parse_record_header(), SparseArray::read_datagram(), LVecBase2f::read_datagram(), LVecBase3f::read_datagram(), LVecBase4f::read_datagram(), Shader::ShaderPtrData::read_datagram(), LVecBase2d::read_datagram(), LVecBase3d::read_datagram(), LVecBase4d::read_datagram(), LVecBase2i::read_datagram(), LVecBase3i::read_datagram(), LVecBase4i::read_datagram(), LVecBase2f::read_datagram_fixed(), LVecBase3f::read_datagram_fixed(), LVecBase4f::read_datagram_fixed(), LVecBase2d::read_datagram_fixed(), LVecBase3d::read_datagram_fixed(), LVecBase4d::read_datagram_fixed(), LVecBase2i::read_datagram_fixed(), LVecBase3i::read_datagram_fixed(), LVecBase4i::read_datagram_fixed(), FFTCompressor::read_reals(), SwitchNode::safe_to_combine_children(), RecorderHeader::write_datagram(), CullBinAttrib::write_datagram(), LightLensNode::write_datagram(), DepthOffsetAttrib::write_datagram(), AuxBitplaneAttrib::write_datagram(), Material::write_datagram(), PlaneNode::write_datagram(), StencilAttrib::write_datagram(), and PandaNode::write_recorder().

◆ get_int64()

PN_int64 DatagramIterator::get_int64 ( )
inline

Extracts a signed 64-bit integer.

Definition at line 176 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), and get_uint16().

Referenced by get_int32().

◆ get_int8()

PN_int8 DatagramIterator::get_int8 ( )
inline

◆ get_remaining_bytes()

string DatagramIterator::get_remaining_bytes ( ) const
inline

Returns the remaining bytes in the datagram as a string, but does not extract them from the iterator.

Definition at line 511 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), and get_remaining_size().

Referenced by FltBeadID::output(), skip_bytes(), and FltRecord::write().

◆ get_remaining_size()

int DatagramIterator::get_remaining_size ( ) const
inline

◆ get_stdfloat()

PN_stdfloat DatagramIterator::get_stdfloat ( )
inline

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

Definition at line 305 of file datagramIterator.I.

References get_be_int16(), get_float32(), get_float64(), and Datagram::get_stdfloat_double().

Referenced by TimedCycle::fillin(), STTransform::fillin(), AnimChannelScalarDynamic::fillin(), TransformBlend::fillin(), get_float64(), AnimInterface::get_num_frames(), LODNode::is_any_shown(), AnimPreloadTable::make_from_bam(), SamplerState::read_datagram(), LVecBase2f::read_datagram(), LVecBase3f::read_datagram(), LVecBase4f::read_datagram(), LMatrix3f::read_datagram(), LMatrix4f::read_datagram(), LVecBase2d::read_datagram(), LVecBase3d::read_datagram(), LVecBase4d::read_datagram(), LVecBase2i::read_datagram(), LVecBase3i::read_datagram(), LVecBase4i::read_datagram(), LMatrix3d::read_datagram(), LMatrix4d::read_datagram(), FFTCompressor::read_reals(), AnimChannelScalarTable::write_datagram(), UvScrollNode::write_datagram(), AlphaTestAttrib::write_datagram(), UserVertexSlider::write_datagram(), AudioVolumeAttrib::write_datagram(), AnimChannelMatrixXfmTable::write_datagram(), CollisionParabola::write_datagram(), LightRampAttrib::write_datagram(), BillboardEffect::write_datagram(), RenderModeAttrib::write_datagram(), DepthOffsetAttrib::write_datagram(), CollisionSphere::write_datagram(), Fog::write_datagram(), CollisionFloorMesh::write_datagram(), Material::write_datagram(), CollisionTube::write_datagram(), PolylightNode::write_datagram(), CollisionBox::write_datagram(), and Lens::write_datagram().

◆ get_string()

string DatagramIterator::get_string ( )

◆ get_string32()

string DatagramIterator::get_string32 ( )

Extracts a variable-length string with a 32-bit length field.

Definition at line 48 of file datagramIterator.cxx.

References Datagram::get_data(), get_uint32(), and get_z_string().

Referenced by get_string().

◆ get_uint16()

PN_uint16 DatagramIterator::get_uint16 ( )
inline

Extracts an unsigned 16-bit integer.

Definition at line 197 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), and get_uint32().

Referenced by DataNodeTransmit::complete_pointers(), PartBundleNode::complete_pointers(), OccluderNode::complete_pointers(), CollisionNode::complete_pointers(), TransformTable::complete_pointers(), TexMatrixAttrib::complete_pointers(), SliderTable::complete_pointers(), TexProjectorEffect::complete_pointers(), TexGenAttrib::complete_pointers(), TransformBlendTable::complete_pointers(), Character::complete_pointers(), TextureAttrib::complete_pointers(), PStatServerControlMessage::decode(), PStatClientControlMessage::decode(), GeomVertexData::CacheEntry::evict_callback(), Geom::CacheEntry::evict_callback(), TimedCycle::fillin(), ButtonEventList::fillin(), GeomVertexAnimationSpec::fillin(), ComputeNode::Dispatcher::CData::fillin(), GeomVertexColumn::fillin(), TransformBlend::fillin(), LightAttrib::finalize(), RenderEffects::finalize(), GeomNode::finalize(), RenderState::finalize(), FFTCompressor::free_storage(), DatagramUDPHeader::get_datagram_checksum(), DatagramTCPHeader::get_datagram_size(), get_int64(), PStatReader::get_monitor(), get_string(), get_wstring(), BamReader::init(), AnimPreloadTable::make_from_bam(), DCClass::output(), PStatFrameData::read_datagram(), ButtonEvent::read_datagram(), BamReader::read_handle(), BamReader::register_pta(), OccluderEffect::require_fully_complete(), ClipPlaneAttrib::require_fully_complete(), AnimGroup::write(), GeomPatches::write_datagram(), AnimChannelBase::write_datagram(), AnimChannelScalarTable::write_datagram(), RecorderTable::write_datagram(), ModelNode::write_datagram(), AntialiasAttrib::write_datagram(), AnimChannelMatrixXfmTable::write_datagram(), ScissorEffect::write_datagram(), CharacterJoint::write_datagram(), CompassEffect::write_datagram(), CollisionFloorMesh::write_datagram(), BamCacheRecord::write_datagram(), PartGroup::write_datagram(), CollisionPolygon::write_datagram(), CollisionBox::write_datagram(), LODNode::write_datagram(), Lens::write_datagram(), and PandaNode::write_recorder().

◆ get_uint32()

PN_uint32 DatagramIterator::get_uint32 ( )
inline

◆ get_uint64()

PN_uint64 DatagramIterator::get_uint64 ( )
inline

Extracts an unsigned 64-bit integer.

Definition at line 239 of file datagramIterator.I.

References Datagram::get_data(), get_float32(), and Datagram::get_length().

Referenced by get_uint32(), and BamCacheRecord::write_datagram().

◆ get_uint8()

PN_uint8 DatagramIterator::get_uint8 ( )
inline

◆ get_wstring()

wstring DatagramIterator::get_wstring ( )

Extracts a variable-length wstring (with a 32-bit length field).

Definition at line 116 of file datagramIterator.cxx.

References extract_bytes(), Datagram::get_length(), get_uint16(), and get_uint32().

Referenced by get_current_index(), and get_fixed_string().

◆ get_z_string()

string DatagramIterator::get_z_string ( )

Extracts a variable-length string, as a NULL-terminated string.

Definition at line 70 of file datagramIterator.cxx.

References Datagram::get_data(), get_fixed_string(), and Datagram::get_length().

Referenced by get_string32().

◆ output()

void DatagramIterator::output ( ostream &  out) const

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

Definition at line 182 of file datagramIterator.cxx.

References write().

Referenced by extract_bytes().

◆ skip_bytes()

void DatagramIterator::skip_bytes ( size_t  size)
inline

◆ write()

void DatagramIterator::write ( ostream &  out,
unsigned int  indent = 0 
) const

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

Definition at line 195 of file datagramIterator.cxx.

References get_datagram(), Datagram::get_length(), and Datagram::write().

Referenced by output().


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