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>

List of all members.

Public Types

enum  {
  NONE = 0,
  READ = 1,
  WRITE = 2,
  EXEC = 4,
  TRUNC = 8
}
enum  {
  PRIV = 0,
  SHAR = 1
}

Public Member Functions

 FXMemMap ()
void * mapFile (const FXString &filename, long off=0, long len=-1L, FXuint access=READ, FXuint share=PRIV)
void * unmap ()
void sync ()
void * base () const
long length () const
long offset () const
 ~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.


Member Enumeration Documentation

anonymous enum
 

Memory map access modes.

Enumeration values:
NONE  Map is inaccessible.
READ  Readable.
WRITE  Writable.
EXEC  Executable (where supported).
TRUNC  Truncate file to 0.

anonymous enum
 

Share mode.

Enumeration values:
PRIV  Private.
SHAR  Shared.


Constructor & Destructor Documentation

FX::FXMemMap::FXMemMap  ) 
 

Construct a memory map.

FX::FXMemMap::~FXMemMap  ) 
 

Destroy the map.


Member Function Documentation

void* FX::FXMemMap::mapFile const FXString filename,
long  off = 0,
long  len = -1L,
FXuint  access = READ,
FXuint  share = PRIV
 

Map a view of the file; the offset must be a multiple of the page size.

void* FX::FXMemMap::unmap  ) 
 

Unmap the view of the file.

void FX::FXMemMap::sync  ) 
 

Synchronize disk.

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.

Copyright © 1997-2005 Jeroen van der Zijp