Regina Calculation Engine
|
Provides a standard random access interface for old-style binary file-like resources. More...
#include <file/nresources.h>
Public Types | |
enum | mode { CLOSED = 0, READ = 1, WRITE = 2 } |
Specifies the current state of a resource. More... | |
Public Member Functions | |
virtual | ~NRandomAccessResource () |
Destroys this resource. | |
virtual bool | openRead ()=0 |
Open the resource in read mode. | |
virtual bool | openWrite ()=0 |
Open the resource in write mode. | |
virtual void | close ()=0 |
Close the resource. | |
virtual mode | getOpenMode () const =0 |
Returns the current state of the resource. | |
virtual char | getChar ()=0 |
Reads a character from the current position in the resource and moves on to the next position. | |
virtual void | putChar (char c)=0 |
Writes the given character to the resource at the current position and moves on to the next position. | |
virtual long | getPosition ()=0 |
Returns the current position in the resource. | |
virtual void | setPosition (long pos)=0 |
Moves to the given position in the resource. |
Provides a standard random access interface for old-style binary file-like resources.
regina::NRandomAccessResource::~NRandomAccessResource | ( | ) | [inline, virtual] |
Destroys this resource.
virtual void regina::NRandomAccessResource::close | ( | ) | [pure virtual] |
Close the resource.
If the resource is already closed, this routine should do nothing.
Implemented in regina::NLocalFileResource.
virtual char regina::NRandomAccessResource::getChar | ( | ) | [pure virtual] |
Reads a character from the current position in the resource and moves on to the next position.
Implemented in regina::NLocalFileResource.
virtual mode regina::NRandomAccessResource::getOpenMode | ( | ) | const [pure 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.
Implemented in regina::NLocalFileResource.
virtual long regina::NRandomAccessResource::getPosition | ( | ) | [pure virtual] |
Returns the current position in the resource.
Implemented in regina::NLocalFileResource.
virtual bool regina::NRandomAccessResource::openRead | ( | ) | [pure virtual] |
Open the resource in read mode.
This routine should fail if the resource does not exist.
true
on success, false
on failure. Implemented in regina::NLocalFileResource.
virtual bool regina::NRandomAccessResource::openWrite | ( | ) | [pure virtual] |
Open the resource in write mode.
If the resource already exists, any existing contents should be deleted.
true
on success, false
on failure. Implemented in regina::NLocalFileResource.
virtual void regina::NRandomAccessResource::putChar | ( | char | c | ) | [pure virtual] |
Writes the given character to the resource at the current position and moves on to the next position.
c | the character to write. |
Implemented in regina::NLocalFileResource.
virtual void regina::NRandomAccessResource::setPosition | ( | long | pos | ) | [pure virtual] |
Moves to the given position in the resource.
pos | the position to which to move, as counted in bytes. |
Implemented in regina::NLocalFileResource.