00001 // Filename: reversedNumericData.I 00002 // Created by: drose (09May01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: ReversedNumericData::Constructor 00022 // Access: Public 00023 // Description: This constructor accepts the address of a numeric 00024 // variable, and its sizeof. 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE ReversedNumericData:: 00027 ReversedNumericData(const void *data, size_t length) { 00028 reverse_assign((const char *)data, length); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: ReversedNumericData::Constructor 00033 // Access: Public 00034 // Description: This constructor accepts a pointer to a data array 00035 // containing a packed numeric value, the offset within 00036 // the array at which the numeric value starts, and the 00037 // size of the numeric value. 00038 // 00039 // It is essential that the array not be destructed or 00040 // modified as long as the NumericData object remains; 00041 // it may just store a pointer into that string's 00042 // internal buffer. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE ReversedNumericData:: 00045 ReversedNumericData(const void *data, size_t start, size_t length) { 00046 reverse_assign((const char *)data + start, length); 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: ReversedNumericData::store_value 00051 // Access: Public 00052 // Description: Copies the data, with byte reversal if appropriate, 00053 // into the indicated numeric variable, whose address 00054 // and sizeof are given. 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE void ReversedNumericData:: 00057 store_value(void *dest, size_t length) const { 00058 memcpy(dest, _data, length); 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: ReversedNumericData::get_data 00063 // Access: Public 00064 // Description: Returns the pointer to the first byte of the data, 00065 // either reversed or nonreversed, as appropriate. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE const void *ReversedNumericData:: 00068 get_data() const { 00069 return _data; 00070 }