home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / INCLUDE / FSTREAM.H < prev    next >
Text File  |  1993-09-17  |  7KB  |  158 lines

  1. #pragma info( none )
  2. #ifndef __CHKHDR__
  3.    #pragma info( none )
  4. #endif
  5. #pragma info( restore )
  6.  
  7. #ifndef __fstream_h
  8.    #define __fstream_h
  9.  
  10.    /********************************************************************/
  11.    /*  <fstream.h> header file                                         */
  12.    /*                                                                  */
  13.    /*  Licensed Materials - Property of IBM                            */
  14.    /*                                                                  */
  15.    /*  IBM C/C++ Tools Version 2.01                                    */
  16.    /*  Copyright (C) International Business Machines Corp., 1991, 1993.*/
  17.    /*  All rights reserved                                             */
  18.    /*                                                                  */
  19.    /*                                                                  */
  20.    /*                                                                  */
  21.    /*  Licensed Materials - Property of USL                            */
  22.    /*                                                                  */
  23.    /*  Standard Class Library Version 3.0                              */
  24.    /*  Copyright (C) Unix System Laboratories Inc. 1991.               */
  25.    /*  All rights reserved                                             */
  26.    /*                                                                  */
  27.    /********************************************************************/
  28.  
  29.    /**************************************************************************/
  30.    /*  C++ source for the C++ Language System, Release 3.0.  This product    */
  31.    /*  is a new release of the original cfront developed in the computer     */
  32.    /*  science research center of AT&T Bell Laboratories.                    */
  33.    /*                                                                        */
  34.    /*  Copyright (c) 1991 AT&T and UNIX System Laboratories, Inc.            */
  35.    /*  Copyright (c) 1984, 1989, 1990 AT&T.  All Rights Reserved.            */
  36.    /*                                                                        */
  37.    /*  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE of AT&T and UNIX System   */
  38.    /*  Laboratories, Inc.  The copyright notice above does not evidence      */
  39.    /*  any actual or intended publication of such source code.               */
  40.    /*                                                                        */
  41.    /*  UNIX is a registered trademark of UNIX System Laboratories, Inc.      */
  42.    /*                                                                        */
  43.    /*  ident "@(#)ctrans:incl-master/const-headers/fstream.h 1.4"            */
  44.    /**************************************************************************/
  45.  
  46.    #include <iostream.h>
  47.  
  48.    #pragma pack(4)
  49.  
  50.    class  filebuf : public streambuf {     /* a stream buffer for files */
  51.    public:
  52.            static const int openprot ; /* default protection for open */
  53.    public:
  54.                            filebuf() ;
  55.                            filebuf(int fd);
  56.                            filebuf(int fd, char*  p, int l) ;
  57.  
  58.            int             is_open() { return opened ; }
  59.            int             fd() { return xfd ; }
  60.            filebuf*        open(const char *name, int om, int prot=openprot);
  61.            filebuf*        attach(int fd) ;
  62.            filebuf*        close() ;
  63.                            ~filebuf() ;
  64.    public: /* virtuals */
  65.            virtual int     overflow(int=EOF);
  66.            virtual int     underflow();
  67.            virtual int     sync() ;
  68.            virtual streampos
  69.                            seekoff(streamoff,ios::seek_dir,int) ;
  70.            virtual streambuf*
  71.                            setbuf(char*  p, int len) ;
  72.    protected:
  73.            int             xfd;
  74.            int             mode ;
  75.            char            opened;
  76.            streampos       last_seek ;
  77.            char*           in_start;
  78.            int             last_op();
  79.            char            lahead[2] ;
  80.    };
  81.  
  82.    class fstreambase : virtual public ios {
  83.    public:
  84.                            fstreambase() ;
  85.  
  86.                            fstreambase(const char* name,
  87.                                            int mode,
  88.                                            int prot=filebuf::openprot) ;
  89.                            fstreambase(int fd) ;
  90.                            fstreambase(int fd, char*  p, int l) ;
  91.                            ~fstreambase() ;
  92.            void            open(const char* name, int mode,
  93.                                            int prot=filebuf::openprot) ;
  94.            void            attach(int fd);
  95.            void            close() ;
  96.            void            setbuf(char*  p, int l) ;
  97.            filebuf*        rdbuf() { return &buf ; }
  98.    private:
  99.            filebuf         buf ;
  100.    protected:
  101.            void            verify(int) ;
  102.    } ;
  103.  
  104.    class ifstream : public fstreambase, public istream {
  105.    public:
  106.                            ifstream() ;
  107.                            ifstream(const char* name,
  108.                                            int mode=ios::in,
  109.                                            int prot=filebuf::openprot) ;
  110.                            ifstream(int fd) ;
  111.                            ifstream(int fd, char*  p, int l) ;
  112.                            ~ifstream() ;
  113.  
  114.            filebuf*        rdbuf() { return fstreambase::rdbuf(); }
  115.            void            open(const char* name, int mode=ios::in,
  116.                                            int prot=filebuf::openprot) ;
  117.    } ;
  118.  
  119.    class ofstream : public fstreambase, public ostream {
  120.    public:
  121.                            ofstream() ;
  122.                            ofstream(const char* name,
  123.                                            int mode=ios::out,
  124.                                            int prot=filebuf::openprot) ;
  125.                            ofstream(int fd) ;
  126.                            ofstream(int fd, char*  p, int l) ;
  127.                            ~ofstream() ;
  128.  
  129.            filebuf*        rdbuf() { return fstreambase::rdbuf(); }
  130.            void            open(const char* name, int mode=ios::out,
  131.                                            int prot=filebuf::openprot) ;
  132.    } ;
  133.  
  134.    class fstream : public fstreambase, public iostream {
  135.    public:
  136.                            fstream() ;
  137.  
  138.                            fstream(const char* name,
  139.                                            int mode,
  140.                                            int prot=filebuf::openprot) ;
  141.                            fstream(int fd) ;
  142.                            fstream(int fd, char*  p, int l) ;
  143.                            ~fstream() ;
  144.            filebuf*        rdbuf() { return fstreambase::rdbuf(); }
  145.            void            open(const char* name, int mode,
  146.                                    int prot=filebuf::openprot) ;
  147.    } ;
  148.  
  149.    #pragma pack()
  150.  
  151. #endif
  152.  
  153. #pragma info( none )
  154. #ifndef __CHKHDR__
  155.    #pragma info( restore )
  156. #endif
  157. #pragma info( restore )
  158.