MemoryFile Class Reference

This class mimics a disk file with an in-memory representation. More...

Inherits Simba::Support::IFile.

List of all members.

Public Member Functions

virtual void Clear ()
 Erase contents of the current file, setting the size to 0.
virtual void Close ()
 Closes this file.
virtual simba_int64 Extend (simba_int64 in_size)
 Extend the file to a size of precisely length bytes. If the file previously was shorter, it is extended, and the content of extended part is not defined. If the file was same size, it is not extended and the actual size of the file is returned. If the file previously was larger than this size, return -1.
virtual void Flush ()
 Flush data to file.
virtual const simba_wstringGetName () const
 Gets the file name.
virtual simba_int64 GetPosition ()
 Gets current file position.
virtual bool IsOpen ()
 Determines if file is currently open.
 MemoryFile (simba_size_t in_blockSize=MEMORY_FILE_DEFAULT_BLOCK_SIZE)
 Constructor.
virtual simba_int64 Read (void *io_buffer, simba_int64 in_size)
 Read from the file into buffer.
virtual bool ReOpen (FileOpenMode in_openmode)
 Re-open file with new mode.
virtual simba_int64 Seek (simba_int64 in_position, SeekDirection in_direction)
 Navigate to the certain position within file.
virtual simba_int64 Write (const void *in_buffer, simba_int64 in_size)
 Write text from buffer to the file.
virtual ~MemoryFile ()
 Destructor.

Detailed Description

This class mimics a disk file with an in-memory representation.

File data is stored in a vector of MemoryFileBlocks. The vector is sparse in that MemoryFileBlocks are allocated only when data is written to the file. Regions of the file where no data has been written will not have allocated MemoryFileBlocks.


Constructor & Destructor Documentation

MemoryFile ( simba_size_t  in_blockSize = MEMORY_FILE_DEFAULT_BLOCK_SIZE  ) 

Constructor.

Parameters:
in_blockSize The size of the file block in bytes to be created.
virtual ~MemoryFile (  )  [virtual]

Destructor.


Member Function Documentation

virtual void Clear (  )  [virtual]

Erase contents of the current file, setting the size to 0.

Exceptions:
ErrorException if there was an error clearing the file.

Implements IFile.

virtual void Close (  )  [virtual]

Closes this file.

Implements IFile.

virtual simba_int64 Extend ( simba_int64  in_size  )  [virtual]

Extend the file to a size of precisely length bytes. If the file previously was shorter, it is extended, and the content of extended part is not defined. If the file was same size, it is not extended and the actual size of the file is returned. If the file previously was larger than this size, return -1.

Parameters:
in_size New size in bytes.
Returns:
The new size of the file or -1.
virtual void Flush (  )  [virtual]

Flush data to file.

Implements IFile.

virtual const simba_wstring& GetName (  )  const [virtual]

Gets the file name.

Returns:
The name of the binary file.

Implements IFile.

virtual simba_int64 GetPosition (  )  [virtual]

Gets current file position.

Returns:
Absolute position from the beginning of the file. Returns -1 on error.

Implements IFile.

virtual bool IsOpen (  )  [virtual]

Determines if file is currently open.

Returns:
true if file is open; false otherwise.

Implements IFile.

virtual simba_int64 Read ( void *  io_buffer,
simba_int64  in_size 
) [virtual]

Read from the file into buffer.

Parameters:
io_buffer Buffer to read into. (NOT OWN)
in_size Size of the provided buffer.
Returns:
Number of bytes read.
virtual bool ReOpen ( FileOpenMode  in_openmode  )  [virtual]

Re-open file with new mode.

Parameters:
in_openmode Open mode as defined in OPENMODE enum.
Returns:
true on success; false otherwise.

Implements IFile.

virtual simba_int64 Seek ( simba_int64  in_position,
SeekDirection  in_direction 
) [virtual]

Navigate to the certain position within file.

Parameters:
in_position Offset from the current position.
in_direction Seek direction.
Returns:
Absolute position from the beginning of the file. Returns -1 on error.
virtual simba_int64 Write ( const void *  in_buffer,
simba_int64  in_size 
) [virtual]

Write text from buffer to the file.

Parameters:
in_buffer Buffer containing text to write. (NOT OWN)
in_size Size of the provided buffer.
Returns:
Number of bytes written.

The documentation for this class was generated from the following file:

Generated on Wed May 17 14:21:16 2017 for SimbaEngine 10.1.3.1011 by simba