Bullet Collision Detection & Physics Library
bChunk.cpp
Go to the documentation of this file.
1 /*
2 bParse
3 Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #include "bChunk.h"
17 #include "bDefines.h"
18 #include "bFile.h"
19 
20 #if !defined(__CELLOS_LV2__) && !defined(__MWERKS__)
21 #include <memory.h>
22 #endif
23 #include <string.h>
24 
25 using namespace bParse;
26 
27 // ----------------------------------------------------- //
28 short ChunkUtils::swapShort(short sht)
29 {
30  SWITCH_SHORT(sht);
31  return sht;
32 }
33 
34 // ----------------------------------------------------- //
35 int ChunkUtils::swapInt(int inte)
36 {
37  SWITCH_INT(inte);
38  return inte;
39 }
40 
41 // ----------------------------------------------------- //
43 {
44  SWITCH_LONGINT(lng);
45  return lng;
46 }
47 
48 // ----------------------------------------------------- //
49 int ChunkUtils::getOffset(int flags)
50 {
51  // if the file is saved in a
52  // different format, get the
53  // file's chunk size
54  int res = CHUNK_HEADER_LEN;
55 
56  if (VOID_IS_8)
57  {
58  if (flags & FD_BITS_VARIES)
59  res = sizeof(bChunkPtr4);
60  }
61  else
62  {
63  if (flags & FD_BITS_VARIES)
64  res = sizeof(bChunkPtr8);
65  }
66  return res;
67 }
68 
69 //eof
#define long64
Definition: bChunk.h:20
#define SWITCH_SHORT(a)
Definition: bDefines.h:124
#define SWITCH_LONGINT(a)
Definition: bDefines.h:134
#define SWITCH_INT(a)
Definition: bDefines.h:111
static int getOffset(int flags)
Definition: bChunk.cpp:49
static short swapShort(short sht)
Definition: bChunk.cpp:28
static int swapInt(int inte)
Definition: bChunk.cpp:35
static long64 swapLong64(long64 lng)
Definition: bChunk.cpp:42
const bool VOID_IS_8
Definition: bChunk.h:81
@ FD_BITS_VARIES
Definition: bFile.h:33
const int CHUNK_HEADER_LEN
Definition: bChunk.h:80