Panda3D
Loading...
Searching...
No Matches
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)
 
void assign (Datagram &datagram, size_t offset=0)
 direct Assignment to a Datagram
 
vector_uchar extract_bytes (size_t size)
 Extracts the indicated number of bytes in the datagram and returns them as a string.
 
size_t extract_bytes (unsigned char *into, size_t size)
 Extracts the indicated number of bytes in the datagram into the given character buffer.
 
PN_float32 get_be_float32 ()
 Extracts a 32-bit big-endian single-precision floating-point number.
 
PN_float64 get_be_float64 ()
 Extracts a 64-bit big-endian floating-point number.
 
int16_t get_be_int16 ()
 Extracts a signed 16-bit big-endian integer.
 
int32_t get_be_int32 ()
 Extracts a signed 32-bit big-endian integer.
 
int64_t get_be_int64 ()
 Extracts a signed 64-bit big-endian integer.
 
uint16_t get_be_uint16 ()
 Extracts an unsigned 16-bit big-endian integer.
 
uint32_t get_be_uint32 ()
 Extracts an unsigned 32-bit big-endian integer.
 
uint64_t get_be_uint64 ()
 Extracts an unsigned 64-bit big-endian integer.
 
vector_uchar get_blob ()
 Extracts a variable-length binary blob.
 
vector_uchar get_blob32 ()
 Extracts a variable-length binary blob with a 32-bit size field.
 
bool get_bool ()
 Extracts a boolean value.
 
size_t get_current_index () const
 Returns the current position within the datagram of the next piece of data to extract.
 
const Datagramget_datagram () const
 Return the datagram of this iterator.
 
std::string get_fixed_string (size_t size)
 Extracts a fixed-length string.
 
PN_float32 get_float32 ()
 Extracts a 32-bit single-precision floating-point number.
 
PN_float64 get_float64 ()
 Extracts a 64-bit floating-point number.
 
int16_t get_int16 ()
 Extracts a signed 16-bit integer.
 
int32_t get_int32 ()
 Extracts a signed 32-bit integer.
 
int64_t get_int64 ()
 Extracts a signed 64-bit integer.
 
int8_t get_int8 ()
 Extracts a signed 8-bit integer.
 
vector_uchar get_remaining_bytes () const
 Returns the remaining bytes in the datagram as a string, but does not extract them from the iterator.
 
size_t get_remaining_size () const
 Return the bytes left in the datagram.
 
PN_stdfloat get_stdfloat ()
 Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_double().
 
std::string get_string ()
 Extracts a variable-length string.
 
std::string get_string32 ()
 Extracts a variable-length string with a 32-bit length field.
 
uint16_t get_uint16 ()
 Extracts an unsigned 16-bit integer.
 
uint32_t get_uint32 ()
 Extracts an unsigned 32-bit integer.
 
uint64_t get_uint64 ()
 Extracts an unsigned 64-bit integer.
 
uint8_t get_uint8 ()
 Extracts an unsigned 8-bit integer.
 
std::wstring get_wstring ()
 Extracts a variable-length wstring (with a 32-bit length field).
 
std::string get_z_string ()
 Extracts a variable-length string, as a NULL-terminated string.
 
void output (std::ostream &out) const
 Write a string representation of this instance to <out>.
 
void skip_bytes (size_t size)
 Skips over the indicated number of bytes in the datagram.
 
