Regina Calculation Engine
Public Member Functions | Static Public Member Functions
regina::NLocalFileResource Class Reference

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

#include <file/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.
- Public Member Functions inherited from regina::NRandomAccessResource
virtual ~NRandomAccessResource ()
 Destroys this resource.

Static Public Member Functions

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

Additional Inherited Members

- Public Types inherited from regina::NRandomAccessResource
enum  mode { CLOSED = 0, READ = 1, WRITE = 2 }
 Specifies the current state of a resource. More...

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.

Internationalisation:
This routine makes no assumptions about the character encoding used in the given file name, and simply passes it through unchanged to low-level C/C++ file I/O routines.
Precondition:
Parameter newFileName is not an empty string.
Parameters:
newFileNamethe pathname of the file that is this resource.
regina::NLocalFileResource::~NLocalFileResource ( )
inlinevirtual

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 ( )
inlinevirtual

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
inlinevirtual

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)
inlinevirtual

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:
cthe 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:
posthe position to which to move, as counted in bytes.

Implements regina::NRandomAccessResource.

std::ios::openmode regina::NLocalFileResource::sysModeRead ( )
inlinestatic

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 ( )
inlinestatic

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-2012, The Regina development team
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).