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