Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

salt::MemFile Class Reference

Memfile implements the RFile interface using an inmemory buffer. More...

#include <fileclasses.h>

Inheritance diagram for salt::MemFile:

Inheritance graph
[legend]
Collaboration diagram for salt::MemFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MemFile (const char *fn=NULL, char *mode="rb")
 MemFile (FILE *f)
 MemFile (RFile *f)
 ~MemFile ()
bool Open (const char *fn=NULL, char *mode="rb")
 opens the file fn in the specified mode.
bool Open (void *buffer, long s)
void Close ()
 closes a previously opened file
void Destroy ()
 releases any occupied ressources used by the file.
int Eof ()
 returns a non zero value if the file pointer is at the end of the file
long Tell ()
 returns the current file pointer position
int GetPos (long *pos)
 copies the current file pointer position to pos and returns true on success
int Seek (long offset, int origin)
 sets the file pointer for the file.
void Rewind ()
 sets the file pointer to the beginning of the file
long Size ()
 return the size of the file
char * Gets (char *buffer, int n)
 reads in at most one less than n characters from the file and stores them into buffer.
int Getc ()
 reads the next character from the file returns it as an int r EOF on end of file or error.
void * GetHandle ()
 returns a handle identifying the file.
size_t Read (void *buffer, size_t size, size_t count)
 reads reads count elements of data, each size bytes long, storing them in the specified buffer
size_t Read (void *buffer, size_t count)
 reads count bytes of data, storing them in the specified buffer

Private Attributes

void * mHandle
 the file handle
unsigned char * mCharHandle
 a pointer to the buffer holding the file
long mSize
 the size of the file in bytes
long mPosition
 the current file pointer position

Detailed Description

Memfile implements the RFile interface using an inmemory buffer.

On open() a file is completely read into the buffer and from there on served from memory.

Definition at line 171 of file fileclasses.h.


Constructor & Destructor Documentation

MemFile::MemFile const char *  fn = NULL,
char *  mode = "rb"
 

Definition at line 47 of file fileclasses.cpp.

References mCharHandle, mHandle, mPosition, mSize, and Open().

Here is the call graph for this function:

MemFile::MemFile FILE *  f  ) 
 

Definition at line 62 of file fileclasses.cpp.

References mCharHandle, mHandle, mPosition, and mSize.

MemFile::MemFile RFile f  ) 
 

Definition at line 74 of file fileclasses.cpp.

References mCharHandle, mHandle, mPosition, mSize, salt::RFile::Read(), and salt::RFile::Size().

Here is the call graph for this function:

MemFile::~MemFile  ) 
 

Definition at line 83 of file fileclasses.cpp.

References Destroy(), and mHandle.

Here is the call graph for this function:


Member Function Documentation

void MemFile::Close  )  [virtual]
 

closes a previously opened file

Implements salt::RFile.

Definition at line 123 of file fileclasses.cpp.

References Destroy().

Here is the call graph for this function:

void MemFile::Destroy  )  [virtual]
 

releases any occupied ressources used by the file.

The semantic is up to the derived classes

Implements salt::RFile.

Definition at line 128 of file fileclasses.cpp.

References mCharHandle, mHandle, mPosition, and mSize.

Referenced by Close(), and ~MemFile().

int MemFile::Eof  )  [virtual]
 

returns a non zero value if the file pointer is at the end of the file

Implements salt::RFile.

Definition at line 140 of file fileclasses.cpp.

References mPosition, and mSize.

Referenced by Gets().

int MemFile::Getc  )  [virtual]
 

reads the next character from the file returns it as an int r EOF on end of file or error.

Implements salt::RFile.

Definition at line 199 of file fileclasses.cpp.

References mCharHandle, mPosition, and mSize.

void* salt::MemFile::GetHandle  )  [inline, virtual]
 

returns a handle identifying the file.

The semantics of this handle depends on the subclass, implementing this method

Implements salt::RFile.

Definition at line 194 of file fileclasses.h.

References mHandle.

int MemFile::GetPos long *  pos  )  [virtual]
 

copies the current file pointer position to pos and returns true on success

Implements salt::RFile.

Definition at line 150 of file fileclasses.cpp.

References Tell().

Here is the call graph for this function:

char * MemFile::Gets char *  buffer,
int  n
[virtual]
 

reads in at most one less than n characters from the file and stores them into buffer.

A '' is stored after the last character in the buffer.

Implements salt::RFile.

Definition at line 181 of file fileclasses.cpp.

References Eof(), mCharHandle, and mPosition.

Here is the call graph for this function:

bool MemFile::Open void *  buffer,
long  s
 

Definition at line 114 of file fileclasses.cpp.

References mCharHandle, mHandle, mPosition, and mSize.

bool MemFile::Open const char *  fn = NULL,
char *  mode = "rb"
[virtual]
 

opens the file fn in the specified mode.

The implementation of the namespace and mode semantics ist up to derived classes

Implements salt::RFile.

Definition at line 89 of file fileclasses.cpp.

References salt::StdFile::GetHandle(), mCharHandle, mHandle, mPosition, mSize, salt::StdFile::Read(), and salt::StdFile::Size().

Referenced by MemFile().

Here is the call graph for this function:

size_t salt::MemFile::Read void *  buffer,
size_t  count
[inline, virtual]
 

reads count bytes of data, storing them in the specified buffer

Implements salt::RFile.

Definition at line 197 of file fileclasses.h.

References Read().

Here is the call graph for this function:

size_t MemFile::Read void *  buffer,
size_t  size,
size_t  count
[virtual]
 

reads reads count elements of data, each size bytes long, storing them in the specified buffer

Implements salt::RFile.

Definition at line 208 of file fileclasses.cpp.

References mCharHandle, mPosition, and mSize.

Referenced by Read().

void MemFile::Rewind  )  [virtual]
 

sets the file pointer to the beginning of the file

Implements salt::RFile.

Definition at line 171 of file fileclasses.cpp.

References mPosition.

int MemFile::Seek long  offset,
int  origin
[virtual]
 

sets the file pointer for the file.

The new position, measured in bytes, is obtained by adding offset bytes to the position specified by origin. If origin is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively.

Implements salt::RFile.

Definition at line 156 of file fileclasses.cpp.

References mPosition, and mSize.

long MemFile::Size  )  [virtual]
 

return the size of the file

Implements salt::RFile.

Definition at line 176 of file fileclasses.cpp.

References mSize.

long MemFile::Tell  )  [virtual]
 

returns the current file pointer position

Implements salt::RFile.

Definition at line 145 of file fileclasses.cpp.

References mPosition.

Referenced by GetPos().


Member Data Documentation

unsigned char* salt::MemFile::mCharHandle [private]
 

a pointer to the buffer holding the file

Definition at line 204 of file fileclasses.h.

Referenced by Destroy(), Getc(), Gets(), MemFile(), Open(), and Read().

void* salt::MemFile::mHandle [private]
 

the file handle

Definition at line 201 of file fileclasses.h.

Referenced by Destroy(), GetHandle(), MemFile(), Open(), and ~MemFile().

long salt::MemFile::mPosition [private]
 

the current file pointer position

Definition at line 210 of file fileclasses.h.

Referenced by Destroy(), Eof(), Getc(), Gets(), MemFile(), Open(), Read(), Rewind(), Seek(), and Tell().

long salt::MemFile::mSize [private]
 

the size of the file in bytes

Definition at line 207 of file fileclasses.h.

Referenced by Destroy(), Eof(), Getc(), MemFile(), Open(), Read(), Seek(), and Size().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:48:45 2006 for rcssserver3d by  doxygen 1.4.4