os::MemFile Class Reference
[The Syllable high level filesystem API]

Virtual stream object. More...

Inheritance diagram for os::MemFile:

os::SeekableIO os::StreamableIO List of all members.

Public Member Functions

 MemFile ()
 Default constructor.
 MemFile (const void *pData, uint32 nLen)
 Constructor.
 ~MemFile ()
virtual ssize_t Read (void *pBuffer, ssize_t nSize)
virtual ssize_t Write (const void *pBuffer, ssize_t nSize)
virtual ssize_t ReadPos (off_t nPos, void *pBuffer, ssize_t nSize)
virtual ssize_t WritePos (off_t nPos, const void *pBuffer, ssize_t nSize)
virtual off_t Seek (off_t nPos, int nMode)
virtual void SetSize (uint32 nSize)
 Set the size of the internal buffer.

Classes

class  Private

Detailed Description

Description:
This class simulates a SeekableIO object in memory. It may be used to capture data that would normally be sent to a file, or it may be used to supply compiled-in data, or data retrieved elsewhere to an object that expects a stream or file.
One possible application would be to decode data received from an HTTP link, with the BitmapImage class' Load() method.

See also:
os::StreamableIO, os::SeekableIO, os::BitmapImage
Author:
Henrik Isaksson ([email protected])


Constructor & Destructor Documentation

MemFile::MemFile (  ) 

Description:
Initializes a MemFile object to default values (ie. an empty MemFile).

MemFile::MemFile ( const void *  pData,
uint32  nLen 
)

Description:
Creates a MemFile object with the data you specify. The data is not copied, unless the object is written to. This reduces overhead, since the data will often be static.
If the object is written to, memory is allocated and the data is copied to the newly allocated memory. Your original data will not be affected in any way.
Parameters:
pData Pointer to the data you want to access as a stream.
nLen Length of the data.
Example:
 const char bitmap[] = {
        // Bitmap data
 };

 MemFile cBitmapStream( bitmap, sizeof( bitmap ) );

 // Now cBitmapStream may be used like an ordinary stream object:

 Image *cImg = new BitmapImage( &cBitmapStream );
Note:
The object pointed to by pData must live as long as the MemFile object lives. (That is, unless you force MemFile to move it into it's own memory, with a dummy write).
Author:
Henrik Isaksson ([email protected])

MemFile::~MemFile (  ) 


Member Function Documentation

ssize_t MemFile::Read ( void *  pBuffer,
ssize_t  nSize 
) [virtual]

Implements os::StreamableIO.

ssize_t MemFile::Write ( const void *  pBuffer,
ssize_t  nSize 
) [virtual]

Implements os::StreamableIO.

ssize_t MemFile::ReadPos ( off_t  nPos,
void *  pBuffer,
ssize_t  nSize 
) [virtual]

Implements os::SeekableIO.

ssize_t MemFile::WritePos ( off_t  nPos,
const void *  pBuffer,
ssize_t  nSize 
) [virtual]

Implements os::SeekableIO.

off_t MemFile::Seek ( off_t  nPos,
int  nMode 
) [virtual]

Implements os::SeekableIO.

void MemFile::SetSize ( uint32  nSize  )  [virtual]

Description:
Set the size of the internal buffer. Any data past the end of new buffer will be discarded. Setting the buffer size to 0 will cause the MemFile object to free all allocated memory.
You may want to set a default buffer size, to optimize performance and reduce overhead. Normally, the buffer will be allocated incrementally, as needed, with at least MIN_BLOCKSIZE (currently 1 kbyte, but this may change in future versions).
Example:
If you know you will be writing at most 500 bytes, it makes sense to set the buffer to 500 bytes.
If you know you will be writing at least 200 k, it makes sense to set the buffer to 200 k. Even if you write more, you will still have reduced the number of blocks required.
Parameters:
nSize The new buffer size.
Author:
Henrik Isaksson ([email protected])


Generated on Sat May 9 22:51:57 2009 for Syllable higlevel API by  doxygen 1.5.1