#ifndef __cplusplus
#error <stream.h> must be compiled in C++ mode.
#pragma +
#endif

#ifndef _INCLUDE_STREAM_H
#define _INCLUDE_STREAM_H

#ifndef EOF
#define EOF (-1)
#endif

struct stream;

typedef stream FILE;

class form
{  struct tmpstr
   { tmpstr *link;
     char *dynamicstr;
   } *string;
  public:
   form(const char*, ...);
   ~form();
};

class ios
{ protected:
    FILE *file;
    unsigned char basefield;
    unsigned char GUESS, WHAT, FOR;
  public:
    ios(FILE *f=0);
    FILE *getstream();
    operator void*();

    enum open_mode { in=1, out=2, app=4 };
    enum seek_dir { beg=-1, cur=0, end=1 };
};

ios &flush(ios&);
ios &endl(ios&);
ios &dec(ios&);
ios &hex(ios&);
ios &oct(ios&);

class ostream: public virtual ios
{ protected:
    unsigned char Reserved;
  public:
    ostream(FILE *f=0);
    ostream &operator << (int);
    ostream &operator << (unsigned);
    ostream &operator << (long);
    ostream &operator << (unsigned long);
    ostream &operator << (long long);
    ostream &operator << (unsigned long long);
    ostream &operator << (char);
    ostream &operator << (unsigned char);
    ostream &operator << (signed char);
    ostream &operator << (const char *);
    ostream &operator << (float);
    ostream &operator << (double);
    ostream &operator << (long double);
    ostream &operator << (form &);
    ostream &operator << (const void*);
    ostream &operator << (ios&(*f)(ios&));
    ostream &put(char);
    ostream &write(const char*, int);
};

class istream : public virtual ios
{ protected:
    unsigned char errorflag;
  public:
    istream(FILE *f=0);
    istream &operator >> (char *);
    istream &operator >> (unsigned char *);
    istream &operator >> (char&);
    istream &operator >> (unsigned char&);
    istream &operator >> (signed char&);
    istream &operator >> (short&);
    istream &operator >> (unsigned short&);
    istream &operator >> (int&);
    istream &operator >> (unsigned &);
    istream &operator >> (long&);
    istream &operator >> (unsigned long&);
    istream &operator >> (long long&);
    istream &operator >> (unsigned long long&);
    istream &operator >> (float&);
    istream &operator >> (double&);
    istream &operator >> (long double&);
    istream &read(char *,int);
    istream &get(char &);
    istream &get(unsigned char &);
    int      get();
    istream &getline(char *buf, int len, char Delim = '\n');
    istream &putback(char);
    int eof();
    operator void*();
};

#define STREAM_MAXSTRING 80     // maximal von ">>" in String gelesene Zeichen

extern ostream cout, cerr, clog;
extern istream cin;
void exit(int);

#endif

