Annotation of researchv10no/cmd/cfront/libC/oiostream/fstream.h, revision 1.1.1.1

1.1       root        1: /*ident        "@(#)ctrans:incl/fstream.h      1.1.1.2" */
                      2: /**************************************************************************
                      3:                         Copyright (c) 1984 AT&T
                      4:                           All Rights Reserved   
                      5: 
                      6:         THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
                      7:       
                      8:         The copyright notice above does not evidence any        
                      9:         actual or intended publication of such source code.
                     10: 
                     11: *****************************************************************************/
                     12: #ifndef FSTREAMH
                     13: #define FSTREAMH
                     14: 
                     15: #include <iostream.h>
                     16: 
                     17: class  filebuf : public streambuf {    /* a stream buffer for files */
                     18: public:
                     19:        static const int openprot ; /* default protection for open */
                     20: public:
                     21:                        filebuf() ;
                     22:                        filebuf(int fd);
                     23:                        filebuf(int fd, char*  p, int l) ;
                     24: 
                     25:        int             is_open() { return opened ; }
                     26:        int             fd() { return xfd ; }
                     27:        filebuf*        open(const char *name, int om, int prot=openprot);
                     28:        filebuf*        attach(int fd) ;
                     29:        filebuf*        close() ;
                     30:                        ~filebuf() ;
                     31: public: /* virtuals */
                     32:        virtual int     overflow(int=EOF);
                     33:        virtual int     underflow();
                     34:        virtual int     sync() ;
                     35:        virtual streampos
                     36:                        seekoff(streamoff,seek_dir,int) ;
                     37:        virtual streambuf*
                     38:                        setbuf(char*  p, int len) ;
                     39: protected:
                     40:        int             xfd;    
                     41:        int             mode ;
                     42:        char            opened;
                     43:        streampos       last_seek ;
                     44:        char*           in_start;
                     45:        int             last_op();
                     46:        char            lahead[2] ;
                     47: };
                     48: 
                     49: class fstreambase : virtual public ios { 
                     50: public:
                     51:                        fstreambase() ;
                     52:        
                     53:                        fstreambase(const char* name, 
                     54:                                        int mode,
                     55:                                        int prot=filebuf::openprot) ;
                     56:                        fstreambase(int fd) ;
                     57:                        fstreambase(int fd, char*  p, int l) ;
                     58:                        ~fstreambase() ;
                     59:        void            open(const char* name, int mode, 
                     60:                                        int prot=filebuf::openprot) ;
                     61:        void            attach(int fd);
                     62:        void            close() ;
                     63:        void            setbuf(char*  p, int l) ;
                     64:        filebuf*        rdbuf() { return &buf ; }
                     65: private:
                     66:        filebuf         buf ;
                     67: protected:
                     68:        void            verify(int) ;
                     69: } ;
                     70: 
                     71: class ifstream : public fstreambase, public istream {
                     72: public:
                     73:                        ifstream() ;
                     74:                        ifstream(const char* name, 
                     75:                                        int mode=ios::in,
                     76:                                        int prot=filebuf::openprot) ;
                     77:                        ifstream(int fd) ;
                     78:                        ifstream(int fd, char*  p, int l) ;
                     79:                        ~ifstream() ;
                     80: 
                     81:        filebuf*        rdbuf() { return fstreambase::rdbuf(); }
                     82:        void            open(const char* name, int mode=ios::in, 
                     83:                                        int prot=filebuf::openprot) ;
                     84: } ;
                     85: 
                     86: class ofstream : public fstreambase, public ostream {
                     87: public:
                     88:                        ofstream() ;
                     89:                        ofstream(const char* name, 
                     90:                                        int mode=ios::out,
                     91:                                        int prot=filebuf::openprot) ;
                     92:                        ofstream(int fd) ;
                     93:                        ofstream(int fd, char*  p, int l) ;
                     94:                        ~ofstream() ;
                     95: 
                     96:        filebuf*        rdbuf() { return fstreambase::rdbuf(); }
                     97:        void            open(const char* name, int mode=ios::out, 
                     98:                                        int prot=filebuf::openprot) ;
                     99: } ;
                    100: 
                    101: class fstream : public fstreambase, public iostream {
                    102: public:
                    103:                        fstream() ;
                    104:        
                    105:                        fstream(const char* name, 
                    106:                                        int mode,
                    107:                                        int prot=filebuf::openprot) ;
                    108:                        fstream(int fd) ;
                    109:                        fstream(int fd, char*  p, int l) ;
                    110:                        ~fstream() ;
                    111:        filebuf*        rdbuf() { return fstreambase::rdbuf(); }
                    112:        void            open(const char* name, int mode, 
                    113:                                int prot=filebuf::openprot) ;
                    114: } ;
                    115: 
                    116: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.