Sleeping Wombat Common Library  0.50.0
swCommonLibrary
HCF.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "swCommonLib/System/Path.h"
10 
13 
14 #include "Chunk.h"
15 #include "Attribute.h"
16 
17 #include <string>
18 
19 
20 namespace sw
21 {
22 
23 class ImplHCF;
24 
25 
34 class HCF
35 {
36  FRIEND_CLASS_TESTER( HCF );
37 public:
38 
39  enum WriteMode : uint8
40  {
41  DirectToFile,
42  Indirect
43  };
44 
45  const static bool READ_ONLY = true;
46  const static bool READ_WRITE = false;
47  const static Size UserDefinedAttributes = 0xFFFFFFFFFFFF0000;
48 
49 private:
50  ImplHCF m_impl;
51 
52 protected:
53 public:
54  explicit HCF ();
55  ~HCF () = default;
56 
59  bool LoadFile ( const filesystem::Path& filePath, bool readOnly );
60  bool Load ( DataPtr data, Size size );
61 
64  bool WriteFile ( const filesystem::Path& filePath );
65 
68  bool OpenFile ( const filesystem::Path& filePath, WriteMode mode );
70 
71  Chunk GetRootChunk ();
72  Chunk CreateRootChunk ();
73 
76 
77  Attribute AddAttribute ( AttributeType type, const DataPtr data, Size dataSize );
78 
82  template< typename AttributeStruct >
83  Attribute AddAttribute ( AttributeType type, const AttributeStruct& content );
84 
87  template< typename AttributeStruct >
88  Attribute AddAttribute ( const AttributeStruct& content );
90 
91 };
92 
93 
94 
95 } // sw
96 
98 template< typename AttributeStruct >
99 sw::AttributeType GetAttributeTypeID ();
100 
101 
102 #include "HCF.inl"
bool OpenFile(const filesystem::Path &filePath, WriteMode mode)
Opens file for writing. This functions allows to use WriteMode::DirectToFile. If you use Indirect mod...
Definition: HCF.cpp:48
sw::AttributeType GetAttributeTypeID()
Override this funtion for your attribute atructure.
Definition: Path.h:26
Definition: Exception.h:11
Definition: ImplHCF.h:28
bool WriteFile(const filesystem::Path &filePath)
Saves content to file.
Definition: HCF.cpp:41
Represents memory chunk in file.
Definition: Chunk.h:24
Main class for loading and writing HCF files.
Definition: HCF.h:34
Plik zawiera definicje podstawowych typów zmiennych.
Definition: Attribute.h:21
Attribute AddAttribute(AttributeType type, const DataPtr data, Size dataSize)
Adds attribute and fills it with data.
Definition: HCF.cpp:69