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