gwnavruntime/blob/blobfileheader.h Source File

blobfileheader.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #pragma once
9 
10 
13 
14 
15 namespace Kaim
16 {
17 
18 class BaseBlobHandler;
19 
20 class BlobFileHeader
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
23 public:
24  static const char* MagicString() { return "BlobFile"; }
25 
26  BlobFileHeader();
27 
28  /* Sets the whole structure to zeros */
29  void Clear();
30 
31  /* Copy memoryBuffer to this and fix the endianness if needed.
32  Typically called when loading a Blob from a buffer or a file. */
33  KyResult InitFromBuffer(void* memoryBuffer, bool& isEndiannessSwap);
34 
35  /* Typically called when saving a Blob to a buffer or a file */
36  void Init(KyUInt32 blobTypeId, KyUInt32 blobTypeVersion, KyUInt32 deepBlobSize, KyUInt32 shallowBlobSize);
37 
38  void Init(const BaseBlobHandler& blobHandler);
39 
40  /* GetEndianness() works even if the endianness of the structure is swapped */
41  Endianness::Type GetEndianness() const;
42 
43  /* Swap endianness in place.
44  After SwapEndianness() is called, all subsequent calls to BlobFileHeader are invalid !
45  Swaps also m_endianness from little to big or big to little */
46  void SwapEndianness();
47 
48 public:
49  char m_magicString[12]; // BlobFile0000
50  KyUInt32 m_endianness;
51  KyUInt32 m_blobTypeId;
52  KyUInt32 m_blobTypeVersion;
53  KyUInt32 m_deepBlobSize;
54  KyUInt32 m_shallowBlobSize;
55 };
56 
57 
58 }
59 
60 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Type
Enumerates possible endianness types.
Definition: endianness.h:20