Go to the documentation of this file.00001 #ifndef Chunk_h
00002 #define Chunk_h
00003
00004 struct CChunkInfo
00005 {
00006 BYTE m_ChunkType;
00007 BYTE m_ChunkLength;
00008
00009 bool operator == (const CChunkInfo & X) const
00010 {
00011 return (m_ChunkType == X.m_ChunkType)
00012 && (m_ChunkLength == X.m_ChunkLength) ;
00013 }
00014 bool operator < (const CChunkInfo & X) const
00015 {
00016 if (m_ChunkType == X.m_ChunkType)
00017 return m_ChunkLength < X.m_ChunkLength;
00018
00019 return (m_ChunkType < X.m_ChunkType);
00020 }
00021 };
00022 inline size_t get_size_in_bytes (const CChunkInfo& i)
00023 {
00024 return get_size_in_bytes(i.m_ChunkType) + get_size_in_bytes(i.m_ChunkLength);
00025
00026 };
00027
00028 inline size_t save_to_bytes(const CChunkInfo& i, BYTE* buf)
00029 {
00030 buf += save_to_bytes(i.m_ChunkType, buf);
00031 buf += save_to_bytes(i.m_ChunkLength, buf);
00032 return get_size_in_bytes(i);
00033 }
00034
00035 inline size_t restore_from_bytes(CChunkInfo& i, const BYTE* buf)
00036 {
00037 buf += restore_from_bytes(i.m_ChunkType, buf);
00038 buf += restore_from_bytes(i.m_ChunkLength, buf);
00039 return get_size_in_bytes(i);
00040 }
00041
00042
00043
00044 struct CChunkOccurrence
00045 {
00046 BYTE m_Type;
00047 int m_StartUnitOffset;
00048 int m_LastUnitOffset;
00049 bool operator < (const CChunkOccurrence& X) const
00050 {
00051 if (m_StartUnitOffset == X.m_StartUnitOffset)
00052 return m_LastUnitOffset < X.m_LastUnitOffset;
00053
00054 return m_StartUnitOffset < X.m_StartUnitOffset;
00055 };
00056 };
00057
00058 inline size_t get_size_in_bytes (const CChunkOccurrence& i)
00059 {
00060 return get_size_in_bytes(i.m_Type) + get_size_in_bytes(i.m_StartUnitOffset) + get_size_in_bytes(i.m_LastUnitOffset);
00061
00062 };
00063
00064 inline size_t save_to_bytes(const CChunkOccurrence& i, BYTE* buf)
00065 {
00066 buf += save_to_bytes(i.m_Type, buf);
00067 buf += save_to_bytes(i.m_StartUnitOffset, buf);
00068 buf += save_to_bytes(i.m_LastUnitOffset, buf);
00069 return get_size_in_bytes(i);
00070 }
00071
00072 inline size_t restore_from_bytes(CChunkOccurrence& i, const BYTE* buf)
00073 {
00074 buf += restore_from_bytes(i.m_Type, buf);
00075 buf += restore_from_bytes(i.m_StartUnitOffset, buf);
00076 buf += restore_from_bytes(i.m_LastUnitOffset, buf);
00077
00078 return get_size_in_bytes(i);
00079 }
00080
00081
00082 const int ClauseIndexDelta = 100;
00083 #endif