00001 // Filename: nativeNumericData.h 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 #ifndef NATIVENUMERICDATA_H 00020 #define NATIVENUMERICDATA_H 00021 00022 #include "pandabase.h" 00023 00024 #include <string.h> // for memcpy() 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : NativeNumericData 00028 // Description : NativeNumericData and ReversedNumericData work 00029 // together to provide a sneaky interface for 00030 // automatically byte-swapping numbers, when necessary, 00031 // to transparency support big-endian and little-endian 00032 // architectures. 00033 // 00034 // Both of these classes provide interfaces that accept 00035 // a pointer to a numeric variable and the size of the 00036 // number, and they can append that data to the end of a 00037 // string, or memcpy it into another location. 00038 // 00039 // The difference is that NativeNumericData simply 00040 // passes everything through unchanged, while 00041 // ReversedNumericData always byte-swaps everything. 00042 // Otherwise, they have the same interface. 00043 // 00044 // The transparent part comes from LittleEndian and 00045 // BigEndian, which are typedeffed to be one of these or 00046 // the other, according to the machine's architecture. 00047 //////////////////////////////////////////////////////////////////// 00048 class EXPCL_PANDAEXPRESS NativeNumericData { 00049 public: 00050 INLINE NativeNumericData(const void *data, size_t length); 00051 INLINE NativeNumericData(const void *data, size_t start, size_t length); 00052 00053 INLINE void store_value(void *dest, size_t length) const; 00054 INLINE const void *get_data() const; 00055 00056 private: 00057 const void *_source; 00058 }; 00059 00060 #include "nativeNumericData.I" 00061 00062 #endif