Public Types | Public Member Functions

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

Provides a standard random access interface for old-style binary file-like resources. More...

#include <nresources.h>

Inheritance diagram for regina::NRandomAccessResource:
regina::NLocalFileResource

List of all members.

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.

Detailed Description

Provides a standard random access interface for old-style binary file-like resources.

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

Member Enumeration Documentation

Specifies the current state of a resource.

Enumerator:
CLOSED 

The resource is closed.

READ 

The resource is open for reading.

WRITE 

The resource is open for writing.


Constructor & Destructor Documentation

regina::NRandomAccessResource::~NRandomAccessResource (  ) [inline, virtual]

Destroys this resource.


Member Function Documentation

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.

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

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.

Returns:
the current state of the resource.

Implemented in regina::NLocalFileResource.

virtual long regina::NRandomAccessResource::getPosition (  ) [pure virtual]

Returns the current position in the resource.

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

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.

Precondition:
The resource is currently closed.
Returns:
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.

Precondition:
The resource is currently closed.
Returns:
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.

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

Implemented in regina::NLocalFileResource.

virtual void regina::NRandomAccessResource::setPosition ( long  pos ) [pure 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.

Implemented in regina::NLocalFileResource.


The documentation for this class was generated from the following file:

Copyright © 1999-2009, 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).