Panda3D
reversedNumericData.I
1 // Filename: reversedNumericData.I
2 // Created by: drose (09May01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ReversedNumericData::Constructor
18 // Access: Public
19 // Description: This constructor accepts the address of a numeric
20 // variable, and its sizeof.
21 ////////////////////////////////////////////////////////////////////
23 ReversedNumericData(const void *data, size_t length) {
24  reverse_assign((const char *)data, length);
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: ReversedNumericData::Constructor
29 // Access: Public
30 // Description: This constructor accepts a pointer to a data array
31 // containing a packed numeric value, the offset within
32 // the array at which the numeric value starts, and the
33 // size of the numeric value.
34 //
35 // It is essential that the array not be destructed or
36 // modified as long as the NumericData object remains;
37 // it may just store a pointer into that string's
38 // internal buffer.
39 ////////////////////////////////////////////////////////////////////
41 ReversedNumericData(const void *data, size_t start, size_t length) {
42  reverse_assign((const char *)data + start, length);
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: ReversedNumericData::store_value
47 // Access: Public
48 // Description: Copies the data, with byte reversal if appropriate,
49 // into the indicated numeric variable, whose address
50 // and sizeof are given.
51 ////////////////////////////////////////////////////////////////////
52 INLINE void ReversedNumericData::
53 store_value(void *dest, size_t length) const {
54  memcpy(dest, _data, length);
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: ReversedNumericData::get_data
59 // Access: Public
60 // Description: Returns the pointer to the first byte of the data,
61 // either reversed or nonreversed, as appropriate.
62 ////////////////////////////////////////////////////////////////////
63 INLINE const void *ReversedNumericData::
64 get_data() const {
65  return _data;
66 }
ReversedNumericData(const void *data, size_t length)
This constructor accepts the address of a numeric variable, and its sizeof.
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.
void store_value(void *dest, size_t length) const
Copies the data, with byte reversal if appropriate, into the indicated numeric variable, whose address and sizeof are given.