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
SWITCH_LONGINT
#define SWITCH_LONGINT(a)
Definition: bDefines.h:134
bParse::ChunkUtils::getOffset
static int getOffset(int flags)
Definition: bChunk.cpp:49
bChunk.h
bParse::ChunkUtils::swapInt
static int swapInt(int inte)
Definition: bChunk.cpp:35
SWITCH_INT
#define SWITCH_INT(a)
Definition: bDefines.h:111
bFile.h
bParse::ChunkUtils::swapLong64
static long64 swapLong64(long64 lng)
Definition: bChunk.cpp:42
bParse::VOID_IS_8
const bool VOID_IS_8
Definition: bChunk.h:81
long64
#define long64
Definition: bChunk.h:20
bParse::bChunkPtr4
Definition: bChunk.h:31
bParse::FD_BITS_VARIES
Definition: bFile.h:33
bParse
Definition: btBulletWorldImporter.h:23
SWITCH_SHORT
#define SWITCH_SHORT(a)
Definition: bDefines.h:124
bParse::bChunkPtr8
Definition: bChunk.h:45
bParse::CHUNK_HEADER_LEN
const int CHUNK_HEADER_LEN
Definition: bChunk.h:80
bParse::ChunkUtils::swapShort
static short swapShort(short sht)
Definition: bChunk.cpp:28
bDefines.h