PMemoryFile Class Reference

#include <memfile.h>

Inheritance diagram for PMemoryFile:

PFile PChannel PObject List of all members.

Public Member Functions

Overrides from class PObject
Comparison Compare (const PObject &obj) const
Overrides from class PChannel
virtual BOOL Read (void *buf, PINDEX len)
virtual BOOL Write (const void *buf, PINDEX len)
Overrides from class PFile
off_t GetLength () const
BOOL SetLength (off_t len)
BOOL SetPosition (off_t pos, FilePositionOrigin origin=Start)
off_t GetPosition () const
Overrides from class PFile
const PBYTEArrayGetData () const

Protected Attributes

PBYTEArray data
off_t position

Detailed Description

This class is used to allow a block of memory to substitute for a disk file.


Constructor & Destructor Documentation

PMemoryFile::PMemoryFile (  ) 

Create a new, empty, memory file.

PMemoryFile::PMemoryFile ( const PBYTEArray data  ) 

Create a new memory file initialising to the specified content.

Parameters:
data  New content filr memory file.

PMemoryFile::PMemoryFile (  ) 

Create a new, empty, memory file.

PMemoryFile::PMemoryFile ( const PBYTEArray data  ) 

Create a new memory file initialising to the specified content.

Parameters:
data  New content filr memory file.


Member Function Documentation

Comparison PMemoryFile::Compare ( const PObject obj  )  const [virtual]

Determine the relative rank of the two objects. This is essentially the string comparison of the PFilePath# names of the files.

Returns:
relative rank of the file paths.
Parameters:
obj  Other file to compare against.

Reimplemented from PFile.

virtual BOOL PMemoryFile::Read ( void *  buf,
PINDEX  len 
) [virtual]

Low level read from the memory file channel. The read timeout is ignored. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns FALSE to determine what caused the failure.

Returns:
TRUE indicates that at least one character was read from the channel. FALSE means no bytes were read due to timeout or some other I/O error.
Parameters:
buf  Pointer to a block of memory to receive the read bytes.
len  Maximum number of bytes to read into the buffer.

Reimplemented from PFile.

virtual BOOL PMemoryFile::Write ( const void *  buf,
PINDEX  len 
) [virtual]

Low level write to the memory file channel. The write timeout is ignored. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.

Returns:
TRUE if at least len bytes were written to the channel.
Parameters:
buf  Pointer to a block of memory to write.
len  Number of bytes to write.

Reimplemented from PFile.

off_t PMemoryFile::GetLength (  )  const [virtual]

Get the current size of the file. The size of the file corresponds to the size of the data array.

Returns:
length of file in bytes.

Reimplemented from PFile.

BOOL PMemoryFile::SetLength ( off_t  len  )  [virtual]

Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter.

Returns:
TRUE if the file size was changed to the length specified.
Parameters:
len  New length of file.

Reimplemented from PFile.

BOOL PMemoryFile::SetPosition ( off_t  pos,
FilePositionOrigin  origin = Start 
) [virtual]

Set the current active position in the file for the next read or write operation. The pos# variable is a signed number which is added to the specified origin. For origin == PFile::Start# only positive values for pos# are meaningful. For origin == PFile::End# only negative values for pos# are meaningful.

Returns:
TRUE if the new file position was set.
Parameters:
pos  New position to set.
origin  Origin for position change.

Reimplemented from PFile.

off_t PMemoryFile::GetPosition (  )  const [virtual]

Get the current active position in the file for the next read or write operation.

Returns:
current file position relative to start of file.

Reimplemented from PFile.

const PBYTEArray& PMemoryFile::GetData (  )  const [inline]

Get the memory data the file has operated with.


Member Data Documentation

PBYTEArray PMemoryFile::data [protected]

off_t PMemoryFile::position [protected]


The documentation for this class was generated from the following file:
Generated on Fri Mar 7 06:25:06 2008 for PTLib by  doxygen 1.5.1