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

qgar::AbstractFile Class Reference
[Files]

#include <qgarlib/AbstractFile.H>

Inheritance diagram for qgar::AbstractFile:

qgar::AbstractGraphicsFile qgar::AbstractPbmPlusFile qgar::File qgar::MapleFile qgar::DxfFile qgar::TgifFile qgar::PbmFile qgar::PgmFile List of all members.

Detailed Description

Base class implementing common tools to conveniently define and use files in the Qgar way.

Warning:
This is an abstract class. Pure virtual functions:
Author:
Gérald Masini
Date:
Jul 02, 2001 17:13
Since:
Qgar 1.0

Definition at line 108 of file AbstractFile.H.

Public Member Functions

Destructor
virtual ~AbstractFile ()
 Virtual destructor.
Access to file characteristics
std::fstream & fileStream ()
 Get file stream.
const char *const fileName () const
 Get file name.
QGEfileStatus fileStatus () const
 Get current file status.
Opening
virtual void openRONLY () throw (QgarErrorIO)
 Open in read-only mode.
virtual void openWONLY () throw (QgarErrorIO)
 Open in write-only mode.
virtual void openAPPEND () throw (QgarErrorIO)
 Open in append mode.
virtual void openRW () throw (QgarErrorIO)
 Open in read-write mode.
virtual void openRA () throw (QgarErrorIO)
 Open in read-append mode.
Closing
virtual void close ()
 Close the file.
Checking status
virtual void isOpenR () throw (QgarErrorUser)
 Abort if the file is not open in a mode allowing reading.
virtual void isOpenW () throw (QgarErrorUser)
 Abort if the file is not open in a mode allowing writing.
virtual void isOpenA () throw (QgarErrorUser)
 Abort if the file is not open in a mode allowing appending.
virtual void isOpenRW () throw (QgarErrorUser)
 Abort if the file is not open in read-write mode.
virtual void isOpenRA () throw (QgarErrorUser)
 Abort if the file is not open in readi-append mode.

Protected Member Functions

Constructors
Constructors belong to the protected section so that the class cannot be instantiated.

 AbstractFile (const char *aFileName) throw (QgarErrorInvalidArg)
 Create a file of given name.
Headers & footers
virtual void readHeader ()=0
 Read header of the file (pure virtual function).
virtual void writeHeader ()=0
 Write header of the file (pure virtual function).
virtual void writeFooter ()=0
 Write footer of the file (pure virtual function).

Protected Attributes

Representation of a file
char * _fileName
 File name.
QGEfileStatus _fileStatus
 File status.
std::fstream _fileStream
 Associated file stream.


Constructor & Destructor Documentation

qgar::AbstractFile::~AbstractFile  )  [virtual]
 

Virtual destructor.

Free space allocated to character string representing the name of the file

Definition at line 93 of file AbstractFile.C.

References _fileName.

qgar::AbstractFile::AbstractFile const char *  aFileName  )  throw (QgarErrorInvalidArg) [protected]
 

Create a file of given name.

Parameters:
aFileName name of the file
Warning:
The file is closed and must be opened to be used.
Exceptions:
qgar::QgarErrorInvalidArg (incorrect file name)

Definition at line 60 of file AbstractFile.C.


Member Function Documentation

void qgar::AbstractFile::close  )  [virtual]
 

Close the file.

No effect is the file is already closed.

Warning:
If the file is currently open in write-only or read-write modes, a footer is written into the file using function qgar::AbstractFile::writeFooter.

Definition at line 251 of file AbstractFile.C.

References _fileStatus, _fileStream, qgar::QGE_FILE_STATUS_CLOSED, qgar::QGE_FILE_STATUS_READ_WRITE, qgar::QGE_FILE_STATUS_WRITE_ONLY, and writeFooter().

Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), qgar::MapleFile::MapleFile(), openAPPEND(), openRA(), openRONLY(), openRW(), openWONLY(), and qgar::GenImage< T, CheckPolicy >::save().

const char *const qgar::AbstractFile::fileName  )  const [inline]
 

Get file name.

Definition at line 395 of file AbstractFile.H.

References _fileName.

QGEfileStatus qgar::AbstractFile::fileStatus  )  const [inline]
 

Get current file status.

Definition at line 404 of file AbstractFile.H.

References _fileStatus.

std::fstream & qgar::AbstractFile::fileStream  )  [inline]
 

