b3Chunk.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. bParse
  3. Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef __BCHUNK_H__
  14. #define __BCHUNK_H__
  15. #if defined(_WIN32) && !defined(__MINGW32__)
  16. #define b3Long64 __int64
  17. #elif defined(__MINGW32__)
  18. #include <stdint.h>
  19. #define b3Long64 int64_t
  20. #else
  21. #define b3Long64 long long
  22. #endif
  23. namespace bParse
  24. {
  25. // ----------------------------------------------------- //
  26. class bChunkPtr4
  27. {
  28. public:
  29. bChunkPtr4() {}
  30. int code;
  31. int len;
  32. union {
  33. int m_uniqueInt;
  34. };
  35. int dna_nr;
  36. int nr;
  37. };
  38. // ----------------------------------------------------- //
  39. class bChunkPtr8
  40. {
  41. public:
  42. bChunkPtr8() {}
  43. int code, len;
  44. union {
  45. b3Long64 oldPrev;
  46. int m_uniqueInts[2];
  47. };
  48. int dna_nr, nr;
  49. };
  50. // ----------------------------------------------------- //
  51. class bChunkInd
  52. {
  53. public:
  54. bChunkInd() {}
  55. int code, len;
  56. void *oldPtr;
  57. int dna_nr, nr;
  58. };
  59. // ----------------------------------------------------- //
  60. class ChunkUtils
  61. {
  62. public:
  63. // file chunk offset
  64. static int getOffset(int flags);
  65. // endian utils
  66. static short swapShort(short sht);
  67. static int swapInt(int inte);
  68. static b3Long64 swapLong64(b3Long64 lng);
  69. };
  70. const int CHUNK_HEADER_LEN = ((sizeof(bChunkInd)));
  71. const bool VOID_IS_8 = ((sizeof(void *) == 8));
  72. } // namespace bParse
  73. #endif //__BCHUNK_H__