Initial
This commit is contained in:
100
sample/holdii/GenChnk.hpp
Normal file
100
sample/holdii/GenChnk.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef _SAMPLE_GENERICCHUNK_HPP_
|
||||
#define _SAMPLE_GENERICCHUNK_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#include <common/gdata.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MEMFILE_HPP_
|
||||
#include <common/memfile.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_OPENFILE_HPP_
|
||||
#include <common/openfile.hpp>
|
||||
#endif
|
||||
#ifndef _SAMPLE_CHUNKID_HPP_
|
||||
#include <sample/chunkid.hpp>
|
||||
#endif
|
||||
|
||||
class GenericChunk : public GlobalData<BYTE>
|
||||
{
|
||||
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<BYTE>&)*this==(GlobalData<BYTE>&)someGenericChunk);
|
||||
}
|
||||
|
||||
inline
|
||||
MemFile &GenericChunk::operator>>(MemFile &someMemFile)const
|
||||
{
|
||||
DWORD lengthData(size());
|
||||
|
||||
mChunkID>>someMemFile;
|
||||
someMemFile.write((char*)&lengthData,sizeof(lengthData));
|
||||
someMemFile.write((char*)(BYTE*)&(((GlobalData<BYTE>&)*this).operator[](0)),lengthData);
|
||||
return someMemFile;
|
||||
}
|
||||
|
||||
inline
|
||||
FileHandle &GenericChunk::operator<<(FileHandle &someFileHandle)
|
||||
{
|
||||
DWORD lengthData;
|
||||
|
||||
mChunkID<<someFileHandle;
|
||||
someFileHandle.read((BYTE*)&lengthData,sizeof(lengthData));
|
||||
size(lengthData);
|
||||
// someFileHandle.read((BYTE*)((GlobalData<BYTE>&)*this),lengthData);
|
||||
someFileHandle.read(&(((GlobalData<BYTE>&)*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
|
||||
Reference in New Issue
Block a user