Get file stream.

When saving the stream, usual I/O operations apply to the associated file, depending on the opening mode.

Definition at line 386 of file AbstractFile.H.

References _fileStream.

void qgar::AbstractFile::isOpenA  )  throw (QgarErrorUser) [virtual]
 

Abort if the file is not open in a mode allowing appending.

Exceptions:
qgar::QgarErrorUser (file not open in append mode)

Definition at line 310 of file AbstractFile.C.

References _fileName, _fileStatus, qgar::QGE_FILE_STATUS_APPEND, and qgar::QGE_FILE_STATUS_READ_APPEND.

void qgar::AbstractFile::isOpenR  )  throw (QgarErrorUser) [virtual]
 

Abort if the file is not open in a mode allowing reading.

Exceptions:
qgar::QgarErrorUser (file not open in read mode)

Definition at line 273 of file AbstractFile.C.

References _fileName, _fileStatus, qgar::QGE_FILE_STATUS_APPEND, and qgar::QGE_FILE_STATUS_WRITE_ONLY.

Referenced by qgar::PgmFile::readRow(), and qgar::PbmFile::readRow().

void qgar::AbstractFile::isOpenRA  )  throw (QgarErrorUser) [virtual]
 

Abort if the file is not open in readi-append mode.

Exceptions:
qgar::QgarErrorUser (file not open in read/append mode)

Definition at line 347 of file AbstractFile.C.

References _fileName, _fileStatus, and qgar::QGE_FILE_STATUS_READ_APPEND.

void qgar::AbstractFile::isOpenRW  )  throw (QgarErrorUser) [virtual]
 

Abort if the file is not open in read-write mode.

Exceptions:
qgar::QgarErrorUser (file not open in read/write mode)

Definition at line 329 of file AbstractFile.C.

References _fileName, _fileStatus, and qgar::QGE_FILE_STATUS_READ_WRITE.

void qgar::AbstractFile::isOpenW  )  throw (QgarErrorUser) [virtual]
 

Abort if the file is not open in a mode allowing writing.

Exceptions:
qgar::QgarErrorUser (file not open in write mode)

Definition at line 292 of file AbstractFile.C.

References _fileName, _fileStatus, and qgar::QGE_FILE_STATUS_READ_ONLY.

Referenced by qgar::TgifFile::write(), qgar::DxfFile::write(), qgar::PgmFile::writeRow(), and qgar::PbmFile::writeRow().

void qgar::AbstractFile::openAPPEND  )  throw (QgarErrorIO) [virtual]
 

Open in append mode.

The eventual content of the file is preserved and the file pointer is set to the end of the file.

Warning:
The file header is read using function qgar::AbstractFile::readHeader.
Exceptions:
qgar::QgarErrorIO (file cannot be opened)

Definition at line 166 of file AbstractFile.C.

References _fileName, _fileStatus, _fileStream, close(), qgar::QGE_FILE_STATUS_APPEND, and readHeader().

void qgar::AbstractFile::openRA  )  throw (QgarErrorIO) [virtual]
 

Open in read-append mode.

The file pointer is set to the end of the file.

Warning:
The file header is read using function qgar::AbstractFile::readHeader.
Exceptions:
qgar::QgarErrorIO (file cannot be opened)

Definition at line 223 of file AbstractFile.C.

References _fileName, _fileStatus, _fileStream, close(), qgar::QGE_FILE_STATUS_READ_APPEND, and readHeader().

void qgar::AbstractFile::openRONLY  )  throw (QgarErrorIO) [virtual]
 

Open in read-only mode.

The file pointer is set to the first character after the header.

Warning:
The file header is read using function qgar::AbstractFile::readHeader.
Exceptions:
qgar::QgarErrorIO (file cannot be opened)

Definition at line 107 of file AbstractFile.C.

References _fileName, _fileStatus, _fileStream, close(), qgar::QGE_FILE_STATUS_READ_ONLY, and readHeader().

Referenced by qgar::GenImage< T, CheckPolicy >::GenImage().

void qgar::AbstractFile::openRW  )  throw (QgarErrorIO) [virtual]
 

Open in read-write mode.

Warning:
The file is new and a header is written into the file using function qgar::AbstractFile::writeHeader. If a file with given name already exists, its content is lost.
Exceptions:
qgar::QgarErrorIO (file cannot be opened)

Definition at line 197 of file AbstractFile.C.

