A class for reading text data from a text file. More...
#include <textfile.h>
Public Member Functions | |
textfile () | |
The default constructor. | |
textfile (std::istream &in) | |
A constructor for an opened file. | |
int | open (const char *filename) |
Opens a file with the given name. | |
void | close () |
Closes the file. | |
~textfile () | |
The destructor. | |
long | readnumber (long defaultnumber=0, int ignorecolons=0) |
Read an integer number from the input file. | |
int | checkchar () |
Returns the first non-white character waiting to be read. | |
int | readchar () |
Read one non-white character from the file. | |
int | readword (char *buf, int maxlength) |
Reads one word from the file and returns its actual length. | |
int | readphrase (const char *phrase) |
Reads a strongly expected phrase from the file. | |
void | ignoreline () |
Ignore the current line from the current position to the end of line, including the end of line character. | |
long | linenumber () |
Returns the current line number. | |
operator int () | |
Returns the text file's status: 0 = not opened, 1 = opened, 13 = initialized with an input stream. | |
Private Member Functions | |
void | ignorespaces () |
Ignores white characters and fills in the variable 'ch' with the first non-white character. | |
Private Attributes | |
int | ch |
The character already read and waiting to be interpreted. | |
long | line |
The current line number. | |
std::ifstream * | fs |
The true file if it was opened. | |
std::istream * | s |
A pointer to an input stream (usually equal to 'fs'). |
A class for reading text data from a text file.
All blank characters and comments are ignored. NOTE: This class is deprecated, it is recommended to use the class std::istream directly.
Definition at line 528 of file textfile.h.
chomp::homology::textfile::textfile | ( | ) |
The default constructor.
chomp::homology::textfile::textfile | ( | std::istream & | in | ) |
A constructor for an opened file.
chomp::homology::textfile::~textfile | ( | ) |
The destructor.
int chomp::homology::textfile::checkchar | ( | ) |
Returns the first non-white character waiting to be read.
Returns EOF if end-of-file has been reached.
void chomp::homology::textfile::close | ( | ) |
Closes the file.
void chomp::homology::textfile::ignoreline | ( | ) |
Ignore the current line from the current position to the end of line, including the end of line character.
void chomp::homology::textfile::ignorespaces | ( | ) | [private] |
Ignores white characters and fills in the variable 'ch' with the first non-white character.
long chomp::homology::textfile::linenumber | ( | ) |
Returns the current line number.
int chomp::homology::textfile::open | ( | const char * | filename | ) |
Opens a file with the given name.
Returns 1 if a file associated with this object has already been opened before, 0 on success, -1 in case of an error (no message is displayed).
chomp::homology::textfile::operator int | ( | ) |
Returns the text file's status: 0 = not opened, 1 = opened, 13 = initialized with an input stream.
int chomp::homology::textfile::readchar | ( | ) |
Read one non-white character from the file.
Return EOF if end-of-file has been reached.
long chomp::homology::textfile::readnumber | ( | long | defaultnumber = 0 , |
|
int | ignorecolons = 0 | |||
) |
Read an integer number from the input file.
If none can be read, returns the suggested default value. If requested, ignores a preceding ':', '=' or ',' if any.
int chomp::homology::textfile::readphrase | ( | const char * | phrase | ) |
Reads a strongly expected phrase from the file.
Ignores white characters before the phrase and inside it. Returns 0 on success, -1 if the phrase was not present in the input (shows an error message in that case).
int chomp::homology::textfile::readword | ( | char * | buf, | |
int | maxlength | |||
) |
Reads one word from the file and returns its actual length.
int chomp::homology::textfile::ch [private] |
The character already read and waiting to be interpreted.
Definition at line 587 of file textfile.h.
std::ifstream* chomp::homology::textfile::fs [private] |
The true file if it was opened.
Definition at line 593 of file textfile.h.
long chomp::homology::textfile::line [private] |
The current line number.
Definition at line 590 of file textfile.h.
std::istream* chomp::homology::textfile::s [private] |
A pointer to an input stream (usually equal to 'fs').
Definition at line 596 of file textfile.h.