Panda3D
Public Member Functions | List of all members
ReversedNumericData Class Reference

NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatically byte-swapping numbers, when necessary, to transparency support big-endian and little-endian architectures. More...

#include "reversedNumericData.h"

Public Member Functions

 ReversedNumericData (const void *data, size_t length)
 This constructor accepts the address of a numeric variable, and its sizeof. More...
 
 ReversedNumericData (const void *data, size_t start, size_t length)
 This constructor accepts a pointer to a data array containing a packed numeric value, the offset within the array at which the numeric value starts, and the size of the numeric value. More...
 
const void * get_data () const
 Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate. More...
 
void store_value (void *dest, size_t length) const
 Copies the data, with byte reversal if appropriate, into the indicated numeric variable, whose address and sizeof are given. More...
 

Detailed Description

NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatically byte-swapping numbers, when necessary, to transparency support big-endian and little-endian architectures.

Both of these classes provide interfaces that accept a pointer to a numeric variable and the size of the number, and they can append that data to the end of a string, or memcpy it into another location.

The difference is that NativeNumericData simply passes everything through unchanged, while ReversedNumericData always byte-swaps everything. Otherwise, they have the same interface.

The transparent part comes from LittleEndian and BigEndian, which are typedeffed to be one of these or the other, according to the machine's architecture.

Definition at line 42 of file reversedNumericData.h.

Constructor & Destructor Documentation

◆ ReversedNumericData() [1/2]

ReversedNumericData::ReversedNumericData ( const void *  data,
size_t  length 
)
inline

This constructor accepts the address of a numeric variable, and its sizeof.

Definition at line 18 of file reversedNumericData.I.

◆ ReversedNumericData() [2/2]

ReversedNumericData::ReversedNumericData ( const void *  data,
size_t  start,
size_t  length 
)
inline

This constructor accepts a pointer to a data array containing a packed numeric value, the offset within the array at which the numeric value starts, and the size of the numeric value.

It is essential that the array not be destructed or modified as long as the NumericData object remains; it may just store a pointer into that string's internal buffer.

Definition at line 32 of file reversedNumericData.I.

Member Function Documentation

◆ get_data()

const void * ReversedNumericData::get_data ( ) const
inline

◆ store_value()

void ReversedNumericData::store_value ( void *  dest,
size_t  length 
) const
inline

Copies the data, with byte reversal if appropriate, into the indicated numeric variable, whose address and sizeof are given.

Definition at line 41 of file reversedNumericData.I.

Referenced by StreamReader::get_be_float64(), StreamReader::get_be_int16(), StreamReader::get_be_int32(), StreamReader::get_be_int64(), StreamReader::get_be_uint16(), StreamReader::get_be_uint32(), and StreamReader::get_be_uint64().


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