(C)Copyright 2000 NTT Cyber Space Laboratories
class CChunk{
public:
// type declaration
typedef std::vector<char>
CChunkData;
// initialize, destructor
CChunk(std::string
ID); // constructor
virtual ~CChunk();
//
destructor
////////////////////////////
// member functions
// input
const std::string&
GetID(); //
get chunk ID
const int GetSize(); //
get chunk size
const CChunkData&
GetData(); //
get chunk data
// output
int PutData( int
size, char inputData[] ); //
character array
int PutData( CChunkData&
inputData ); //
vector
int PutData( std::string&
theString); //
character string
// inquiry
virtual std::string
whatami(); //
type of chunk
protected:
int GetNInt( int
size=sizeof(long) ); //
get size byte integer from current position
CChunkData GetVector(
int size=0 ); //
get size byte vector from current position
std::string GetRndString(
int length=0 ); //
get length of character string
void PutNInt( unsigned
int inputData, int size=sizeof(long) ); //
put size byte integer from current position
void cnk_rewind(); //
move current position to top
void cnk_delete(); //
delete cunk data
const int GetCurrentPosition(); //
get current position
// exception
class err_FailPut; //
output failure
}
CChunk
helps construction and acquisition of the chunk
data which contain header information.
CChunk
consists of ID, size and data as for other data format chunk.
Reading procedures of ID, size, and data are available. However, it is not allowed to write ID
and size directly. ID can be once defined at construction, and the size is automatically
updated according to the data contents.
Access method of data field of CChunk
is not open, since the structures
of the data field depend on the chunk.
Some subclasses inherit the CChunk
and the data field can be accessed by
protected member functions. const std::string& GetID()
const int GetSize()
const CChunkData& GetData()
int PutData( int size, char inputData[] )
int PutData( CChunkData& inputData )
int PutData( std::string& theString )
CChunk
class holds current position. Current position is automatically moved
to the data field.
The current position can be obtained by
GetCurrentPosition()
and can be set to the top
by cnk_rewind()
.
int GetNInt( int size=sizeof(long) )
CChunkData GetVector( int size=0 )
(CChunkData)
from current position.
(Default size is a size of data field to the end.)
std::string GetRndString ( int size=0 )
void PutNInt( unsigned int inputData, int
size=sizeof(long) )
void cnk_rewind()
void cnk_delete()
const int GetCurrentPosition()
CChunk.h
CChunk.cxx