home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / c / gcc / g++lib.spk / h / fstream < prev    next >
Text File  |  1993-12-07  |  3KB  |  71 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1991 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef _FSTREAM_H
  19. #define _FSTREAM_H
  20. #ifdef __GNUG__
  21. #pragma interface
  22. #endif
  23. #include "iostream.h"
  24.  
  25. class fstreambase : virtual public ios {
  26.   public:
  27.     fstreambase();
  28.     fstreambase(int fd);
  29.     fstreambase(const char *name, int mode, int prot=0664);
  30.     void close();
  31.     filebuf* rdbuf() const { return (filebuf*)_strbuf; }
  32.     void open(const char *name, int mode, int prot=0664);
  33.     int is_open() const { return rdbuf()->is_open(); }
  34.     void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); }
  35. #ifdef _STREAM_COMPAT
  36.     int filedesc() { return rdbuf()->fd(); }
  37.     fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; }
  38. #endif
  39. };
  40.  
  41. class ifstream : public fstreambase, public istream {
  42.   public:
  43.     ifstream() : fstreambase() { }
  44.     ifstream(int fd) : fstreambase(fd) { }
  45.     ifstream(const char *name, int mode=ios::in, int prot=0664)
  46.     : fstreambase(name, mode, prot) { }
  47.     void open(const char *name, int mode=ios::in, int prot=0664)
  48.     { fstreambase::open(name, mode, prot); }
  49. };
  50.  
  51. class ofstream : public fstreambase, public ostream {
  52.   public:
  53.     ofstream() : fstreambase() { }
  54.     ofstream(int fd) : fstreambase(fd) { }
  55.     ofstream(const char *name, int mode=ios::out, int prot=0664)
  56.     : fstreambase(name, mode, prot) { }
  57.     void open(const char *name, int mode=ios::out, int prot=0664)
  58.     { fstreambase::open(name, mode, prot); }
  59. };
  60.  
  61. class fstream : public fstreambase, public iostream {
  62.   public:
  63.     fstream() : fstreambase() { }
  64.     fstream(int fd) : fstreambase(fd) { }
  65.     fstream(const char *name, int mode, int prot=0664)
  66.     : fstreambase(name, mode, prot) { }
  67.     void open(const char *name, int mode, int prot=0664)
  68.     { fstreambase::open(name, mode, prot); }
  69. };
  70. #endif /*!_FSTREAM_H*/
  71.