Panda3D
physxMemoryReadBuffer.cxx
1 // Filename: physxMemoryReadBuffer.cxx
2 // Created by: enn0x (11Oct09)
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 #include "physxMemoryReadBuffer.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: PhysxMemoryReadBuffer::Constructor
19 // Access: Public
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 PhysxMemoryReadBuffer::PhysxMemoryReadBuffer(const NxU8 *data) : buffer(data)
23 {
24 
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: PhysxMemoryReadBuffer::Destructor
29 // Access: Public
30 // Description:
31 ////////////////////////////////////////////////////////////////////
32 PhysxMemoryReadBuffer::~PhysxMemoryReadBuffer()
33 {
34 
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: PhysxMemoryReadBuffer::readByte
39 // Access: Public
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 NxU8 PhysxMemoryReadBuffer::readByte() const
43 {
44  NxU8 b;
45  memcpy(&b, buffer, sizeof(NxU8));
46  buffer += sizeof(NxU8);
47  return b;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: PhysxMemoryReadBuffer::readWord
52 // Access: Public
53 // Description:
54 ////////////////////////////////////////////////////////////////////
55 NxU16 PhysxMemoryReadBuffer::readWord() const
56 {
57  NxU16 w;
58  memcpy(&w, buffer, sizeof(NxU16));
59  buffer += sizeof(NxU16);
60  return w;
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: PhysxMemoryReadBuffer::readDword
65 // Access: Public
66 // Description:
67 ////////////////////////////////////////////////////////////////////
68 NxU32 PhysxMemoryReadBuffer::readDword() const
69 {
70  NxU32 d;
71  memcpy(&d, buffer, sizeof(NxU32));
72  buffer += sizeof(NxU32);
73  return d;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: PhysxMemoryReadBuffer::readFloat
78 // Access: Public
79 // Description:
80 ////////////////////////////////////////////////////////////////////
81 float PhysxMemoryReadBuffer::readFloat() const
82 {
83  float f;
84  memcpy(&f, buffer, sizeof(float));
85  buffer += sizeof(float);
86  return f;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: PhysxMemoryReadBuffer::readDouble
91 // Access: Public
92 // Description:
93 ////////////////////////////////////////////////////////////////////
94 double PhysxMemoryReadBuffer::readDouble() const
95 {
96  double f;
97  memcpy(&f, buffer, sizeof(double));
98  buffer += sizeof(double);
99  return f;
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: PhysxMemoryReadBuffer::readBuffer
104 // Access: Public
105 // Description:
106 ////////////////////////////////////////////////////////////////////
107 void PhysxMemoryReadBuffer::readBuffer(void *dest, NxU32 size) const
108 {
109  memcpy(dest, buffer, size);
110  buffer += size;
111 }
112