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

TextFile Class Reference

Text file. More...

#include <TextFile.h>

List of all members.

Public Methods

 TextFile ()
 Default constuctor.

 TextFile (const TextFile &f)
 Constuct and open a file.

 ~TextFile ()
 Destructor, closes the file.

const string & name () const
 Returns the file name.

unsigned int line () const
 Returns the current line number.

bool eof ()
 Returns true iff end of file has been reached.

int currentChar ()
 Returns the current cached character.

void open (const string &name)
 Opens a text file for reading. More...

void create (const string &name)
 . More...

void close ()
 Creates a text file for writing. More...

void flush ()
 Flushes the file.

TextFile & operator<< (const string &line)
 Writes a string to the text file. More...

int getChar ()
 Reads and returns the next character. More...


Detailed Description

Text file.


Member Function Documentation

void TextFile::close  
 

Creates a text file for writing.

Precondition:
none.
Postcondition:
The file has been closed.

void TextFile::create const string &    name
 

.

Parameters:
name  Name of the file to create.
Precondition:
none.
Postcondition:
The file is created and open for writing.
Exceptions:
runtime_error  When the file could not be created.

int TextFile::getChar  
 

Reads and returns the next character.

Precondition:
The file has been opened for reading.
Postcondition:
  • A character is read and is cached.
  • The line counter is incremented if a new line was previously seen.
Returns:
Character that was read.

void TextFile::open const string &    name
 

Opens a text file for reading.

Parameters:
name  Name of the file to open.
Precondition:
none.
Postcondition:
The file is open for reading.
Exceptions:
runtime_error  When the file could not be opened.

TextFile & TextFile::operator<< const string &    line
 

Writes a string to the text file.

Parameters:
line  The string to write to file.
Precondition:
The file has been opened for writing.
Postcondition:
All characters in line are written to file.
Returns:
Reference to this.
Note:
No new line is appended.


The documentation for this class was generated from the following files:
This documentation was generated using doxygen. If you have any comments or additions please mail me.