Sleeping Wombat Common Library  0.50.0
swCommonLibrary
TesterHCF.h
1 #pragma once
2 
4 
6 
7 
8 
9 namespace sw
10 {
11 
12 
13 class CLASS_TESTER( HCF )
14 {
15 private:
16 public:
17 
18  static bool ValidateStreamPos ( sw::HCF* hcf, sw::Chunk& chunk );
19  static bool ValidateStreamPos ( sw::HCF* hcf, sw::Attribute& attrib );
20 };
21 
22 
23 // ================================ //
24 //
25 inline bool CLASS_TESTER( HCF )::ValidateStreamPos ( sw::HCF* hcf, sw::Chunk& chunk )
26 {
27  auto file = hcf->m_impl.GetFile();
28  if( file == nullptr )
29  return false;
30 
31  Size position = ftell( file );
32 
33  Size chunkOffset = chunk.m_chunkPtr->m_absolutOffset;
34  Size dataOffset = chunk.m_chunkPtr->m_header.DataOffset;
35  Size dataSize = chunk.m_chunkPtr->m_header.DataSize;
36 
37  if( position != chunkOffset + dataOffset + dataSize )
38  return false;
39  return true;
40 }
41 
42 // ================================ //
43 //
44 inline bool CLASS_TESTER( HCF )::ValidateStreamPos ( sw::HCF* hcf, sw::Attribute& attrib )
45 {
46  auto file = hcf->m_impl.GetFile();
47  if( file == nullptr )
48  return false;
49 
50  Size position = ftell( file );
51 
52  Size chunkOffset = attrib.m_attribPtr->m_absolutOffset;
53  Size attribSize = attrib.m_attribPtr->m_header.AttribSize;
54 
55  if( position != chunkOffset + attribSize )
56  return false;
57  return true;
58 }
59 
60 } // sw
61 
62 
Definition: Exception.h:11
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