Download the header file.

#ifndef _FILEIO
#define _FILEIO

#include <iostream.h>
#include <fstream.h>
#include "str.h"


class FileReader
{
    ifstream  file;
    char     *buffer;
    char     *cursor;
    char     *end;
    long      size;
    long      line;
    bool      eof;

  public:
                FileReader();
                FileReader(long);
                ~FileReader();
    void        SetSize(long);
    bool        Open(const Str&);
    bool        Open(const char*);
    void        Close()                       { file.close(); };
    void        Read();
    bool        IsEndOfFile()                 { return eof && cursor == end; };
    long        GetLineNumber()               { return line; };
    void        Begin()                       { cursor = buffer; };
    char        Get()                  const  { return *cursor; };
    bool        SkipSpaces();
    long        GetPosition()          const  { return cursor - buffer; };
    bool        GetCharacter(char&);
    bool        GetToken(Str&);
    bool        SkipToken(int n=1);
    bool        GetToken(Str&, char);
    bool        SkipToken(char, int n=1);
    bool        GetLine(Str&);
    bool        GetTextLine(Str&);
    bool        SkipLine(int n=1);
    FileReader &operator>>(Str&);
};

//_____________________________________________________

class FileWriter
{
    ofstream  file;
    char     *buffer;
    char     *cursor;
    char     *end;
    long      size;

  public:
                        FileWriter();
                        FileWriter(long);
    virtual             ~FileWriter();
            void        SetSize(long);
            bool        Open(const Str&);
            bool        Open(const char*);
    virtual void        Close()                       { file.close(); };
    virtual void        Write();
    virtual void        Append(const Str&);
    virtual void        Append(const char*);
    virtual void        Append(char);
    virtual void        Append(long);
    virtual void        Append(double);
    virtual void        Append(const Str&, char);
    virtual void        Append(const char*, char);
    virtual void        Append(char, char);
    virtual void        Append(long, char);
    virtual void        Append(double, char);
    virtual void        Append(const Str&, long, bool justify=false);
    virtual void        Append(const char*, long, bool justify=false);
    virtual void        Append(char, long, bool justify=false);
    virtual void        Append(long, long, bool justify=false);
    virtual void        Append(double, long, bool justify=false);
    virtual FileWriter &operator<<(const Str&);
    virtual FileWriter &operator<<(const char*);
    virtual FileWriter &operator<<(char);
    virtual FileWriter &operator<<(long);
    virtual FileWriter &operator<<(double);
            void        RemoveEndBlankLines();
};

//_____________________________________________________

class CoutWriter : public FileWriter
{
  public:
                CoutWriter()                   { };
                ~CoutWriter()                  { };
    void        Close()                        { };
    void        Write()                        { };
    void        Append(const Str &s)           { cout << s; };
    void        Append(const char *s)          { cout << s; };
    void        Append(char s)                 { cout << s; };
    void        Append(long n)                 { cout << n; };
    void        Append(double n)               { cout << n; };
    void        Append(const Str &s, char c)   { cout << s << c; };
    void        Append(const char *s, char c)  { cout << s << c; };
    void        Append(char s, char c)         { cout << s << c; };
    void        Append(long n, char c)         { cout << n << c; };
    void        Append(double n, char c)       { cout << n << c; };
    void        Append(const Str&, long, bool justify=false);
    void        Append(const char*, long, bool justify=false);
    void        Append(char, long, bool justify=false);
    void        Append(long, long, bool justify=false);
    void        Append(double, long, bool justify=false);
    FileWriter &operator<<(const Str &s);
    FileWriter &operator<<(const char *s);
    FileWriter &operator<<(char s);
    FileWriter &operator<<(long n);
    FileWriter &operator<<(double n);
};

#endif