Sleeping Wombat Common Library  0.50.0
swCommonLibrary
ImplHCF.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "ChunkRepr.h"
10 #include "AttributeRepr.h"
11 
14 
16 
17 #include "swCommonLib/System/Path.h"
18 
19 
20 #include <stdio.h>
21 
22 
23 
24 namespace sw
25 {
26 
28 class ImplHCF
29 {
30  FRIEND_CLASS_TESTER( HCF );
31  FRIEND_CLASS_TESTER( ImplHCF );
32 private:
33 
34  FileHeader m_header;
35 
36  ChunkReprPtr m_rootChunk;
37  AttributeReprPtr m_fileAttributes;
38 
39  // File related things.
40  FILE* m_file;
41  Size m_writePtr;
42 
43 public:
44 
45  bool m_directWrite : 1;
46  bool m_attributesWritten : 1;
47  bool m_fileReadOnly : 1;
48 
49 protected:
50 public:
51  explicit ImplHCF ();
52  ~ImplHCF ();
53 
54 
55  Chunk GetRootChunk ();
56  Chunk CreateRootChunk ();
57 
58  bool OpenFile ( const filesystem::Path& filePath, bool writeDirect );
59  bool WriteFile ( const filesystem::Path& filePath );
60  bool LoadFile ( const filesystem::Path& filePath, bool readOnly );
61 
62  Attribute AddGlobalAttribute ( AttributeType type, const DataPtr data, Size dataSize );
63  Attribute AddAttribute ( AttributeReprPtr& list, AttributeType type, const DataPtr data, Size dataSize );
64 
65 public:
66  // Internal implementation
67  Size ComputeWholeSize ( Attribute attrib );
68 
69  Size ReserveMemory ( Size dataSize );
70  FILE* GetFile () { return m_file; }
71 
72  bool CanAddGlobalAttrib () const;
73 };
74 
75 
76 } // sw
Definition: Path.h:26
Definition: Exception.h:11
Definition: ImplHCF.h:28
Represents memory chunk in file.
Definition: Chunk.h:24
Main class for loading and writing HCF files.
Definition: HCF.h:34
ChunkReprPtr m_rootChunk
Main Chunk.
Definition: ImplHCF.h:36
AttributeReprPtr m_fileAttributes
Top level attributes.
Definition: ImplHCF.h:37
Definition: Attribute.h:21
Hierarchical Chunked Format file header.
Definition: FileHeader.h:19