Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

FileDevice Class Reference

A device for working with files. More...

#include <filedevice.h>

Inheritance diagram for FileDevice:

IODevice List of all members.

Public Methods

 FileDevice (void)
 A constructor. More...

virtual ~FileDevice (void)
 A destructor. More...

virtual void prepare (const char *, int) throw (ExaltIOException)
 Prepare the device with specified file name and mode. More...

virtual void prepare (void) throw (ExaltIOException)
 Prepare the device (using standard input).

virtual void flush (void) throw (ExaltIOException)
 Flush the device. More...

virtual void finish (void) throw (ExaltIOException)
 Finish the work with the device. More...

virtual IOState readData (char *buf, IOSize length) throw (ExaltIOException)
 Read up to the specified number of bytes into the buffer. More...

virtual IOState getChar (int *) throw (ExaltIOException)
 Read one char. More...

virtual IOState writeData (const char *buf, IOSize length) throw (ExaltIOException)
 Write the specified number of bytes from the buffer. More...

virtual IOState putChar (int) throw (ExaltIOException)
 Write one char. More...

virtual IOSize bytesReadTotal (void)
 Return the number of bytes read so far. More...

virtual IOSize bytesRead (void)
 Return the number of bytes read by the last read operation. More...

virtual IOSize bytesWritten (void)
 Return the number of bytes written so far. More...

virtual bool errorOccurred (void)
 Informs about an error. More...

virtual bool eof (void)
 Informs about an end of file. More...


Protected Attributes

IOSize bWritten
 The number of bytes written so far.

IOSize bRead
 The number of bytes read so far.


Detailed Description

A device for working with files.

This class encapsulates the fstream functionality into the interface of IODevice.

See also:
IODevice, FunnelDevice.

Definition at line 47 of file filedevice.h.


Constructor & Destructor Documentation

FileDevice::FileDevice void   
 

A constructor.

Initialization is performed.

Definition at line 38 of file filedevice.cpp.

References bRead, and bWritten.

FileDevice::~FileDevice void    [virtual]
 

A destructor.

The device is finished.

Definition at line 50 of file filedevice.cpp.

References finish, and IODevice::isPrepared.


Member Function Documentation

IOSize FileDevice::bytesRead void    [virtual]
 

Return the number of bytes read by the last read operation.

Returns the number of bytes read from the device by the last read operation.

Returns:
Number of bytes.

Implements IODevice.

Definition at line 244 of file filedevice.cpp.

References IOSize.

IOSize FileDevice::bytesReadTotal void    [virtual]
 

Return the number of bytes read so far.

Returns the total number of bytes read from the device.

Returns:
Number of bytes.

Implements IODevice.

Definition at line 233 of file filedevice.cpp.

References bRead, and IOSize.

IOSize FileDevice::bytesWritten void    [virtual]
 

Return the number of bytes written so far.

Returns the total number of bytes written to the device.

Returns:
Number of bytes.

Implements IODevice.

Definition at line 255 of file filedevice.cpp.

References bWritten, and IOSize.

bool FileDevice::eof void    [virtual]
 

Informs about an end of file.

This method can be used for tests of the end of file.

Return values:
TRUE  End of file occurred.
FALSE  End of file didn't occurred.

Implements IODevice.

Definition at line 278 of file filedevice.cpp.

bool FileDevice::errorOccurred void    [virtual]
 

Informs about an error.

If any of the IO operations was unsuccessful, this method can be used to test it.

Return values:
TRUE  An error occurred.
FALSE  No error occurred.

Implements IODevice.

Definition at line 267 of file filedevice.cpp.

void FileDevice::finish void    throw (ExaltIOException) [virtual]
 

Finish the work with the device.

This method ends the work with the device. It flushes the file and closes it. An attempt to work with finished device will cause an ExaltIOException to be raised.

Implements IODevice.

Definition at line 102 of file filedevice.cpp.

Referenced by ExaltCodec::decode, ExaltCodec::encode, and ~FileDevice.

void FileDevice::flush void    throw (ExaltIOException) [virtual]
 

Flush the device.

Ensures that all the data is written to the device.

Implements IODevice.

Definition at line 90 of file filedevice.cpp.

IOState FileDevice::getChar int *    c throw (ExaltIOException) [virtual]
 

Read one char.

Reads one character from the device. If an error occurred, ExaltIOException is raised.

Parameters:
c  Pointer where the read character is stored.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 155 of file filedevice.cpp.

References EndOfFile, IOState, and ReadOk.

void FileDevice::prepare const char *    fileName,
int    mode
throw (ExaltIOException) [virtual]
 

Prepare the device with specified file name and mode.

Prepares the device for work with file fileName in mode mode. If fileName is NULL, and mode is ios::in (or ios::out), standard input is used (or standard output).

Parameters:
fileName  The name of the file (or NULL).
mode  The mode.

Definition at line 64 of file filedevice.cpp.

Referenced by ExaltCodec::decode, ExaltCodec::encode, and ExaltCodec::initializePushCoder.

IOState FileDevice::putChar int    c throw (ExaltIOException) [virtual]
 

Write one char.

Writes one character to the device. If an error occurred, ExaltIOException is raised.

Parameters:
c  The character.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 211 of file filedevice.cpp.

References IOState, and WriteOk.

IOState FileDevice::readData char *    buf,
IOSize    length
throw (ExaltIOException) [virtual]
 

Read up to the specified number of bytes into the buffer.

Reads up to length bytes from the device and stores them in buffer. If an error occurred, ExaltIOException is raised.

Parameters:
buf  Pointer to the buffer.
length  Length of the buffer.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 124 of file filedevice.cpp.

References EndOfFile, IOSize, IOState, and ReadOk.

IOState FileDevice::writeData const char *    buf,
IOSize    length
throw (ExaltIOException) [virtual]
 

Write the specified number of bytes from the buffer.

Writes length bytes from the buffer buf to the device. If an error occurred, ExaltIOException is raised.

Parameters:
buf  Pointer to the buffer.
length  Length of the buffer.
Returns:
State of the device after the write operation.

Implements IODevice.

Definition at line 187 of file filedevice.cpp.

References IOSize, IOState, and WriteOk.


The documentation for this class was generated from the following files:
Generated on Wed Feb 5 10:43:05 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002