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 More... | |
vector_uchar | 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... | |
int16_t | get_be_int16 () |
Extracts a signed 16-bit big-endian integer. More... | |
int32_t | get_be_int32 () |
Extracts a signed 32-bit big-endian integer. More... | |
int64_t | get_be_int64 () |
Extracts a signed 64-bit big-endian integer. More... | |
uint16_t | get_be_uint16 () |
Extracts an unsigned 16-bit big-endian integer. More... | |
uint32_t | get_be_uint32 () |
Extracts an unsigned 32-bit big-endian integer. More... | |
uint64_t | get_be_uint64 () |
Extracts an unsigned 64-bit big-endian integer. More... | |
vector_uchar | get_blob () |
Extracts a variable-length binary blob. More... | |
vector_uchar | get_blob32 () |
Extracts a variable-length binary blob with a 32-bit size field. 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 Datagram & | get_datagram () const |
Return the datagram of this iterator. More... | |
std::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... | |
int16_t | get_int16 () |
Extracts a signed 16-bit integer. More... | |
int32_t | get_int32 () |
Extracts a signed 32-bit integer. More... | |
int64_t | get_int64 () |
Extracts a signed 64-bit integer. More... | |
int8_t | get_int8 () |
Extracts a signed 8-bit integer. More... | |
vector_uchar | get_remaining_bytes () const |
Returns the remaining bytes in the datagram as a string, but does not extract them from the iterator. More... | |
size_t | 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... | |
std::string | get_string () |
Extracts a variable-length string. More... | |
std::string | get_string32 () |
Extracts a variable-length string with a 32-bit length field. More... | |
uint16_t | get_uint16 () |
Extracts an unsigned 16-bit integer. More... | |
uint32_t | get_uint32 () |
Extracts an unsigned 32-bit integer. More... | |
uint64_t | get_uint64 () |
Extracts an unsigned 64-bit integer. More... | |
uint8_t | get_uint8 () |
Extracts an unsigned 8-bit integer. More... | |
std::wstring | get_wstring () |
Extracts a variable-length wstring (with a 32-bit length field). More... | |
std::string | get_z_string () |
Extracts a variable-length string, as a NULL-terminated string. More... | |
void | output (std::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 (std::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 () |
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 27 of file datagramIterator.h.
|
inline |
direct Assignment to a Datagram
Definition at line 37 of file datagramIterator.I.
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 126 of file datagramIterator.cxx.
Referenced by get_blob(), and get_blob32().
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 146 of file datagramIterator.cxx.
|
inline |
Extracts a 32-bit big-endian single-precision floating-point number.
Definition at line 369 of file datagramIterator.I.
Referenced by FltMaterial::extract_14_record(), and IffInputFile::get_be_float32().
|
inline |
Extracts a 64-bit big-endian floating-point number.
Definition at line 388 of file datagramIterator.I.
|
inline |
Extracts a signed 16-bit big-endian integer.
Definition at line 255 of file datagramIterator.I.
Referenced by IffInputFile::get_be_int16().
|
inline |
Extracts a signed 32-bit big-endian integer.
Definition at line 274 of file datagramIterator.I.
Referenced by IffInputFile::get_be_int32().
|
inline |
Extracts a signed 64-bit big-endian integer.
Definition at line 293 of file datagramIterator.I.
|
inline |
Extracts an unsigned 16-bit big-endian integer.
Definition at line 312 of file datagramIterator.I.
Referenced by IffInputFile::get_be_uint16().
|
inline |
Extracts an unsigned 32-bit big-endian integer.
Definition at line 331 of file datagramIterator.I.
Referenced by FltMaterial::extract_14_record(), and IffInputFile::get_be_uint32().
|
inline |
Extracts an unsigned 64-bit big-endian integer.
Definition at line 350 of file datagramIterator.I.
|
inline |
Extracts a variable-length binary blob.
Definition at line 407 of file datagramIterator.I.
References extract_bytes(), and get_uint16().
|
inline |
Extracts a variable-length binary blob with a 32-bit size field.
Definition at line 415 of file datagramIterator.I.
References extract_bytes(), and get_uint32().
|
inline |
Extracts a boolean value.
Definition at line 48 of file datagramIterator.I.
References get_uint8().
Referenced by GeomVertexAnimationSpec::fillin(), TextureProperties::fillin(), and TextureStage::make_TextureStage().
|
inline |
Returns the current position within the datagram of the next piece of data to extract.
Definition at line 471 of file datagramIterator.I.
|
inline |
Return the datagram of this iterator.
Definition at line 462 of file datagramIterator.I.
Referenced by write().
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 87 of file datagramIterator.cxx.
Referenced by FltMaterial::extract_14_record().
|
inline |
Extracts a 32-bit single-precision floating-point number.
Definition at line 202 of file datagramIterator.I.
Referenced by PStatCollectorDef::read_datagram().
|
inline |
Extracts a 64-bit floating-point number.
Definition at line 221 of file datagramIterator.I.
Referenced by TexturePosition::fillin(), and FFTCompressor::read_header().
|
inline |
Extracts a signed 16-bit integer.
Definition at line 88 of file datagramIterator.I.
Referenced by PStatCollectorDef::read_datagram(), and SamplerState::read_datagram().
|
inline |
Extracts a signed 32-bit integer.
Definition at line 107 of file datagramIterator.I.
Referenced by TexturePosition::fillin(), PaletteGroups::fillin(), TextureProperties::fillin(), DownloadDb::Db::parse_header(), DownloadDb::Db::parse_record_header(), and FFTCompressor::read_reals().
|
inline |
Extracts a signed 64-bit integer.
Definition at line 126 of file datagramIterator.I.
|
inline |
Extracts a signed 8-bit integer.
Definition at line 56 of file datagramIterator.I.
Referenced by HermiteCurveCV::fillin(), IffInputFile::get_int8(), IffInputFile::get_uint8(), and FFTCompressor::read_header().
|
inline |
Returns the remaining bytes in the datagram as a string, but does not extract them from the iterator.
Definition at line 442 of file datagramIterator.I.
|
inline |
Return the bytes left in the datagram.
Definition at line 454 of file datagramIterator.I.
References Datagram::get_length().
Referenced by FltRecord::check_remaining_size(), and PStatClientControlMessage::decode().
|
inline |
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_double().
Definition at line 242 of file datagramIterator.I.
Referenced by TimedCycle::fillin(), STTransform::fillin(), AnimChannelScalarDynamic::fillin(), and SamplerState::read_datagram().
string DatagramIterator::get_string | ( | ) |
Extracts a variable-length string.
Definition at line 26 of file datagramIterator.cxx.
References get_uint16().
Referenced by PStatServerControlMessage::decode(), PStatClientControlMessage::decode(), HermiteCurveCV::fillin(), SpeedTreeNode::InstanceList::fillin(), PStatCollectorDef::read_datagram(), ButtonEvent::read_datagram(), Shader::ShaderFile::read_datagram(), and BamReader::read_handle().
string DatagramIterator::get_string32 | ( | ) |
Extracts a variable-length string with a 32-bit length field.
Definition at line 45 of file datagramIterator.cxx.
References get_uint32().
|
inline |
Extracts an unsigned 16-bit integer.
Definition at line 145 of file datagramIterator.I.
Referenced by PStatServerControlMessage::decode(), PStatClientControlMessage::decode(), TimedCycle::fillin(), ButtonEventList::fillin(), GeomVertexAnimationSpec::fillin(), ComputeNode::Dispatcher::CData::fillin(), TransformBlend::fillin(), get_blob(), DatagramUDPHeader::get_datagram_checksum(), get_string(), ButtonEvent::read_datagram(), and BamReader::read_handle().
|
inline |
Extracts an unsigned 32-bit integer.
Definition at line 164 of file datagramIterator.I.
Referenced by get_blob32(), get_string32(), get_wstring(), DownloadDb::Db::parse_header(), BitArray::read_datagram(), SparseArray::read_datagram(), Shader::ShaderPtrData::read_datagram(), and GeomVertexArrayData::read_raw_data().
|
inline |
Extracts an unsigned 64-bit integer.
Definition at line 183 of file datagramIterator.I.
|
inline |
Extracts an unsigned 8-bit integer.
Definition at line 72 of file datagramIterator.I.
Referenced by PStatServerControlMessage::decode(), PStatClientControlMessage::decode(), GeomVertexAnimationSpec::fillin(), GeomVertexColumn::fillin(), get_bool(), ButtonEvent::read_datagram(), SamplerState::read_datagram(), Shader::ShaderPtrData::read_datagram(), Shader::ShaderFile::read_datagram(), and BamReader::read_handle().
wstring DatagramIterator::get_wstring | ( | ) |
Extracts a variable-length wstring (with a 32-bit length field).
Definition at line 104 of file datagramIterator.cxx.
References get_uint32().
string DatagramIterator::get_z_string | ( | ) |
Extracts a variable-length string, as a NULL-terminated string.
Definition at line 64 of file datagramIterator.cxx.
void DatagramIterator::output | ( | std::ostream & | out | ) | const |
Write a string representation of this instance to <out>.
Definition at line 162 of file datagramIterator.cxx.
|
inline |
Skips over the indicated number of bytes in the datagram.
Definition at line 423 of file datagramIterator.I.
Referenced by FltMaterial::extract_14_record().
void DatagramIterator::write | ( | std::ostream & | out, |
unsigned int | indent = 0 |
||
) | const |
Write a string representation of this instance to <out>.
Definition at line 172 of file datagramIterator.cxx.
References get_datagram(), Datagram::get_length(), indent(), and Datagram::write().