void write (std::ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>.
 

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.

Note that it is the responsibility of the caller to ensure that the datagram object is not destructed while this DatagramIterator is in use.

Definition at line 30 of file datagramIterator.h.

Constructor & Destructor Documentation

◆ DatagramIterator() [1/2]

DatagramIterator::DatagramIterator ( )
inline

Definition at line 17 of file datagramIterator.I.

◆ DatagramIterator() [2/2]

DatagramIterator::DatagramIterator ( const Datagram & datagram,
size_t offset = 0 )
inline

Definition at line 26 of file datagramIterator.I.

Member Function Documentation

◆ assign()

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

direct Assignment to a Datagram

Definition at line 36 of file datagramIterator.I.

◆ extract_bytes() [1/2]

vector_uchar DatagramIterator::extract_bytes ( size_t size)

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

Definition at line 125 of file datagramIterator.cxx.

References Datagram::get_data().

Referenced by get_blob(), and get_blob32().

◆ 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 145 of file datagramIterator.cxx.

References Datagram::get_data().

◆ get_be_float32()

PN_float32 DatagramIterator::get_be_float32 ( )
inline

Extracts a 32-bit big-endian single-precision floating-point number.

Definition at line 368 of file datagramIterator.I.

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

Referenced by FltMaterial::extract_14_record(), FltLocalVertexPool::extract_record(), and IffInputFile::get_be_float32().

◆ get_be_float64()

PN_float64 DatagramIterator::get_be_float64 ( )
inline

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

Definition at line 387 of file datagramIterator.I.

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

Referenced by FltLocalVertexPool::extract_record().

◆ get_be_int16()

int16_t DatagramIterator::get_be_int16 ( )
inline

Extracts a signed 16-bit big-endian integer.

Definition at line 254 of file datagramIterator.I.

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

Referenced by IffInputFile::get_be_int16().

◆ get_be_int32()

int32_t DatagramIterator::get_be_int32 ( )
inline

Extracts a signed 32-bit big-endian integer.

Definition at line 273 of file datagramIterator.I.

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

Referenced by FltLocalVertexPool::extract_record(), and IffInputFile::get_be_int32().

◆ get_be_int64()

int64_t DatagramIterator::get_be_int64 ( )
inline

Extracts a signed 64-bit big-endian integer.

Definition at line 292 of file datagramIterator.I.

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

◆ get_be_uint16()

uint16_t DatagramIterator::get_be_uint16 ( )
inline

Extracts an unsigned 16-bit big-endian integer.

Definition at line 311 of file datagramIterator.I.

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

Referenced by IffInputFile::get_be_uint16().

◆ get_be_uint32()

uint32_t DatagramIterator::get_be_uint32 ( )
inline

Extracts an unsigned 32-bit big-endian integer.

Definition at line 330 of file datagramIterator.I.

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

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

◆ get_be_uint64()

uint64_t DatagramIterator::get_be_uint64 ( )
inline

Extracts an unsigned 64-bit big-endian integer.

Definition at line 349 of file datagramIterator.I.

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

◆ get_blob()

vector_uchar DatagramIterator::get_blob ( )
inline

Extracts a variable-length binary blob.

Definition at line 406 of file datagramIterator.I.

References extract_bytes(), and get_uint16().

◆ get_blob32()

vector_uchar DatagramIterator::get_blob32 ( )
inline

Extracts a variable-length binary blob with a 32-bit size field.

Definition at line 414 of file datagramIterator.I.

References extract_bytes(), and get_uint32().

◆ get_bool()

bool DatagramIterator::get_bool ( )
inline

◆ get_class_type()

static TypeHandle DatagramIterator::get_class_type ( )
inlinestatic

Definition at line 88 of file datagramIterator.h.

◆ get_current_index()

size_t DatagramIterator::get_current_index ( ) const
inline

Returns the current position within the datagram of the next piece of data to extract.

Definition at line 470 of file datagramIterator.I.

Referenced by BamReader::init(), and GeomVertexArrayData::read_raw_data().

◆ get_datagram()

const Datagram & DatagramIterator::get_datagram ( ) const
inline

Return the datagram of this iterator.

Definition at line 461 of file datagramIterator.I.

Referenced by FltRecordReader::get_datagram(), GeomVertexArrayData::read_raw_data(), and write().

◆ 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 86 of file datagramIterator.cxx.

References Datagram::get_data().

Referenced by FltMaterial::extract_14_record().

◆ get_float32()

PN_float32 DatagramIterator::get_float32 ( )
inline

◆ get_float64()

PN_float64 DatagramIterator::get_float64 ( )
inline

◆ get_int16()

int16_t DatagramIterator::get_int16 ( )
inline

◆ get_int32()

int32_t DatagramIterator::get_int32 ( )
inline

◆ get_int64()

int64_t DatagramIterator::get_int64 ( )
inline

Extracts a signed 64-bit integer.

Definition at line 125 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), and NativeNumericData::store_value().

◆ get_int8()

int8_t DatagramIterator::get_int8 ( )
inline

Extracts a signed 8-bit integer.

Definition at line 55 of file datagramIterator.I.

References Datagram::get_data().

Referenced by HermiteCurveCV::fillin(), IffInputFile::get_int8(), IffInputFile::get_uint8(), and FFTCompressor::read_header().

◆ get_remaining_bytes()

vector_uchar 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 441 of file datagramIterator.I.

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

◆ get_remaining_size()

size_t DatagramIterator::get_remaining_size ( ) const
inline

◆ get_stdfloat()

PN_stdfloat DatagramIterator::get_stdfloat ( )
inline

◆ 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 44 of file datagramIterator.cxx.

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

◆ get_uint16()

uint16_t DatagramIterator::get_uint16 ( )
inline

◆ get_uint32()

uint32_t DatagramIterator::get_uint32 ( )
inline

◆ get_uint64()

uint64_t DatagramIterator::get_uint64 ( )
inline

Extracts an unsigned 64-bit integer.

Definition at line 182 of file datagramIterator.I.

References Datagram::get_data(), Datagram::get_length(), and NativeNumericData::store_value().

Referenced by CConnectionRepository::check_datagram().

◆ get_uint8()

uint8_t DatagramIterator::get_uint8 ( )
inline

◆ get_wstring()

wstring DatagramIterator::get_wstring ( )

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

Definition at line 103 of file datagramIterator.cxx.

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

◆ get_z_string()

string DatagramIterator::get_z_string ( )

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

Definition at line 63 of file datagramIterator.cxx.

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

◆ init_type()

static void DatagramIterator::init_type ( )
inlinestatic

Definition at line 91 of file datagramIterator.h.

◆ output()

void DatagramIterator::output ( std::ostream & out) const

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

Definition at line 161 of file datagramIterator.cxx.

◆ skip_bytes()

void DatagramIterator::skip_bytes ( size_t size)
inline

Skips over the indicated number of bytes in the datagram.

Definition at line 422 of file datagramIterator.I.

References Datagram::dump_hex(), and Datagram::get_length().

Referenced by FltMaterial::extract_14_record(), and GeomVertexArrayData::read_raw_data().

◆ write()

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

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

Definition at line 171 of file datagramIterator.cxx.

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


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