Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXMemMap Class Reference

A Memory Map provides a view of a file as an array of memory; this allows the file itself to be used as backing for the data and very simplified file access results. More...

#include <FXMemMap.h>

Inheritance diagram for FX::FXMemMap:

FX::FXFile FX::FXIO

List of all members.

Public Member Functions

 FXMemMap ()
void * openMap (const FXString &filename, FXlong off=0, FXival len=-1L, FXuint m=FXIO::Reading, FXuint p=FXIO::AllReadWrite)
void * openMap (FXInputHandle h, FXlong off=0, FXival len=-1L, FXuint m=FXIO::Reading)
void * map (FXlong off=0, FXival len=-1L)
void * base () const
long length () const
long offset () const
virtual FXlong position () const
virtual FXlong position (FXlong off, FXuint from=FXIO::Begin)
void * unmap ()
virtual FXival readBlock (void *data, FXival count)
virtual FXival writeBlock (const void *data, FXival count)
virtual FXbool flush ()
virtual FXbool close ()
 ~FXMemMap ()


Detailed Description

A Memory Map provides a view of a file as an array of memory; this allows the file itself to be used as backing for the data and very simplified file access results.

Moreover, mapped files may be shared by processes, resuling in far less "real" memory being used than would otherwise be the case.


Constructor & Destructor Documentation

FX::FXMemMap::FXMemMap (  ) 

Construct a memory map.

FX::FXMemMap::~FXMemMap (  ) 

Destroy the map.


Member Function Documentation

void* FX::FXMemMap::openMap ( const FXString filename,
FXlong  off = 0,
FXival  len = -1L,
FXuint  m = FXIO::Reading,
FXuint  p = FXIO::AllReadWrite 
)

Open a file, and map a view of it into memory; the offset must be a multiple of the page size.

void* FX::FXMemMap::openMap ( FXInputHandle  h,
FXlong  off = 0,
FXival  len = -1L,
FXuint  m = FXIO::Reading 
)

Open map using existing file handle, and map a view of it into memory.

void* FX::FXMemMap::map ( FXlong  off = 0,
FXival  len = -1L 
)

Map a view of the already open file into memory.

void* FX::FXMemMap::base (  )  const [inline]

Return pointer to memory area.

long FX::FXMemMap::length (  )  const [inline]

Obtain length of the map.

long FX::FXMemMap::offset (  )  const [inline]

Obtain offset of the map.

virtual FXlong FX::FXMemMap::position (  )  const [virtual]

Get current file position.

Reimplemented from FX::FXFile.

virtual FXlong FX::FXMemMap::position ( FXlong  off,
FXuint  from = FXIO::Begin 
) [virtual]

Change file position, returning new position from start.

Reimplemented from FX::FXFile.

void* FX::FXMemMap::unmap (  ) 

Unmap the view of the file.

virtual FXival FX::FXMemMap::readBlock ( void *  data,
FXival  count 
) [virtual]

Read block of bytes, returning number of bytes read.

Reimplemented from FX::FXFile.

virtual FXival FX::FXMemMap::writeBlock ( const void *  data,
FXival  count 
) [virtual]

Write block of bytes, returning number of bytes written.

Reimplemented from FX::FXFile.

virtual FXbool FX::FXMemMap::flush (  )  [virtual]

Flush to disk.

Reimplemented from FX::FXFile.

virtual FXbool FX::FXMemMap::close (  )  [virtual]

Close file, and also the map.

Reimplemented from FX::FXFile.

Copyright © 1997-2009 Jeroen van der Zijp