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