Panda3D
physxMemoryReadBuffer.cxx
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 physxMemoryReadBuffer.cxx
10  * @author enn0x
11  * @date 2009-10-11
12  */
13 
14 #include "physxMemoryReadBuffer.h"
15 
16 /**
17  *
18  */
19 PhysxMemoryReadBuffer::PhysxMemoryReadBuffer(const NxU8 *data) : buffer(data)
20 {
21 
22 }
23 
24 /**
25  *
26  */
27 PhysxMemoryReadBuffer::~PhysxMemoryReadBuffer()
28 {
29 
30 }
31 
32 /**
33  *
34  */
35 NxU8 PhysxMemoryReadBuffer::readByte() const
36 {
37  NxU8 b;
38  memcpy(&b, buffer, sizeof(NxU8));
39  buffer += sizeof(NxU8);
40  return b;
41 }
42 
43 /**
44  *
45  */
46 NxU16 PhysxMemoryReadBuffer::readWord() const
47 {
48  NxU16 w;
49  memcpy(&w, buffer, sizeof(NxU16));
50  buffer += sizeof(NxU16);
51  return w;
52 }
53 
54 /**
55  *
56  */
57 NxU32 PhysxMemoryReadBuffer::readDword() const
58 {
59  NxU32 d;
60  memcpy(&d, buffer, sizeof(NxU32));
61  buffer += sizeof(NxU32);
62  return d;
63 }
64 
65 /**
66  *
67  */
68 float PhysxMemoryReadBuffer::readFloat() const
69 {
70  float f;
71  memcpy(&f, buffer, sizeof(float));
72  buffer += sizeof(float);
73  return f;
74 }
75 
76 /**
77  *
78  */
79 double PhysxMemoryReadBuffer::readDouble() const
80 {
81  double f;
82  memcpy(&f, buffer, sizeof(double));
83  buffer += sizeof(double);
84  return f;
85 }
86 
87 /**
88  *
89  */
90 void PhysxMemoryReadBuffer::readBuffer(void *dest, NxU32 size) const
91 {
92  memcpy(dest, buffer, size);
93  buffer += size;
94 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.