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

TextFile.h

00001 /*
00002   File: TextFile.h
00003 
00004   Copyright(C) C. Kotterink, Computed Graphics
00005 */
00006 #ifndef TEXTFILE_H
00007 #define TEXTFILE_H
00008 
00009 #include<stdio.h>
00010 #include<string>
00011 
00014 class TextFile
00015 {
00016 public:
00018     TextFile() : f(NULL), l(1) {
00019     }
00020 
00022     TextFile(const TextFile &f) : fileName(tf.fileName), f(tf.f), l(tf.l) {
00023     }
00024 
00026     ~TextFile() {
00027         close();
00028     }
00029 
00031     const string &name() const {
00032         return fileName;
00033     }
00034 
00036     unsigned int line() const {
00037         return l;
00038     }
00039 
00041     bool eof() {
00042         return feof(f);
00043     }
00044 
00046     int currentChar() {
00047         return ch;
00048     }
00049 
00051     void open(const string &name);
00052 
00054     void create(const string &name);
00055 
00057     void close();
00058 
00060     void flush() {
00061         fflush(f);
00062     }
00063 
00065     TextFile &operator<<(const string &line);
00066 
00068     int getChar();
00069 
00070 private:
00072     string fileName;
00073 
00075     FILE *f;
00076 
00078     int l;
00079 
00081     int ch;
00082 };
00083 #endif

This documentation was generated using doxygen. If you have any comments or additions please mail me.