Panda3D
nativeNumericData.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file nativeNumericData.h
10  * @author drose
11  * @date 2001-05-09
12  */
13 
14 #ifndef NATIVENUMERICDATA_H
15 #define NATIVENUMERICDATA_H
16 
17 #include "dtoolbase.h"
18 #include "numeric_types.h"
19 
20 #include <string.h> // for memcpy()
21 
22 /**
23  * NativeNumericData and ReversedNumericData work together to provide a sneaky
24  * interface for automatically byte-swapping numbers, when necessary, to
25  * transparency support big-endian and little-endian architectures.
26  *
27  * Both of these classes provide interfaces that accept a pointer to a numeric
28  * variable and the size of the number, and they can append that data to the
29  * end of a string, or memcpy it into another location.
30  *
31  * The difference is that NativeNumericData simply passes everything through
32  * unchanged, while ReversedNumericData always byte-swaps everything.
33  * Otherwise, they have the same interface.
34  *
35  * The transparent part comes from LittleEndian and BigEndian, which are
36  * typedeffed to be one of these or the other, according to the machine's
37  * architecture.
38  */
39 class EXPCL_DTOOL_PRC NativeNumericData {
40 public:
41  INLINE NativeNumericData(const void *data, size_t length);
42  INLINE NativeNumericData(const void *data, size_t start, size_t length);
43 
44  INLINE void store_value(void *dest, size_t length) const;
45  INLINE const void *get_data() const;
46 
47 private:
48  const void *_source;
49 };
50 
51 #include "nativeNumericData.I"
52 
53 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.