Back to the WFC main page

CDataMemory : CDataFile

$Revision: 16 $

Description

This is the interesting CDataFile derivative. It allows you to treat a chunk of memory like it was a file. This makes it easy to embed CDataChunk's within other chunks (i.e. a chunk of chunks).

Data Members

None.

Constructors

CDataMemory()
CDataMemory( const CDataMemory& source )
CDataMemory( const BYTE * buffer_p, DWORD number_of_bytes )
CDataMemory( const CByteArray& source )
Constructs the object.

Methods

void Append( const CByteArray& source )
void Append( const CDataMemory& source )
Appends the contents of source to this object.
void AppendTo( CByteArray& data )
Appends the contents of this object to data.
void Close( void )
Closes the "file".
void Copy( const BYTE * buffer, DWORD number_of_bytes_to_copy )
void Copy( const CByteArray& buffer )
void Copy( const CDataMemory& buffer )
Copies the contents of buffer to this object. It replaces the current contents of this object with whatever is in buffer.
void CopyTo( CByteArray& data )
Replaces the contents of data with the contents of this object.
void Empty( void )
Empties this objects.
void Flush( void )
Does nothing, just intercept the call. Since we aren't really a file, it would just cause the base class to blow up.
const BYTE * GetData( void ) const
Returns a pointer to the raw data.
DWORD GetLength( void ) const
Returns the number of bytes currently in the buffer.
DWORD GetPosition( void ) const
Returns the current file pointer.
BOOL Open( LPCTSTR filename, UINT mode )
Doesn't do anything.
UINT Read( void * buffer, UINT number_of_bytes_to_read )
Reads data from the buffer.
long Seek( long offset, UINT from )
Positions the file pointer.
void Write( const void * buffer, UINT number_of_bytes_to_write )
Appends data to the buffer.

Operators

const CDataMemory& operator = ( const CDataMemory& source )
const CDataMemory& operator = ( const CByteArray& source )
Calls the Copy() method.
const CDataMemory& operator += ( const CDataMemory& source )
const CDataMemory& operator += ( const CByteArray& source )
Calls the Append() method.

Example

#include <wfc.h>

void read_next_chunk( CDataMemory& data_in_memory, CDataChunk& data )
{
   WFCTRACEINIT( TEXT( "read_next_chunk()" ) );

   data_in_memory.GetData( data );

   _tprintf( TEXT( "Read %lu bytes\n" ), data.Data.GetSize() );
}

Copyright, 2000, Samuel R. Blackburn
$Workfile: CDataMemory.cpp $
$Modtime: 1/17/00 9:00a $