Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

NativeNumericData 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 <nativeNumericData.h>

List of all members.

Public Member Functions

 NativeNumericData (const void *data, size_t length)
 This constructor accepts the address of a numeric variable, and its sizeof.

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

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.

const void * get_data () const
 Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.


Private Attributes

const void * _source


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 72 of file nativeNumericData.h.


Constructor & Destructor Documentation

NativeNumericData::NativeNumericData const void *  data,
size_t  length
[inline]
 

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

Definition at line 34 of file nativeNumericData.I.

References _source, and INLINE.

NativeNumericData::NativeNumericData 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 64 of file nativeNumericData.I.

References _source, and INLINE.


Member Function Documentation

const void * NativeNumericData::get_data  )  const [inline]
 

Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.

Definition at line 96 of file nativeNumericData.I.

Referenced by StreamWriter::add_int16(), Datagram::add_int16(), StreamWriter::add_int32(), Datagram::add_int32(), StreamWriter::add_int8(), Datagram::add_uint32(), StreamWriter::add_uint8(), and Datagram::add_uint8().

void NativeNumericData::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 81 of file nativeNumericData.I.

Referenced by StreamReader::get_bool(), StreamReader::get_int32(), StreamReader::get_int64(), DatagramIterator::get_int64(), StreamReader::get_int8(), StreamReader::get_uint16(), DatagramIterator::get_uint16(), StreamReader::get_uint32(), DatagramIterator::get_uint32(), DatagramIterator::get_uint64(), and StreamReader::get_uint8().


Member Data Documentation

const void* NativeNumericData::_source [private]
 

Definition at line 81 of file nativeNumericData.h.

Referenced by NativeNumericData().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:31 2003 for Panda by doxygen1.3