#ifndef _SAMPLE_GENERICCHUNK_HPP_ #define _SAMPLE_GENERICCHUNK_HPP_ #ifndef _COMMON_WINDOWS_HPP_ #include #endif #ifndef _COMMON_GLOBALDATA_HPP_ #include #endif #ifndef _COMMON_MEMFILE_HPP_ #include #endif #ifndef _COMMON_OPENFILE_HPP_ #include #endif #ifndef _SAMPLE_CHUNKID_HPP_ #include #endif class GenericChunk : public GlobalData { public: GenericChunk(void); GenericChunk(const GenericChunk &someGenericChunk); virtual ~GenericChunk(); GenericChunk &operator=(const GenericChunk &someGenericChunk); WORD operator==(const GenericChunk &someGenericChunk)const; MemFile &operator>>(MemFile &someMemFile)const; FileHandle &operator<<(FileHandle &someFileHandle); const ChunkID &chunkID(void)const; DWORD chunkLength(void)const; private: ChunkID mChunkID; }; inline GenericChunk::GenericChunk(void) { } inline GenericChunk::GenericChunk(const GenericChunk &someGenericChunk) { *this=someGenericChunk; } inline GenericChunk::~GenericChunk() { } inline GenericChunk &GenericChunk::operator=(const GenericChunk &someGenericChunk) { mChunkID=someGenericChunk.mChunkID; return *this; } inline WORD GenericChunk::operator==(const GenericChunk &someGenericChunk)const { return (mChunkID==someGenericChunk.mChunkID&& (GlobalData&)*this==(GlobalData&)someGenericChunk); } inline MemFile &GenericChunk::operator>>(MemFile &someMemFile)const { DWORD lengthData(size()); mChunkID>>someMemFile; someMemFile.write((char*)&lengthData,sizeof(lengthData)); someMemFile.write((char*)(BYTE*)&(((GlobalData&)*this).operator[](0)),lengthData); return someMemFile; } inline FileHandle &GenericChunk::operator<<(FileHandle &someFileHandle) { DWORD lengthData; mChunkID<&)*this),lengthData); someFileHandle.read(&(((GlobalData&)*this).operator[](0)),lengthData); return someFileHandle; } inline DWORD GenericChunk::chunkLength(void)const { return mChunkID.size()+size()+sizeof(DWORD); } inline const ChunkID &GenericChunk::chunkID(void)const { return mChunkID; } #endif