References _fileName, _fileStatus, _fileStream, close(), qgar::QGE_FILE_STATUS_READ_WRITE, and writeHeader().

void qgar::AbstractFile::openWONLY  )  throw (QgarErrorIO) [virtual]
 

Open in write-only mode.

Warning:
The file is new and a header is written into the file using function qgar::AbstractFile::writeHeader. If a file with given name already exists, its content is lost.
Exceptions:
qgar::QgarErrorIO (file cannot be opened)

Definition at line 136 of file AbstractFile.C.

References _fileName, _fileStatus, _fileStream, close(), qgar::QGE_FILE_STATUS_WRITE_ONLY, and writeHeader().

Referenced by qgar::MapleFile::MapleFile(), and qgar::GenImage< T, CheckPolicy >::save().

virtual void qgar::AbstractFile::readHeader  )  [protected, pure virtual]
 

Read header of the file (pure virtual function).

Automatically performed when the file is opened for reading, appending or reading/appending.

Implemented in qgar::DxfFile, qgar::File, qgar::MapleFile, qgar::PbmFile, qgar::PgmFile, and qgar::TgifFile.

Referenced by openAPPEND(), openRA(), and openRONLY().

virtual void qgar::AbstractFile::writeFooter  )  [protected, pure virtual]
 

Write footer of the file (pure virtual function).

Automatically performed when the file is closed.

Implemented in qgar::DxfFile, qgar::File, qgar::MapleFile, qgar::PbmFile, qgar::PgmFile, and qgar::TgifFile.

Referenced by close().

virtual void qgar::AbstractFile::writeHeader  )  [protected, pure virtual]
 

Write header of the file (pure virtual function).

Automatically performed when the file is opened for writing only or reading/writing.

Implemented in qgar::DxfFile, qgar::File, qgar::MapleFile, qgar::PbmFile, qgar::PgmFile, and qgar::TgifFile.

Referenced by openRW(), and openWONLY().


Member Data Documentation

char* qgar::AbstractFile::_fileName [protected]
 

File name.

Definition at line 349 of file AbstractFile.H.

Referenced by fileName(), qgar::PbmFile::getBit(), qgar::AbstractPbmPlusFile::getChar(), qgar::AbstractPbmPlusFile::getInt(), qgar::AbstractPbmPlusFile::getRawByte(), isOpenA(), isOpenR(), isOpenRA(), isOpenRW(), isOpenW(), openAPPEND(), openRA(), openRONLY(), openRW(), openWONLY(), qgar::PgmFile::readHeader(), qgar::PbmFile::readHeader(), qgar::DxfFile::readHeader(), qgar::DxfFile::retrieveChainOrQgarPolyline(), and ~AbstractFile().

QGEfileStatus qgar::AbstractFile::_fileStatus [protected]
 

File status.

Definition at line 354 of file AbstractFile.H.

Referenced by close(), fileStatus(), isOpenA(), isOpenR(), isOpenRA(), isOpenRW(), isOpenW(), openAPPEND(), openRA(), openRONLY(), openRW(), and openWONLY().

std::fstream qgar::AbstractFile::_fileStream [protected]
 

Associated file stream.

Definition at line 359 of file AbstractFile.H.

Referenced by qgar::TgifFile::beginSavePoly(), close(), qgar::TgifFile::endSavePoly(), fileStream(), qgar::AbstractPbmPlusFile::getChar(), qgar::AbstractPbmPlusFile::getRawByte(), qgar::MapleFile::MapleFile(), openAPPEND(), openRA(), openRONLY(), openRW(), openWONLY(), qgar::PgmFile::readHeader(), qgar::PbmFile::readHeader(), qgar::DxfFile::retrieveDxfGroup(), qgar::TgifFile::saveArc(), qgar::TgifFile::saveBox(), qgar::TgifFile::saveChain(), qgar::TgifFile::saveCircle(), qgar::DxfFile::saveDxfGroup(), qgar::TgifFile::savePoint(), qgar::TgifFile::savePolyline(), qgar::TgifFile::saveSegment(), qgar::TgifFile::writeHeader(), qgar::PgmFile::writeHeader(), qgar::PbmFile::writeHeader(), qgar::MapleFile::writeHeader(), qgar::DxfFile::writeHeader(), qgar::PgmFile::writeRow(), and qgar::PbmFile::writeRow().


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