DatagramIterator

class DatagramIterator

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.

Inheritance diagram

Inheritance diagram of DatagramIterator

DatagramIterator(void)
DatagramIterator(Datagram const &datagram, std::size_t offset = 0)
DatagramIterator(DatagramIterator const&) = default
vector_uchar extract_bytes(std::size_t size)
std::size_t extract_bytes(unsigned char *into, std::size_t size)

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

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.

PN_float32 get_be_float32(void)

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

PN_float64 get_be_float64(void)

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

int16_t get_be_int16(void)

Extracts a signed 16-bit big-endian integer.

int32_t get_be_int32(void)

Extracts a signed 32-bit big-endian integer.

int64_t get_be_int64(void)

Extracts a signed 64-bit big-endian integer.

uint16_t get_be_uint16(void)

Extracts an unsigned 16-bit big-endian integer.

uint32_t get_be_uint32(void)

Extracts an unsigned 32-bit big-endian integer.

uint64_t get_be_uint64(void)

Extracts an unsigned 64-bit big-endian integer.

vector_uchar get_blob(void)

Extracts a variable-length binary blob.

vector_uchar get_blob32(void)

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

bool get_bool(void)

Extracts a boolean value.

static TypeHandle get_class_type(void)
std::size_t get_current_index(void) const

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

Datagram const &get_datagram(void) const

Return the datagram of this iterator.

std::string get_fixed_string(std::size_t size)

Extracts a fixed-length string. However, if a zero byte occurs within the string, it marks the end of the string.

PN_float32 get_float32(void)

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

PN_float64 get_float64(void)

Extracts a 64-bit floating-point number.

int16_t get_int16(void)

Extracts a signed 16-bit integer.

int32_t get_int32(void)

Extracts a signed 32-bit integer.

int64_t get_int64(void)

Extracts a signed 64-bit integer.

int8_t get_int8(void)

Extracts a signed 8-bit integer.

vector_uchar get_remaining_bytes(void) const

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

std::size_t get_remaining_size(void) const

Return the bytes left in the datagram.

PN_stdfloat get_stdfloat(void)

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

std::string get_string(void)

Extracts a variable-length string.

std::string get_string32(void)

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

uint16_t get_uint16(void)

Extracts an unsigned 16-bit integer.

uint32_t get_uint32(void)

Extracts an unsigned 32-bit integer.

uint64_t get_uint64(void)

Extracts an unsigned 64-bit integer.

uint8_t get_uint8(void)

Extracts an unsigned 8-bit integer.

std::wstring get_wstring(void)

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

std::string get_z_string(void)

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

int16_t peek_int16(void)

Extracts a signed 16-bit integer without advancing the iterator.

uint16_t peek_uint16(void)

Extracts an unsigned 16-bit integer without advancing the iterator.

void skip_bytes(std::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>.