Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

regina::NLocalFileResource Class Reference
[File I/O]

A random access resource that is simply a local file. More...

#include <nresources.h>

Inheritance diagram for regina::NLocalFileResource:

regina::NRandomAccessResource List of all members.

Public Member Functions

 NLocalFileResource (const char *newFileName)
 Creates a new resource referring to the given file.

virtual ~NLocalFileResource ()
 Destroys this resource reference, closing the corresponding file if necessary.

virtual bool openRead ()
 Open the resource in read mode.

virtual bool openWrite ()
 Open the resource in write mode.

virtual void close ()
 Close the resource.

virtual mode getOpenMode () const
 Returns the current state of the resource.

virtual char getChar ()
 Reads a character from the current position in the resource and moves on to the next position.

virtual void putChar (char c)
 Writes the given character to the resource at the current position and moves on to the next position.

virtual long getPosition ()
 Returns the current position in the resource.

virtual void setPosition (long pos)
 Moves to the given position in the resource.


Static Public Member Functions

std::ios::openmode sysModeRead ()
 Returns the system file mode for opening a binary file for reading.

std::ios::openmode sysModeWrite ()
 Returns the system file mode for opening a binary file for writing.


Detailed Description

A random access resource that is simply a local file.

Deprecated:
The preferred way of representing data is using XML which is accessed using text I/O streams.
Python:
Not present.


Constructor & Destructor Documentation

regina::NLocalFileResource::NLocalFileResource const char *  newFileName  )  [inline]
 

Creates a new resource referring to the given file.

The file will not be accessed until one of the open... routines is called.

Precondition:
Parameter newFileName is not an empty string.
Parameters:
newFileName the pathname of the file that is this resource.

regina::NLocalFileResource::~NLocalFileResource  )  [inline, virtual]
 

Destroys this resource reference, closing the corresponding file if necessary.


Member Function Documentation

virtual void regina::NLocalFileResource::close  )  [virtual]
 

Close the resource.

If the resource is already closed, this routine should do nothing.

Implements regina::NRandomAccessResource.

char regina::NLocalFileResource::getChar  )  [inline, virtual]
 

Reads a character from the current position in the resource and moves on to the next position.

Precondition:
The resource is currently open in read mode.
Returns:
the character read.

Implements regina::NRandomAccessResource.

NRandomAccessResource::mode regina::NLocalFileResource::getOpenMode  )  const [inline, virtual]
 

Returns the current state of the resource.

If the resource is open, the mode in which it was opened will be returned (either READ or WRITE). If the file is closed, 0 (alternatively, CLOSED) will be returned.

Returns:
the current state of the resource.

Implements regina::NRandomAccessResource.

virtual long regina::NLocalFileResource::getPosition  )  [virtual]
 

Returns the current position in the resource.

Precondition:
The resource is currently open.
Returns:
the current positon, as counted in bytes.

Implements regina::NRandomAccessResource.

virtual bool regina::NLocalFileResource::openRead  )  [virtual]
 

Open the resource in read mode.

This routine should fail if the resource does not exist.

Precondition:
The resource is currently closed.
Returns:
true on success, false on failure.

Implements regina::NRandomAccessResource.

virtual bool regina::NLocalFileResource::openWrite  )  [virtual]
 

Open the resource in write mode.

If the resource already exists, any existing contents should be deleted.

Precondition:
The resource is currently closed.
Returns:
true on success, false on failure.

Implements regina::NRandomAccessResource.

void regina::NLocalFileResource::putChar char  c  )  [inline, virtual]
 

Writes the given character to the resource at the current position and moves on to the next position.

Precondition:
The resource is currently open in write mode.
Parameters:
c the character to write.

Implements regina::NRandomAccessResource.

virtual void regina::NLocalFileResource::setPosition long  pos  )  [virtual]
 

Moves to the given position in the resource.

Precondition:
The resource is currently open.
Parameters:
pos the position to which to move, as counted in bytes.

Implements regina::NRandomAccessResource.

std::ios::openmode regina::NLocalFileResource::sysModeRead  )  [inline, static]
 

Returns the system file mode for opening a binary file for reading.

Returns:
the system file mode for reading.

std::ios::openmode regina::NLocalFileResource::sysModeWrite  )  [inline, static]
 

Returns the system file mode for opening a binary file for writing.

Returns:
the system file mode for writing.


The documentation for this class was generated from the following file:
Copyright © 1999-2004, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).