#include <qgarlib/PbmFile.H>
Inheritance diagram for qgar::PbmFile:

Most of the code documented here is an adaptation of code from the PBM software package. Here is the copyright notice of this package:
+------------------------------------------------------------------------+ | Copyright (C) 1988 by Jef Poskanzer | | | | Permission to use, copy, modify, and distribute this software and its | | documentation for any purpose and without fee is hereby granted, | | provided that the above copyright notice appear in all copies and that | | both that copyright notice and this permission notice appear in | | supporting documentation. This software is provided "as is" without | | express or implied warranty. | +------------------------------------------------------------------------+
Definition at line 82 of file PbmFile.H.
Public Member Functions | |
Constructors | |
| PbmFile (const char *aFileName, QGEpbmFormat aFormat=QGE_PBM_RAW) | |
| Initialize from file name and format. | |
| PbmFile (const char *aFileName, unsigned int aRowCnt, unsigned int aColCnt, QGEpbmFormat aFormat=QGE_PBM_RAW) | |
| Initialize from full data. | |
Input | |
| void | readRow () |
| Read a row from the file. | |
Output | |
| void | writeRow () |
| Write a row into the file. | |
Access | |
| int | colCnt () const |
| Get number of columns. | |
| int | rowCnt () const |
| Get number of rows. | |
| unsigned char * | pRow () |
| Get current row. | |
Assignment | |
| void | setColCnt (int aCnt) |
| Set number of columns. | |
| void | setRowCnt (int aCnt) |
| Set number of rows. | |
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 | |
Input | |
| void | readHeader () throw (QgarErrorIO) |
| Read file header and allocate a new row. | |
| unsigned char | getBit () throw (QgarErrorIO) |
| Return the next bit from the file. | |
Output | |
| void | writeHeader () |
| Write file header. | |
| void | writeFooter () |
| Write file footer. | |
Input auxiliaries | |
| virtual char | getChar () throw (QgarErrorIO) |
| Read a character from the file. | |
| virtual int | getInt () throw (QgarErrorIO) |
| Read an integer from the file. | |
| virtual unsigned char | getRawByte () throw (QgarErrorIO) |
| Read a raw byte from the file. | |
Memory space allocation | |
| void | newRow () |
| Allocate a new row. | |
Protected Attributes | |
Representation of a file | |
| QGEpbmFormat | _format |
| Format of the file. | |
| int | _rowCnt |
| Number of rows of the image. | |
| int | _colCnt |
| Number of columns of the image. | |
| unsigned char * | _pRow |
| Pointer to current image row. | |
Representation of a file | |
| char * | _fileName |
| File name. | |
| QGEfileStatus | _fileStatus |
| File status. | |
| std::fstream | _fileStream |
| Associated file stream. | |
Static Protected Attributes | |
Magic numbers | |
| static const unsigned short | _s_pbm_format |
| PLAIN format. | |
| static const unsigned char | _s_pbm_magic1 = 'P' |
| PLAIN format: Magic-1. | |
| static const unsigned char | _s_pbm_magic2 = '1' |
| PLAIN format: Magic-2. | |
| static const unsigned short | _s_rpbm_format |
| RAW format. | |
| static const unsigned char | _s_rpbm_magic2 = '4' |
| RAW format: Magic-2. | |
|
||||||||||||
|
Initialize from file name and format.
|
|
||||||||||||||||||||
|
Initialize from full data.
|
|
|
Close the file. No effect is the file is already closed.
Definition at line 251 of file AbstractFile.C. References qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::QGE_FILE_STATUS_CLOSED, qgar::QGE_FILE_STATUS_READ_WRITE, qgar::QGE_FILE_STATUS_WRITE_ONLY, and qgar::AbstractFile::writeFooter(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), qgar::MapleFile::MapleFile(), qgar::AbstractFile::openAPPEND(), qgar::AbstractFile::openRA(), qgar::AbstractFile::openRONLY(), qgar::AbstractFile::openRW(), qgar::AbstractFile::openWONLY(), and qgar::GenImage< T, CheckPolicy >::save(). |
|
|
Get number of columns.
Definition at line 328 of file AbstractPbmPlusFile.H. References qgar::AbstractPbmPlusFile::_colCnt. Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(). |
|
|
Get file name.
Definition at line 395 of file AbstractFile.H. References qgar::AbstractFile::_fileName. |
|
|
Get current file status.
Definition at line 404 of file AbstractFile.H. References qgar::AbstractFile::_fileStatus. |
|
|
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 qgar::AbstractFile::_fileStream. |
|
|
Return the next bit from the file.
Definition at line 219 of file PbmFile.C. References qgar::AbstractFile::_fileName, and qgar::AbstractPbmPlusFile::getChar(). Referenced by readRow(). |
|
|
Read a character from the file.
Definition at line 125 of file AbstractPbmPlusFile.C. References qgar::AbstractFile::_fileName, and qgar::AbstractFile::_fileStream. Referenced by getBit(), and qgar::AbstractPbmPlusFile::getInt(). |
|
|
Read an integer from the file.
Definition at line 169 of file AbstractPbmPlusFile.C. References qgar::AbstractFile::_fileName, and qgar::AbstractPbmPlusFile::getChar(). Referenced by qgar::PgmFile::readHeader(), readHeader(), and qgar::PgmFile::readRow(). |
|
|
Read a raw byte from the file.
Definition at line 207 of file AbstractPbmPlusFile.C. References qgar::AbstractFile::_fileName, and qgar::AbstractFile::_fileStream. Referenced by qgar::PgmFile::readRow(), and readRow(). |
|
|
Abort if the file is not open in a mode allowing appending.
Definition at line 310 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::QGE_FILE_STATUS_APPEND, and qgar::QGE_FILE_STATUS_READ_APPEND. |
|
|
Abort if the file is not open in a mode allowing reading.
Definition at line 273 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::QGE_FILE_STATUS_APPEND, and qgar::QGE_FILE_STATUS_WRITE_ONLY. Referenced by qgar::PgmFile::readRow(), and readRow(). |
|
|
Abort if the file is not open in readi-append mode.
Definition at line 347 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, and qgar::QGE_FILE_STATUS_READ_APPEND. |
|
|
Abort if the file is not open in read-write mode.
Definition at line 329 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, and qgar::QGE_FILE_STATUS_READ_WRITE. |
|
|
Abort if the file is not open in a mode allowing writing.
Definition at line 292 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, and qgar::QGE_FILE_STATUS_READ_ONLY. Referenced by qgar::TgifFile::write(), qgar::DxfFile::write(), qgar::PgmFile::writeRow(), and writeRow(). |
|
|
Allocate a new row.
Definition at line 234 of file AbstractPbmPlusFile.C. References qgar::AbstractPbmPlusFile::_colCnt, and qgar::AbstractPbmPlusFile::_pRow. Referenced by qgar::PgmFile::readHeader(), readHeader(), qgar::PgmFile::writeHeader(), and writeHeader(). |
|
|
Open in append mode. The eventual content of the file is preserved and the file pointer is set to the end of the file.
Definition at line 166 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::AbstractFile::close(), qgar::QGE_FILE_STATUS_APPEND, and qgar::AbstractFile::readHeader(). |
|
|
Open in read-append mode. The file pointer is set to the end of the file.
Definition at line 223 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::AbstractFile::close(), qgar::QGE_FILE_STATUS_READ_APPEND, and qgar::AbstractFile::readHeader(). |
|
|
Open in read-only mode. The file pointer is set to the first character after the header.
Definition at line 107 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::AbstractFile::close(), qgar::QGE_FILE_STATUS_READ_ONLY, and qgar::AbstractFile::readHeader(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(). |
|
|
Open in read-write mode.
Definition at line 197 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::AbstractFile::close(), qgar::QGE_FILE_STATUS_READ_WRITE, and qgar::AbstractFile::writeHeader(). |
|
|
Open in write-only mode.
Definition at line 136 of file AbstractFile.C. References qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStatus, qgar::AbstractFile::_fileStream, qgar::AbstractFile::close(), qgar::QGE_FILE_STATUS_WRITE_ONLY, and qgar::AbstractFile::writeHeader(). Referenced by qgar::MapleFile::MapleFile(), and qgar::GenImage< T, CheckPolicy >::save(). |
|
|
Get current row.
Definition at line 346 of file AbstractPbmPlusFile.H. References qgar::AbstractPbmPlusFile::_pRow. Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), qgar::PgmFile::readRow(), readRow(), qgar::GenImage< T, CheckPolicy >::save(), qgar::PgmFile::writeRow(), and writeRow(). |
|
|
Read file header and allocate a new row.
Implements qgar::AbstractFile. Definition at line 126 of file PbmFile.C. References qgar::AbstractPbmPlusFile::_colCnt, qgar::AbstractFile::_fileName, qgar::AbstractFile::_fileStream, qgar::AbstractPbmPlusFile::_format, qgar::AbstractPbmPlusFile::_rowCnt, _s_pbm_format, _s_rpbm_format, qgar::AbstractPbmPlusFile::getInt(), qgar::AbstractPbmPlusFile::newRow(), qgar::QGE_PBM_PLAIN, and qgar::QGE_PBM_RAW. |
|
|
Read a row from the file.
Implements qgar::AbstractPbmPlusFile. Definition at line 182 of file PbmFile.C. References qgar::AbstractPbmPlusFile::_colCnt, qgar::AbstractPbmPlusFile::_format, qgar::AbstractPbmPlusFile::_pRow, getBit(), qgar::AbstractPbmPlusFile::getRawByte(), qgar::AbstractFile::isOpenR(), qgar::AbstractPbmPlusFile::pRow(), qgar::QGE_PBM_PLAIN, and qgar::QGE_PBM_RAW. |
|
|
Get number of rows.
Definition at line 337 of file AbstractPbmPlusFile.H. References qgar::AbstractPbmPlusFile::_rowCnt. Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(). |
|
|
Set number of columns.
Definition at line 360 of file AbstractPbmPlusFile.H. References qgar::AbstractPbmPlusFile::_colCnt. Referenced by qgar::GenImage< T, CheckPolicy >::save(). |
|
|
Set number of rows.
Definition at line 369 of file AbstractPbmPlusFile.H. References qgar::AbstractPbmPlusFile::_rowCnt. Referenced by qgar::GenImage< T, CheckPolicy >::save(). |
|
|
Write file footer.
Implements qgar::AbstractFile. |
|
|
Write file header.
Implements qgar::AbstractFile. Definition at line 254 of file PbmFile.C. References qgar::AbstractPbmPlusFile::_colCnt, qgar::AbstractFile::_fileStream, qgar::AbstractPbmPlusFile::_format, qgar::AbstractPbmPlusFile::_rowCnt, _s_pbm_magic1, _s_pbm_magic2, _s_rpbm_magic2, qgar::AbstractPbmPlusFile::newRow(), and qgar::QGE_PBM_RAW. |
|
|
Write a row into the file.
Implements qgar::AbstractPbmPlusFile. Definition at line 280 of file PbmFile.C. References qgar::AbstractPbmPlusFile::_colCnt, qgar::AbstractFile::_fileStream, qgar::AbstractPbmPlusFile::_format, qgar::AbstractPbmPlusFile::_pRow, qgar::AbstractFile::isOpenW(), qgar::AbstractPbmPlusFile::pRow(), and qgar::QGE_PBM_RAW. |
|
|
Number of columns of the image.
Definition at line 258 of file AbstractPbmPlusFile.H. Referenced by qgar::AbstractPbmPlusFile::colCnt(), qgar::AbstractPbmPlusFile::newRow(), qgar::PgmFile::readHeader(), readHeader(), qgar::PgmFile::readRow(), readRow(), qgar::AbstractPbmPlusFile::setColCnt(), qgar::PgmFile::writeHeader(), writeHeader(), qgar::PgmFile::writeRow(), and writeRow(). |
|
|
|
|
|
Format of the file.
Definition at line 248 of file AbstractPbmPlusFile.H. Referenced by qgar::PgmFile::readHeader(), readHeader(), qgar::PgmFile::readRow(), readRow(), qgar::PgmFile::writeHeader(), writeHeader(), qgar::PgmFile::writeRow(), and writeRow(). |
|
|
Pointer to current image row.
Definition at line 263 of file AbstractPbmPlusFile.H. Referenced by qgar::AbstractPbmPlusFile::newRow(), qgar::AbstractPbmPlusFile::pRow(), qgar::PgmFile::readRow(), readRow(), qgar::PgmFile::writeRow(), writeRow(), and qgar::AbstractPbmPlusFile::~AbstractPbmPlusFile(). |
|
|
Number of rows of the image.
Definition at line 253 of file AbstractPbmPlusFile.H. Referenced by qgar::PgmFile::readHeader(), readHeader(), qgar::AbstractPbmPlusFile::rowCnt(), qgar::AbstractPbmPlusFile::setRowCnt(), qgar::PgmFile::writeHeader(), and writeHeader(). |
|
|
Initial value: (((unsigned short) PbmFile::_s_pbm_magic1) * 256) + (unsigned short) PbmFile::_s_pbm_magic2
Definition at line 77 of file PbmFile.C. Referenced by readHeader(). |
|
|
PLAIN format: Magic-1.
Definition at line 73 of file PbmFile.C. Referenced by writeHeader(). |
|
|
PLAIN format: Magic-2.
Definition at line 75 of file PbmFile.C. Referenced by writeHeader(). |
|
|
Initial value: (((unsigned short) PbmFile::_s_pbm_magic1) * 256) + (unsigned short) PbmFile::_s_rpbm_magic2
Definition at line 83 of file PbmFile.C. Referenced by readHeader(). |
|
|
RAW format: Magic-2.
Definition at line 81 of file PbmFile.C. Referenced by writeHeader(). |