home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 6 / Sonderheft_6-96.iso / demo-versionen / stormc_v1.05-demo / include / fstream.h < prev    next >
C/C++ Source or Header  |  1996-11-03  |  2KB  |  99 lines

  1. #ifndef _INCLUDE_FSTREAM_H
  2. #define _INCLUDE_FSTREAM_H
  3.  
  4. /*
  5. **  $VER: fstream.h 1.0 (25.1.96)
  6. **  StormC Release 1.0
  7. **
  8. **  '(C) Copyright 1995 Haage & Partner Computer GmbH'
  9. **     All Rights Reserved
  10. */
  11.  
  12. #ifndef __cplusplus
  13. #error <fstream.h> must be compiled in C++ mode.
  14. #pragma +
  15. #endif
  16.  
  17. #ifndef _INCLUDE_STDDEF_H
  18. #include <stddef.h>
  19. #endif
  20.  
  21. #ifndef _INCLUDE_IOSTREAM_H
  22. #include <iostream.h>
  23. #endif
  24.  
  25. #ifndef DOS_DOS_H
  26. #include <dos/dos.h>
  27. #endif
  28.  
  29. class filebuf : public streambuf {
  30. public:
  31.     filebuf();
  32.     virtual ~filebuf();
  33.     int is_open() { return aFile != NULL; };
  34.     filebuf *open(const char *, int);
  35.     filebuf *close();
  36.     virtual streampos seekoff(streamoff, ios::seek_dir, int = ios::in|ios::out);
  37.     virtual streampos seekpos(streampos, int = ios::in|ios::out);
  38.     virtual streambuf *setbuf(char *, size_t);
  39.     virtual int sync();
  40. protected:
  41.     virtual int doallocate();
  42.     virtual int overflow(int = EOF);
  43.     virtual int underflow();
  44.     virtual int xsputn(const char *, int);
  45.     virtual int xsgetn(char *, int);
  46.     virtual int pbackfail(int);
  47. protected:
  48.     BPTR aFile;
  49.     int aGetPos;
  50.     int aOpenMode;
  51. };
  52.  
  53. class fstream : public iostream {
  54. public:
  55.     fstream();
  56.     fstream(const char *, int);
  57.     virtual ~fstream() { };
  58.     void open(const char *, int);
  59.     void close();
  60.     void setbuf(char *, size_t);
  61.     filebuf *rdbuf() { return &buffer; };
  62. private:
  63.     fstream(const fstream &);
  64.     fstream &operator =(const fstream &);
  65.     filebuf buffer;
  66. };
  67.  
  68. class ifstream : public istream {
  69. public:
  70.     ifstream();
  71.     ifstream(const char *, int = ios::in);
  72.     virtual ~ifstream() { };
  73.     void open(const char *, int = ios::in);
  74.     void close();
  75.     void setbuf(char *, size_t);
  76.     filebuf *rdbuf() { return &buffer; };
  77. private:
  78.     ifstream(const ifstream &);
  79.     ifstream &operator =(const ifstream &);
  80.     filebuf buffer;
  81. };
  82.  
  83. class ofstream : public ostream {
  84. public:
  85.     ofstream();
  86.     ofstream(const char *, int = ios::out);
  87.     virtual ~ofstream() { };
  88.     void open(const char *, int = ios::out);
  89.     void close();
  90.     void setbuf(char *, size_t);
  91.     filebuf *rdbuf() { return &buffer; };
  92. private:
  93.     ofstream(const ofstream &);
  94.     ofstream &operator =(const ofstream &);
  95.     filebuf buffer;
  96. };
  97.  
  98. #endif
  99.