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

  1. #pragma info( none )
  2. #ifndef __CHKHDR__
  3.    #pragma info( none )
  4. #endif
  5. #pragma info( restore )
  6.  
  7. #ifndef __iostream_h
  8.    #define __iostream_h
  9.  
  10.    /********************************************************************/
  11.    /*  <iostream.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/iostream.h        1.11"   */
  44.    /**************************************************************************/
  45.    #include <string.h>
  46.                    /* Some inlines use memcpy */
  47.  
  48.    #pragma pack(4)
  49.  
  50.    /* If EOF is defined already verify that it is -1.  Otherwise
  51.     * define it.
  52.     */
  53.  
  54.    #ifdef EOF
  55.    #       if EOF!=-1
  56.    #               define EOF (-1)
  57.    #       endif
  58.    #else
  59.    #       define EOF (-1)
  60.    #endif
  61.  
  62.    /* Don't worry about NULL not being 0 */
  63.    #ifndef NULL
  64.    #       define NULL 0
  65.    #endif
  66.  
  67.    #define zapeof(c) ((unsigned char)(c))
  68.                /* extracts char from c. The critical requirement is
  69.                 *      zapeof(EOF)!=EOF
  70.                 * ((c)&0377) and ((unsigned char)(c)) are alternative definitions
  71.                 * whose efficiency depends on compiler environment.
  72.                 */
  73.  
  74.    typedef long streampos ;
  75.    typedef long streamoff ;
  76.  
  77.    class streambuf ;
  78.    class ostream ;
  79.    union ios_user_union;
  80.  
  81.  
  82.    class ios {
  83.    public: /* Some enums are declared in ios to avoid pollution of
  84.             * global namespace
  85.             */
  86.            enum io_state   { goodbit=0, eofbit=1, failbit=2, badbit=4,
  87.                                    hardfail=0200};
  88.                                    /* hard fail can be set and reset internally,
  89.                                     * but not via public function */
  90.            enum open_mode  { in=1, out=2, ate=4, app=010, trunc=020,
  91.                                    nocreate=040, noreplace=0100, bin=0200,
  92.                                    binary=bin   /* OS2 specific */
  93.                                    } ;
  94.            enum seek_dir   { beg=0, cur=1, end=2 } ;
  95.  
  96.            /* flags for controlling format */
  97.            enum            { skipws=01,
  98.                                            /* skip whitespace on input */
  99.                              left=02,  right=04, internal=010,
  100.                                            /* padding location */
  101.                              dec=020, oct=040, hex=0100,
  102.                                            /* conversion base */
  103.                              showbase=0200, showpoint=0400, uppercase=01000,
  104.                              showpos=02000,
  105.                                            /* modifiers */
  106.                              scientific=04000, fixed=010000,
  107.                                            /* floating point notation */
  108.                              unitbuf=020000, stdio=040000
  109.                                            /* stuff to control flushing */
  110.                              } ;
  111.            static const long
  112.                            basefield ; /* dec|oct|hex */
  113.            static const long
  114.                            adjustfield ; /* left|right|internal */
  115.            static const long
  116.                            floatfield ; /* scientific|fixed */
  117.    public:
  118.                            ios(streambuf*) ;
  119.            virtual         ~ios() ;
  120.  
  121.            long            flags() const   { return x_flags ; }
  122.            long            flags(long f);
  123.  
  124.            long            setf(long setbits, long field);
  125.            long            setf(long) ;
  126.            long            unsetf(long) ;
  127.  
  128.            int             width() const   { return x_width ; }
  129.            int             width(int w)
  130.            {
  131.                            int i = x_width ; x_width = w ; return i ;
  132.            }
  133.  
  134.            ostream*        tie(ostream* s);
  135.            ostream*        tie()           { return x_tie ; }
  136.            char            fill(char) ;
  137.            char            fill() const    { return x_fill ; }
  138.            int             precision(int) ;
  139.            int             precision() const       { return x_precision ; }
  140.  
  141.            int             rdstate() const { return state ; }
  142.                            operator void*()
  143.                                    {
  144.                                    if (state&(failbit|badbit|hardfail)) return 0 ;
  145.                                    else return this ;
  146.                                    }
  147.                            operator const void*() const
  148.                                    {
  149.                                    if (state&(failbit|badbit|hardfail)) return 0 ;
  150.                                    else return this ;
  151.                                    }
  152.  
  153.            int             operator!() const
  154.                                    { return state&(failbit|badbit|hardfail); }
  155.            int             eof() const     { return state&eofbit; }
  156.            int             fail() const    { return state&(failbit|badbit|hardfail); }
  157.            int             bad() const     { return state&badbit ; }
  158.            int             good() const    { return state==0 ; }
  159.            void            clear(int i =0)
  160.                                    {
  161.                                    state =  (i&0377) | (state&hardfail) ;
  162.                                    ispecial = (ispecial&~0377) | state ;
  163.                                    ospecial = (ospecial&~0377) | state ;
  164.                                    }
  165.            streambuf*      rdbuf() { return bp ;}
  166.  
  167.    public: /* Members related to user allocated bits and words */
  168.            long &          iword(int) ;
  169.            void* &         pword(int) ;
  170.            static long     bitalloc() ;
  171.            static int      xalloc() ;
  172.  
  173.    private: /*** privates for implemting allocated bits and words */
  174.            static long     nextbit ;
  175.            static long     nextword ;
  176.  
  177.            int             nuser ;
  178.            union ios_user_union*
  179.                            x_user ;
  180.            int     uresize(int) ;
  181.    public: /* static member functions */
  182.            static void     sync_with_stdio() ;
  183.    protected:
  184.            enum            { skipping=01000, tied=02000 } ;
  185.                            /*** bits 0377 are reserved for userbits ***/
  186.            streambuf*      bp;
  187.            void            setstate(int b)
  188.                            {       state |= (b&0377) ;
  189.                                    ispecial |= b&~skipping ;
  190.                                    ispecial |= b ;
  191.                            }
  192.            int             state;
  193.            int             ispecial;
  194.            int             ospecial;
  195.            int             isfx_special;
  196.            int             osfx_special;
  197.            int             delbuf;
  198.            ostream*        x_tie;
  199.            long            x_flags;
  200.            short           x_precision;
  201.            char            x_fill;
  202.            short           x_width;
  203.  
  204.            static void     (*stdioflush)() ;
  205.  
  206.            void            init(streambuf*) ;
  207.                                    /* Does the real work of a constructor */
  208.                            ios() ; /* No initialization at all. Needed by
  209.                                     * multiple inheritance versions */
  210.            int             assign_private ;
  211.                                    /* needed by with_assgn classes */
  212.    private:
  213.                            ios(ios&) ;
  214.            void            operator=(ios&) ;
  215.    public:   /* old stream package compatibility */
  216.            int             skip(int i) ;
  217.    };
  218.  
  219.    class streambuf {
  220.            short           alloc;
  221.            short           x_unbuf;
  222.            char*           x_base;
  223.            char*           x_pbase;
  224.            char*           x_pptr;
  225.            char*           x_epptr;
  226.            char*           x_gptr;
  227.            char*           x_egptr;
  228.            char*           x_eback;
  229.            int             x_blen;
  230.        private:
  231.                            streambuf(streambuf&); /* Declared but not defined */
  232.            void            operator=(streambuf&); /* Declared but not defined */
  233.        public:
  234.            void            dbp();
  235.        protected:
  236.            char*           base()          { return x_base ; }
  237.            char*           pbase()         { return x_pbase ; }
  238.            char*           pptr()          { return x_pptr ; }
  239.            char*           epptr()         { return x_epptr ; }
  240.            char*           gptr()          { return x_gptr ; }
  241.            char*           egptr()         { return x_egptr ; }
  242.            char*           eback()         { return x_eback ; }
  243.            char*           ebuf()          { return x_base+x_blen ; }
  244.            int             blen() const    { return x_blen; }
  245.            void            setp(char*  p, char*  ep)
  246.            {
  247.                    x_pbase=x_pptr=p ; x_epptr=ep ;
  248.            }
  249.            void            setg(char*  eb,char*  g, char*  eg)
  250.            {
  251.                    x_eback=eb; x_gptr=g ; x_egptr=eg ;
  252.            }
  253.            void            pbump(int n)
  254.            {
  255.                    x_pptr+=n ;
  256.            }
  257.  
  258.            void            gbump(int n)
  259.            {
  260.                    x_gptr+=n ;
  261.                    }
  262.  
  263.            void            setb(char* b, char* eb, int a = 0 )
  264.            {
  265.                    if ( alloc && x_base ) delete x_base ;
  266.                    x_base = b ;
  267.                    x_blen= (eb>b) ? (eb-b) : 0 ;
  268.                    alloc = a ;
  269.                    }
  270.            int             unbuffered() const      { return x_unbuf; }
  271.            void            unbuffered(int unb) { x_unbuf = (unb!=0)  ; }
  272.            int             allocate()
  273.            {
  274.                    if ( x_base== 0 && !unbuffered() ) return doallocate() ;
  275.                    else                             return 0 ;
  276.            }
  277.            virtual int     doallocate();
  278.        public :
  279.            virtual int     overflow(int c=EOF);
  280.            virtual int     underflow();
  281.            virtual int     pbackfail(int c);
  282.            virtual int     sync();
  283.            virtual streampos
  284.                            seekoff(streamoff,ios::seek_dir,int =ios::in|ios::out);
  285.            virtual streampos
  286.                            seekpos(streampos, int =ios::in|ios::out) ;
  287.            virtual int     xsputn(const char*  s,int n);
  288.            virtual int     xsgetn(char*  s,int n);
  289.  
  290.            int             in_avail()
  291.            {
  292.                    return x_gptr<x_egptr ? x_egptr-x_gptr : 0 ;
  293.            }
  294.  
  295.            int             out_waiting()
  296.            {
  297.                    if ( x_pptr ) return x_pptr-x_pbase ;
  298.                    else          return 0 ;
  299.            }
  300.  
  301.            int             sgetc()
  302.            {
  303.                    /***WARNING: sgetc does not bump the pointer ***/
  304.                    return (x_gptr>=x_egptr) ? underflow() : zapeof(*x_gptr);
  305.            }
  306.            int             snextc()
  307.            {
  308.                    return (++x_gptr>=x_egptr)
  309.                                    ? x_snextc()
  310.                                    : zapeof(*x_gptr);
  311.            }
  312.            int             sbumpc()
  313.            {
  314.                    return  ( x_gptr>=x_egptr && underflow()==EOF )
  315.                                    ? EOF
  316.                                    : zapeof(*x_gptr++) ;
  317.            }
  318.            int             optim_in_avail()
  319.            {
  320.                    return x_gptr<x_egptr ;
  321.            }
  322.            int             optim_sbumpc()
  323.            {
  324.                    return  zapeof(*x_gptr++) ;
  325.            }
  326.            void            stossc()
  327.            {
  328.                    if ( x_gptr < x_egptr ||
  329.                         ( x_gptr >= x_egptr && underflow() != EOF ) )
  330.                      x_gptr++;
  331.            }
  332.  
  333.            int             sputbackc(char c)
  334.            {
  335.                    if (x_gptr > x_eback ) {
  336.                            if ( *--x_gptr == c ) return zapeof(c) ;
  337.                            else                  return zapeof(*x_gptr=c) ;
  338.                    } else {
  339.                            return pbackfail(c) ;
  340.                    }
  341.            }
  342.  
  343.            int             sputc(int c)
  344.            {
  345.                    return (x_pptr>=x_epptr) ? overflow(zapeof(c))
  346.                                          : zapeof(*x_pptr++=c);
  347.            }
  348.            int             sputn(const char*  s,int n)
  349.             {
  350.                    if ( n <= (x_epptr-x_pptr) ) {
  351.                            memcpy(x_pptr,s,n) ;
  352.                            pbump(n);
  353.                            return n ;
  354.                    } else {
  355.                            return xsputn(s,n) ;
  356.                    }
  357.            }
  358.            int             sgetn(char*  s,int n)
  359.            {
  360.                    if ( n <= (x_egptr-x_gptr) ) {
  361.                            memcpy(s,x_gptr,n) ;
  362.                            gbump(n);
  363.                            return n ;
  364.                    } else {
  365.                            return xsgetn(s,n) ;
  366.                    }
  367.            }
  368.            virtual streambuf*
  369.                            setbuf(char*  p, int len) ;
  370.            streambuf*      setbuf(unsigned char*  p, int len) ;
  371.  
  372.            streambuf*      setbuf(char*  p, int len, int count) ;
  373.                                    /* obsolete third argument */
  374.                            /*** Constructors -- should be protected ***/
  375.                            streambuf() ;
  376.                            streambuf(char*  p, int l) ;
  377.  
  378.                            streambuf(char*  p, int l,int c) ;
  379.                            /* 3 argument form is obsolete.
  380.                             * Use strstreambuf.
  381.                             */
  382.            virtual         ~streambuf() ;
  383.            /*
  384.               The function:
  385.                  int streambuf::pptr_non_null()
  386.               was added by IBM to fix a problem in which a number of member
  387.               functions in class istream needed to check that the "pptr()"
  388.               was non-null. You are advised NOT to use this function in your
  389.               code.
  390.            */
  391.            int             pptr_non_null() { return x_pptr != 0; }
  392.    private:
  393.            int             x_snextc() ;
  394.    };
  395.  
  396.    class istream : virtual public ios {
  397.    public: /* Constructor */
  398.                            istream(streambuf*) ;
  399.            virtual         ~istream() ;
  400.    public:
  401.            int             ipfx(int noskipws=0)
  402.                            {       if ( noskipws?(ispecial&~skipping):ispecial) {
  403.                                            return do_ipfx(noskipws) ;
  404.                                    } else return 1 ;
  405.                            }
  406.  
  407.            /*
  408.              FUNCTION void isfx() IS INTERNAL AND SHOULD NOT BE USED.
  409.            */
  410.            void            isfx() { }
  411.  
  412.            istream&        seekg(streampos p) ;
  413.            istream&        seekg(streamoff o, ios::seek_dir d) ;
  414.            streampos       tellg() ;
  415.            istream&        operator>> (istream& (*f)(istream&))
  416.                            {       return (*f)(*this) ; }
  417.            istream&        operator>> (ios& (*f)(ios&) ) ;
  418.            istream&        operator>>(char*);
  419.            istream&        operator>>(signed char*);
  420.            istream&        operator>>(unsigned char*);
  421.            istream&        operator>>(char& c)
  422.                            {       if ( !ispecial && bp->optim_in_avail() &&
  423.                                         bp->pptr_non_null() ) {
  424.                                            c = bp->optim_sbumpc() ;
  425.                                            return *this;
  426.                                    }
  427.                                    else {
  428.                                            return (rs_complicated(c));
  429.                                    }
  430.                            }
  431.            istream&        operator>>(signed char& c)
  432.                            {       if ( !ispecial && bp->optim_in_avail() &&
  433.                                         bp->pptr_non_null() ) {
  434.                                            c = bp->optim_sbumpc() ;
  435.                                            return *this;
  436.                                    }
  437.                                    else {
  438.                                            return (rs_complicated(c));
  439.                                    }
  440.                            }
  441.            istream&        operator>>(unsigned char& c)
  442.                            {       if ( !ispecial && bp->optim_in_avail() &&
  443.                                         bp->pptr_non_null() ) {
  444.                                            c = bp->optim_sbumpc() ;
  445.                                            return *this;
  446.                                    }
  447.                                    else {
  448.                                            return (rs_complicated(c));
  449.                                    }
  450.                            }
  451.  
  452.            /*
  453.              FUNCTION istream &rs_complicated(char &) IS INTERNAL AND SHOULD
  454.              NOT BE USED.
  455.            */
  456.            istream&        rs_complicated(char& c);
  457.  
  458.            /*
  459.              FUNCTION istream &rs_complicated(signed char &) IS INTERNAL
  460.              AND SHOULD NOT BE USED.
  461.            */
  462.            istream&        rs_complicated(signed char& c);
  463.  
  464.            /*
  465.              FUNCTION istream &rs_complicated(unsigned char &) IS INTERNAL
  466.              AND SHOULD NOT BE USED.
  467.            */
  468.            istream&        rs_complicated(unsigned char& c);
  469.  
  470.            istream&        operator>>(short&);
  471.            istream&        operator>>(int&);
  472.            istream&        operator>>(long&);
  473.            istream&        operator>>(unsigned short&);
  474.            istream&        operator>>(unsigned int&);
  475.            istream&        operator>>(unsigned long&);
  476.            istream&        operator>>(float&);
  477.            istream&        operator>>(double&);
  478.            istream&        operator>>(long double&);
  479.            istream&        operator>>(streambuf*);
  480.            istream&        operator>>(wchar_t*);
  481.            istream&        operator>>(wchar_t&);
  482.            istream&        get(char* , int lim, char delim='\n');
  483.            istream&        get(signed char* b,int lim, char delim='\n');
  484.            istream&        get(unsigned char* b,int lim, char delim='\n');
  485.            istream&        getline(char* b, int lim, char delim='\n');
  486.            istream&        getline(signed char* b, int lim, char delim='\n');
  487.            istream&        getline(unsigned char* b, int lim, char delim='\n');
  488.            istream&        get(streambuf& sb, char delim ='\n');
  489.            istream&        get(wchar_t&);
  490.  
  491.            /*
  492.              FUNCTION istream &get_complicated(char &) IS INTERNAL AND SHOULD
  493.              NOT BE USED.
  494.            */
  495.            istream&        get_complicated(char& c);
  496.  
  497.            /*
  498.              FUNCTION istream &get_complicated(signed char &) IS INTERNAL
  499.              AND SHOULD NOT BE USED.
  500.            */
  501.            istream&        get_complicated(signed char& c);
  502.  
  503.            /*
  504.              FUNCTION istream &get_complicated(unsigned char &) IS INTERNAL
  505.              AND SHOULD NOT BE USED.
  506.            */
  507.            istream&        get_complicated(unsigned char& c);
  508.  
  509.            istream&        get(char& c)
  510.                            {
  511.                                    if ( !(ispecial & ~skipping) && bp->optim_in_avail() &&
  512.                                         bp->pptr_non_null() ) {
  513.                                            x_gcount = 1 ;
  514.                                            c = bp->sbumpc() ;
  515.                                            return *this;
  516.                                    } else {
  517.                                            return (get_complicated(c));
  518.                                    }
  519.                            }
  520.            istream&        get(signed char& c)
  521.                            {
  522.                                    if ( !(ispecial & ~skipping) && bp->optim_in_avail() &&
  523.                                         bp->pptr_non_null() ) {
  524.                                            x_gcount = 1 ;
  525.                                            c = bp->sbumpc() ;
  526.                                            return *this;
  527.                                    } else {
  528.                                            return (get_complicated(c));
  529.                                    }
  530.                            }
  531.            istream&        get(unsigned char& c)
  532.                            {
  533.                                    if ( !(ispecial & ~skipping) && bp->optim_in_avail() &&
  534.                                         bp->pptr_non_null() ) {
  535.                                            x_gcount = 1 ;
  536.                                            c = bp->sbumpc() ;
  537.                                            return *this;
  538.                                    } else {
  539.                                            return (get_complicated(c));
  540.                                    }
  541.                            }
  542.            int             get()
  543.                            {
  544.                                    int c ;
  545.                                    if ( !ipfx(1) ) return EOF ;
  546.                                    else {
  547.                                            c = bp->sbumpc() ;
  548.                                            if ( c == EOF ) setstate(eofbit) ;
  549.                                            return c ;
  550.                                            }
  551.                            }
  552.            int             peek()
  553.                            {
  554.                                    if ( ipfx(-1) ) return bp->sgetc() ;
  555.                                    else            return EOF ;
  556.  
  557.                            }
  558.            istream&        ignore(int n=1,int delim=EOF) ;
  559.            istream&        read(char*  s,int n);
  560.            istream&        read(signed char* s,int n)
  561.                            {
  562.                                    return read((char*)s,n) ;
  563.                            }
  564.            istream&        read(unsigned char* s,int n)
  565.                            {
  566.                                    return read((char*)s,n) ;
  567.                            }
  568.            int             gcount() ;
  569.            istream&        putback(char c);
  570.            int             sync()  { return bp->sync() ; }
  571.    protected:
  572.  
  573.            /*
  574.              FUNCTION int do_ipfx(int) IS INTERNAL AND SHOULD NOT BE USED.
  575.            */
  576.            int             do_ipfx(int noskipws) ;
  577.  
  578.            /*
  579.              FUNCTION void eatwhite() IS INTERNAL AND SHOULD NOT BE USED.
  580.            */
  581.            void            eatwhite() ;
  582.  
  583.                            istream() ;
  584.    private:
  585.            int             x_gcount ;
  586.            void            xget(char*  c) ;
  587.  
  588.            int             inf_special_in(streambuf * nbp);
  589.            int             nan_special_in(streambuf * nbp);
  590.  
  591.    public: /*** Obsolete constructors, carried over from stream package ***/
  592.            /*
  593.              YOU ARE ADVISED NOT TO USE THE OBSOLETE FUNCTIONS SINCE THEY
  594.              MAY BE REMOVED IN A FUTURE VERSION.
  595.            */
  596.                            istream(streambuf*, int sk, ostream* t=0) ;
  597.                                    /* obsolete, set sk and tie
  598.                                     * via format state variables */
  599.                            istream(int size ,char*,int sk=1) ;
  600.                                    /* obsolete, use strstream */
  601.                            istream(int fd,int sk=1, ostream* t=0) ;
  602.                                    /* obsolete use fstream */
  603.    };
  604.  
  605.    class ostream : virtual public ios {
  606.    public: /* Constructor */
  607.                            ostream(streambuf*) ;
  608.            virtual         ~ostream();
  609.    public:
  610.            int             opfx()  /* Output prefix */
  611.                            {       if ( ospecial ) return do_opfx() ;
  612.                                    else            return 1 ;
  613.                            }
  614.  
  615.            void            osfx()
  616.                            {       if ( osfx_special ) do_osfx() ; }
  617.  
  618.            ostream&        flush() ;
  619.            ostream&        seekp(streampos p) ;
  620.            ostream&        seekp(streamoff o, ios::seek_dir d) ;
  621.            streampos       tellp() ;
  622.  
  623.            ostream&        put(char c)
  624.            {
  625.                    if (ospecial || osfx_special) {
  626.                            return complicated_put(c);
  627.                    }
  628.                    else {
  629.                            if (  bp->sputc(c) == EOF )  {
  630.                                    setstate(eofbit|failbit) ;
  631.                            }
  632.                            return *this ;
  633.                    }
  634.            }
  635.  
  636.            /*
  637.              FUNCTION ostream &complicated_put(char) IS INTERNAL AND SHOULD
  638.              NOT BE USED.
  639.            */
  640.            ostream&        complicated_put(char c);
  641.  
  642.            ostream&        operator<<(char c)
  643.            {
  644.                    if (ospecial || osfx_special) {
  645.                            return ls_complicated(c);
  646.                    }
  647.                    else {
  648.                            if (  bp->sputc(c) == EOF )  {
  649.                                    setstate(eofbit|failbit) ;
  650.                            }
  651.                            return *this ;
  652.                    }
  653.            }
  654.  
  655.            ostream&        operator<<(signed char c)
  656.            {
  657.                    if (ospecial || osfx_special) {
  658.                            return ls_complicated(c);
  659.                    }
  660.                    else {
  661.                            if (  bp->sputc(c) == EOF )  {
  662.                                    setstate(eofbit|failbit) ;
  663.                            }
  664.                            return *this ;
  665.                    }
  666.            }
  667.  
  668.            ostream&        operator<<(unsigned char c)
  669.            {
  670.                    if (ospecial || osfx_special) {
  671.                            return ls_complicated(c);
  672.                    }
  673.                    else {
  674.                            if (  bp->sputc(c) == EOF )  {
  675.                                    setstate(eofbit|failbit) ;
  676.                            }
  677.                            return *this ;
  678.                    }
  679.            }
  680.  
  681.            /*
  682.              FUNCTION ostream &ls_complicated(char) IS INTERNAL AND SHOULD
  683.              NOT BE USED.
  684.            */
  685.            ostream&        ls_complicated(char);
  686.  
  687.            /*
  688.              FUNCTION ostream &ls_complicated(signed char) IS INTERNAL AND
  689.              SHOULD NOT BE USED.
  690.            */
  691.            ostream&        ls_complicated(signed char);
  692.  
  693.            /*
  694.              FUNCTION ostream &ls_complicated(unsigned char) IS INTERNAL AND
  695.              SHOULD NOT BE USED.
  696.            */
  697.            ostream&        ls_complicated(unsigned char);
  698.  
  699.            ostream&        operator<<(wchar_t c);
  700.            ostream&        operator<<(const wchar_t *);
  701.            ostream&        operator<<(const char*);
  702.            ostream&        operator<<(const signed char*);
  703.            ostream&        operator<<(const unsigned char*);
  704.            ostream&        operator<<(int a);
  705.            ostream&        operator<<(long);
  706.            ostream&        operator<<(double);
  707.            ostream&        operator<<(long double);
  708.            ostream&        operator<<(float);
  709.            ostream&        operator<<(unsigned int a);
  710.            ostream&        operator<<(unsigned long);
  711.            ostream&        operator<<(const void*);
  712.            ostream&        operator<<(streambuf*);
  713.            ostream&        operator<<(short i) { return *this << (int)i ; }
  714.            ostream&        operator<<(unsigned short i)
  715.                            { return *this << (int)i  ; }
  716.  
  717.            ostream&        operator<< (ostream& (*f)(ostream&))
  718.                            { return (*f)(*this) ; }
  719.            ostream&        operator<< (ios& (*f)(ios&) ) ;
  720.  
  721.            ostream&        write(const char*  s,int n)
  722.            {
  723.                    if ( !state ) {
  724.                            if ( bp->sputn(s,n) != n ) setstate(eofbit|failbit);
  725.                            }
  726.                    return *this ;
  727.            }
  728.            ostream&        write(const signed char* s, int n)
  729.            {
  730.                    return write((const char*)s,n);
  731.            }
  732.            ostream&        write(const unsigned char* s, int n)
  733.            {
  734.                    return write((const char*)s,n);
  735.            }
  736.    protected: /* More ostream members */
  737.  
  738.            /*
  739.              FUNCTION int do_opfx() IS INTERNAL AND SHOULD NOT BE USED.
  740.            */
  741.            int             do_opfx() ;
  742.  
  743.            /*
  744.              FUNCTION void do_osfx() IS INTERNAL AND SHOULD NOT BE USED.
  745.            */
  746.            void            do_osfx() ;
  747.  
  748.                            ostream() ;
  749.  
  750.    public: /*** Obsolete constructors, carried over from stream package ***/
  751.            /*
  752.              YOU ARE ADVISED NOT TO USE THE OBSOLETE FUNCTIONS SINCE THEY
  753.              MAY BE REMOVED IN A FUTURE VERSION.
  754.            */
  755.                            ostream(int fd) ;
  756.                                    /* obsolete use fstream */
  757.                            ostream(int size ,char*) ;
  758.                                    /* obsolete, use strstream */
  759.    /*
  760.       Functions:
  761.  
  762.            int             wchar_out(int, char *, int) ;
  763.  
  764.       has been added by IBM to support wchar_t.
  765.    */
  766.    private:
  767.            int             wchar_out(int, char *, int) ;
  768.    } ;
  769.  
  770.    class iostream : public istream, public ostream {
  771.    public:
  772.                            iostream(streambuf*) ;
  773.            virtual         ~iostream() ;
  774.    protected:
  775.                            iostream() ;
  776.            } ;
  777.  
  778.    class istream_withassign : public istream {
  779.    public:
  780.                            istream_withassign() ;
  781.            virtual         ~istream_withassign() ;
  782.            istream_withassign&     operator=(istream&) ;
  783.            istream_withassign&     operator=(streambuf*) ;
  784.    } ;
  785.  
  786.    class ostream_withassign : public ostream {
  787.    public:
  788.                            ostream_withassign() ;
  789.            virtual         ~ostream_withassign() ;
  790.            ostream_withassign&     operator=(ostream&) ;
  791.            ostream_withassign&     operator=(streambuf*) ;
  792.    } ;
  793.  
  794.    class iostream_withassign : public iostream {
  795.    public:
  796.                            iostream_withassign() ;
  797.            virtual         ~iostream_withassign() ;
  798.            iostream_withassign&    operator=(ios&) ;
  799.            iostream_withassign&    operator=(streambuf*) ;
  800.    } ;
  801.  
  802.    extern istream_withassign cin ;
  803.    extern ostream_withassign cout ;
  804.    extern ostream_withassign cerr ;
  805.    extern ostream_withassign clog ;
  806.  
  807.    ios&            dec(ios&) ;
  808.    ostream&        endl(ostream& i) ;
  809.    ostream&        ends(ostream& i) ;
  810.    ostream&        flush(ostream&) ;
  811.    ios&            hex(ios&) ;
  812.    ios&            oct(ios&) ;
  813.    istream&        ws(istream&) ;
  814.  
  815.    #pragma pack()
  816.  
  817. #endif
  818.  
  819. #pragma info( none )
  820. #ifndef __CHKHDR__
  821.    #pragma info( restore )
  822. #endif
  823. #pragma info( restore )
  824.