home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / K < prev    next >
Encoding:
Text File  |  1992-08-26  |  19.6 KB  |  778 lines

  1. /*
  2.  *   iostream.h
  3.  *
  4.  *   C++ IOStreams and base classes.
  5.  *
  6.  *       Copyright (c) 1991-1992, MetaWare Incorporated
  7.  */
  8.  
  9. /*   $Id: iostream.h,v 1.22 1992/02/19 20:53:40 tom Exp budis $  */
  10.  
  11. #ifndef __IOSTREAM_H
  12. #define __IOSTREAM_H
  13. #pragma push_align_members(64);
  14.  
  15. #c_include "memory.h"    
  16.  
  17.     // ANSI version of memory.h is shipped in C++ include directory
  18.     // to avoid problem with UNIX's non-prototyped memory.h.
  19. //   EOF and NULL may have been defined elsewhere.
  20. #ifndef EOF
  21. # define EOF (-1)
  22. #endif
  23.  
  24. #ifndef NULL
  25. # define NULL ((void*)(0))
  26. #endif
  27.  
  28. #pragma Off(Behaved)
  29. //   Extract a character from c, eliminating possibility of EOF.
  30. #define zapeof(c) ((unsigned char)(c))
  31.  
  32. typedef long streampos;
  33. typedef long streamoff;
  34.  
  35. class streambuf;
  36. class ostream;
  37.  
  38.  
  39.  
  40. #pragma on(nodebug)
  41. /*
  42.  *   Class ios:
  43.  *
  44.  *      I/O Status values and access members.
  45.  *
  46.  */
  47.  
  48. class ios {
  49.  
  50. //   Public constants and enumerations.
  51. public:
  52.     // Stream status
  53.     enum io_state   { 
  54.         goodbit    = 0x00,    // No error
  55.         eofbit    = 0x01,    // End-of-file reached
  56.         failbit     = 0x02,    // Insertion/extraction failed
  57.         range_errbit= 0x04,    // Value out of range
  58.         badbit    = 0x08,    // Access failed
  59.         hardfail    = 0x80     // Unrecoverable error
  60.         };
  61.  
  62.     // Stream I/O mode
  63.     enum open_mode  { 
  64.         in         = 0x01,    // Input
  65.         out         = 0x02,    // Output
  66.         ate         = 0x04,    // Seek to EOF at open
  67.         app         = 0x08,    // All operations append
  68.         trunc    = 0x10,    // Truncate file
  69.         nocreate = 0x20,    // Do not create file
  70.         noreplace= 0x40,    // Do not overwrite file
  71.         binary   = 0x80    // Binary file (no CR/LF translation).
  72.         };
  73.  
  74.     // Stream seek direction
  75.     enum seek_dir   { 
  76.         beg         = 0x00,    // Seek from beginning
  77.         cur         = 0x01,    // Seek from current position
  78.         end         = 0x02    // Seek from end
  79.         };
  80.  
  81.     // Formatting flags
  82.     enum        { 
  83.         skipws     = 0x01,    // Skip whitespace on input
  84.                        
  85.         left       = 0x02,    // Padding location
  86.         right      = 0x04,
  87.         internal   = 0x08,    // Between sign and digits
  88.                     
  89.         dec         = 0x10,    // Conversion base
  90.         oct         = 0x20,
  91.         hex         = 0x40,
  92.  
  93.         showbase   = 0x80,    // Show base on output (eg. 0x)
  94.         showpoint  = 0x100,    // Print trailing zeros,decimals
  95.         uppercase  = 0x200,    // Use uppercase E,X
  96.         showpos    = 0x400,    // Print leading + for positive
  97.                 // Floating point notation
  98.         scientific = 0x800,    // 5.6789e3
  99.         fixed      = 0x1000,// 5678.9 
  100.                             
  101.         unitbuf    = 0x2000,// Buffering--if set, flush after 
  102.                 // operation complete, not every character.
  103.         keepwidth  = 0x4000,// If set, width is NOT reset
  104.                 //  after each operation.
  105.         input_seps = 0x8000,// Allow digit separators on input.
  106.         char_width_1= 0x10000,// Char inserter ignores width setting.
  107.         fp_bases   = 0x20000,// Floating point inserters
  108.                 //  respect base setting.
  109.         stdio      = 0x40000// Flush stdout, stderr
  110.         };
  111.  
  112.     // Constants for use in second argument to setf().
  113.     static const long basefield;        //  dec | oct | hex;
  114.     static const long adjustfield;        //  left | right | internal;
  115.     static const long floatfield;        //  scientific | fixed;
  116.  
  117. private:
  118.     void        ios_check();
  119.     // Privates for implementing allocated bits and words.
  120.     static unsigned long     priv_nextbit;
  121.  
  122.             // NOTE:  AT&T and Borland both have this member as
  123.             // static.  I don't see any reason for it to be static,
  124.             // and I think that having it be static would cause
  125.             // a significant waste of memory when user-defined
  126.             // flag words are used.  See the documentation for
  127.             // more on this.
  128.     /*static*/ unsigned long     priv_nextword;
  129.  
  130.     long        priv_numuwords;
  131.     union ios_user_union {
  132.         long    long_value;
  133.         void *    pointer_value;
  134.         };
  135.     ios_user_union*   priv_userwords;
  136.     int        priv_user_resize(long __newsize);
  137.  
  138.  
  139. protected:
  140.  
  141.             ios(ios&);        // Declared but not defined.
  142.     void        operator=(ios&);    // Causes error on copy.
  143.  
  144.             // Special flags
  145.     enum        { skipping=0x200,    // Skipping whitespace
  146.               tied=0x400        // Tied to another stream
  147.             };
  148.             
  149.     streambuf*    bp;            // streambuf for this ios
  150.  
  151.             // Set status to __new_state
  152.     void        setstate(int __new_state) {
  153.                 state |= (__new_state & 0xff);
  154.                 }
  155.  
  156.     long        state;        // Userbits and error state
  157.     long        ispecial;    // Input special flags
  158.     long        ospecial;    // Output special flags
  159.     long        isfx_special;    // Input suffix special flags
  160.     long        osfx_special;    // Output suffix special flags
  161.     long        delbuf;
  162.  
  163.     long        x_flags;    // Formatting flags
  164.     short        x_width;    // Field width
  165.     short        x_precision;    // Precision
  166.     char        x_fill;        // Fill character
  167.     char        x_decimal;    // Decimal character
  168.     char        x_digsep;    // Digit separator character
  169.     short        x_sepfreq;    // Digit separator frequency
  170.     ostream*    x_tie;        // Link to tied output stream
  171.  
  172.     static void     (*stdioflush)();    // Function to flush stdio
  173.  
  174.             // Does the real work of a constructor.
  175.     void        init(streambuf* __buffer);
  176.  
  177.             ios();  // No initialization. Needed by
  178.                 //  multiple-inheritance versions.
  179.     int        assign_private;
  180.                 // Needed by with_assign classes.
  181.  
  182. public:
  183.  
  184.             ios(streambuf* __buffer);
  185.  
  186.     virtual        ~ios();
  187.  
  188.             // Read flags.
  189.     long        flags() { return x_flags; }
  190.  
  191.             // Set flags, return previous.
  192.     long        flags(long __newflags);
  193.  
  194.             // Set flags, return previous.
  195.     long        setf(long __setbits, long __field);
  196.  
  197.             // Turn on bits set in __setbits, return previous value.
  198.     long        setf(long __setbits);
  199.  
  200.             // Turn off bits set in __unsetbits, return prev.
  201.     long        unsetf(long __unsetbits);
  202.  
  203.                 // Return current width.
  204.     int        width() { return x_width; }
  205.  
  206.             // Set width, return previous value.
  207.     int        width(int __new_width)  {
  208.                 int temp = x_width;
  209.                 x_width = __new_width;
  210.                 return temp;
  211.                 }
  212.  
  213.             // Read tie value.
  214.     ostream*    tie() { return x_tie; }
  215.  
  216.               // Tie to __tie_stream.
  217.     ostream*    tie(ostream* __tie_stream);
  218.  
  219.             // Read fill value.
  220.     char        fill() { return x_fill; }
  221.  
  222.             // Set fill char to __fillc, return previous.
  223.     char        fill(char __fillc);
  224.  
  225.             // Read decimal character
  226.     char        decimal_point() { return x_decimal; }
  227.  
  228.             // Set decimal char to __decimalc, return previous.
  229.     char        decimal_point(char __decimalc) {
  230.                 char tmp = x_decimal;
  231.                 if (__decimalc !=0) x_decimal = __decimalc;
  232.                 return tmp;
  233.                 }
  234.  
  235.             // Read digit separator character
  236.     char        digit_sep() { return x_digsep; }
  237.  
  238.             // Set digit separator char to __sepchar
  239.     char        digit_sep(char __sepchar) {
  240.                 char temp = x_digsep;
  241.                 x_digsep = __sepchar;
  242.                 return temp;
  243.                 }
  244.  
  245.             // Read digit separator character
  246.     int        digit_sep_freq() { return x_sepfreq; }
  247.  
  248.             // Set digit separator frequenct to __sepfreq
  249.     int        digit_sep_freq(char __sepfreq) {
  250.                 int temp = x_sepfreq;
  251.                 x_sepfreq = __sepfreq;
  252.                 return temp;
  253.                 }
  254.  
  255.             // Read current precision
  256.     int        precision() { return x_precision; }
  257.  
  258.             // Set precision to __prec, return previous.
  259.     int        precision(int __prec);
  260.  
  261.             // Read state.
  262.     int        rdstate() { return state; }
  263.  
  264.             // Typecast operator.
  265.             // Return valid pointer only if state is not bad.
  266.             operator void*() {
  267.                 if(state&(failbit|badbit|hardfail)) return NULL;
  268.                 else return this;
  269.                 }
  270.  
  271.             // Check state -- 0 if state is bad, 1 otherwise
  272.     int        operator!()
  273.                 { return (state&(failbit|badbit|hardfail)); }
  274.  
  275.             // Check for EOF
  276.     int        eof()   { return (state&eofbit); }
  277.  
  278.             // Check for failed operation
  279.     int        fail()  { return (state&(failbit|badbit|hardfail)); }
  280.  
  281.             // Check for unusable stream
  282.     int        hard_fail()  { return (state&(hardfail)); }
  283.  
  284.             // Check for bad stream status
  285.     int        bad()   { return (state&badbit); }
  286.  
  287.             // Check for range error status
  288.     int        range_err()   { return (state&range_errbit); }
  289.  
  290.             // Check for good stream status
  291.     int        good()  { return (state==0); }
  292.  
  293.             // Clear status, set to __init
  294.             // Note: Only modifies standard state flags
  295.     void        clear(int __init = 0) {
  296.                 state =  (__init&0xff) | (state&hardfail);
  297.                 }
  298.  
  299.             // Clear status, set to __init
  300.             // Use this function to modify user-defined
  301.             //  state flags.
  302.             // This function is the same as clear(), except
  303.             //  that it modifies all state flags.
  304.     virtual void    set_err(int __init = 0) {
  305.                 state =  __init | (state&hardfail);
  306.                 }
  307.  
  308.             // Get pointer to associated streambuf
  309.     streambuf*    rdbuf() { return bp;}
  310.  
  311.     // Members related to user-allocated bits and words.
  312.  
  313.             // Returns __index_num'th user-defined flag word.
  314.     long &        iword(int __index_num);
  315.  
  316.             // Returns __index_num'th user-defined flag word.
  317.     void* &        pword(int __index_num);
  318.  
  319.             // Returns a long with one previously-unused bit set.
  320.             // This can be used as a user error flag.
  321.     static long    bitalloc();
  322.  
  323.             // Returns a previously-unused index into an array of
  324.             //  words available for use as format state variables.
  325.             // For use by derived classes.
  326.  
  327.             // NOTE:  AT&T and Borland both have this function as
  328.             // static.  I don't see any reason for it to be static,
  329.             // and I think that having it be static would cause
  330.             // a significant waste of memory when user-defined
  331.             // flag words are used.  See the documentation for
  332.             // more on this.
  333.     /*static*/ int    xalloc();
  334.  
  335.             // Allows mixed use of stdio FILE*'s and streams.
  336.             // Has an effect only the first time called.
  337.     static void    sync_with_stdio();
  338.     };
  339.  
  340.  
  341.  
  342. /*
  343.  *   Class streambuf
  344.  *
  345.  *      Base stream-buffer class.
  346.  *
  347.  */
  348.  
  349. class streambuf {
  350.  
  351. private:
  352.     void        check_stat();
  353.     short        priv_alloc;    // TRUE == Delete buffer on setbuf
  354.     short        priv_unbuf;    // TRUE == unbuffered stream
  355.     char*        priv_base;    // Base of reserve area.
  356.     char*        priv_ebuf;    // Byte after end of reserve area.
  357.     char*        priv_pbase;    // Base of put area.
  358.     char*        priv_pptr;    // Current position in put area.
  359.     char*        priv_epptr;    // Byte after end of put area.
  360.     char*        priv_gptr;    // Current position in get area.
  361.     char*        priv_egptr;    // Byte after end of get area.
  362.     char*        priv_eback;    // Lower bound of gptr -- space
  363.                     //  available for putback.
  364.  
  365.     int        priv_snextc();
  366.     
  367. protected:
  368.             // Copy operators declared but not defined.
  369.             // Declaring as protected causes compiler to produce
  370.             //  an error if an assignment of a streambuf is 
  371.             //  attempted.  This is desirable, as assignment
  372.             //  of streambufs is not well-defined.
  373.             streambuf(streambuf&);
  374.     void        operator=(streambuf&);
  375.     
  376.             streambuf();
  377.             streambuf(char* __buf, int __len);
  378.  
  379.     char*        base()  { return priv_base; }
  380.     char*        pbase() { return priv_pbase; }
  381.     char*        pptr()  { return priv_pptr; }
  382.     char*        epptr() { return priv_epptr; }
  383.     char*        gptr()  { return priv_gptr; }
  384.     char*        egptr() { return priv_egptr; }
  385.     char*        eback() { return priv_eback; }
  386.     char*        ebuf()  { return priv_ebuf; }
  387.     int        blen()  {
  388.                 return ((priv_ebuf>priv_base)
  389.                     ? (priv_ebuf-priv_base)
  390.                     : 0);
  391.                 }
  392.  
  393.     void        setp(char*  __p, char*  __ep) {
  394.                 priv_pbase=priv_pptr=__p; priv_epptr=__ep;
  395.                 }
  396.  
  397.     void        setg(char*  __eb, char*  __g, char*  __eg) {
  398.                 priv_eback=__eb; priv_gptr=__g; priv_egptr=__eg;
  399.                 }
  400.  
  401.     void        pbump(int __num) {
  402.                 priv_pptr+=__num;
  403.                 }
  404.  
  405.     void        gbump(int __num) {
  406.                 priv_gptr+=__num;
  407.                 }
  408.  
  409.     void        setb(char* __b, char* __eb, int __a = 0 ) {
  410.                 if ( priv_alloc && priv_base ) delete priv_base;
  411.                 priv_base = __b;
  412.                 priv_ebuf = __eb;
  413.                 priv_alloc = __a;
  414.                 priv_unbuf = (__eb<=__b?1:0);
  415.                 }
  416.  
  417.     int        unbuffered() { return priv_unbuf; }
  418.  
  419.     void        unbuffered(int __unb) { priv_unbuf = (__unb!=0); }
  420.  
  421.     int        allocate() {
  422.                 if ( priv_base == 0 && !unbuffered() )
  423.                     return doallocate();
  424.                 else
  425.                     return 0;
  426.                 }
  427.  
  428.     virtual int    doallocate();
  429.     
  430.     virtual int    xsputn(const char* __str, int __num);
  431.     virtual int    xsgetn(char* __str,int __num);
  432.  
  433. public :
  434.     void        dbp(int __level=0);
  435.     virtual int    overflow(int __c=EOF);
  436.     virtual int    underflow();
  437.     virtual int    pbackfail(int __c);
  438.     virtual int    sync();
  439.     
  440.     virtual streampos
  441.             seekoff(streamoff __offset, ios::seek_dir __dir,
  442.                 long __mode=ios::in|ios::out);
  443.     virtual streampos
  444.             seekpos(streampos __pos, long __mode=ios::in|ios::out);
  445.  
  446.     int        in_avail() {
  447.                 return (priv_gptr<priv_egptr
  448.                     ? priv_egptr-priv_gptr
  449.                     : 0);
  450.                 }
  451.  
  452.     int        out_waiting() {
  453.                 if ( priv_pptr ) return priv_pptr-priv_pbase;
  454.                 else return 0;
  455.                 }
  456.  
  457.             // *** WARNING: sgetc does not bump the get pointer
  458.     int        sgetc() {
  459.                 return (priv_gptr>=priv_egptr)
  460.                     ? underflow()
  461.                     : zapeof(*priv_gptr);
  462.                 }
  463.  
  464.     int        snextc() {
  465.                 return (++priv_gptr>=priv_egptr)
  466.                     ? priv_snextc()
  467.                     : zapeof(*priv_gptr);
  468.                 }
  469.  
  470.     int        sbumpc() {
  471.                 return ((priv_gptr>=priv_egptr
  472.                       && underflow()==EOF)
  473.                     ? EOF
  474.                     : zapeof(*priv_gptr++));
  475.                 }
  476.  
  477.     void        stossc() {
  478.                 if (priv_gptr>=priv_egptr) underflow();
  479.                 else ++priv_gptr;
  480.                 }
  481.  
  482.     int        sputbackc(char __c) {
  483.                 if (priv_gptr >= priv_egptr) return EOF;
  484.                 if (priv_gptr > priv_eback ) {
  485.                     if ( *--priv_gptr == __c )
  486.                         return zapeof(__c);
  487.                     else return zapeof(*priv_gptr=__c);
  488.                     }
  489.                 else {
  490.                     return pbackfail(__c);
  491.                     }
  492.                 }
  493.  
  494.     int        sputc(int __c) {
  495.                 return (priv_pptr>=priv_epptr)
  496.                     ? overflow((int)zapeof(__c))
  497.                     : zapeof(*priv_pptr++=__c);
  498.                 }
  499.  
  500.     int        sputn(const char* __str,int __num) {
  501.                 if ( __num <= (priv_epptr-priv_pptr) ) {
  502.                     memcpy(priv_pptr, __str, __num);
  503.                     pbump(__num);
  504.                     return __num;
  505.                     }
  506.                 else {
  507.                     return xsputn(__str, __num);
  508.                     }
  509.                 }
  510.  
  511.     int        sgetn(char* __str,int __num) {
  512.                 if ( __num <= (priv_egptr-priv_gptr) ) {
  513.                     memcpy(__str,(const char*)priv_gptr,
  514.                            __num);
  515.                     gbump(__num);
  516.                     return __num;
  517.                     }
  518.                 else {
  519.                     return xsgetn(__str, __num);
  520.                     }
  521.                 }
  522.  
  523.     virtual streambuf*
  524.             setbuf(char* __buf, int __len);
  525.  
  526.     streambuf*    setbuf(unsigned char* __buf, int __len) {
  527.                 return (setbuf((char*)__buf, __len));
  528.                 }
  529.  
  530.     virtual        ~streambuf();
  531.     };
  532.  
  533.  
  534.  
  535. class istream : virtual public ios {
  536.  
  537. private:
  538.     int        priv_gcount;        // Keep track of # of chars
  539.                         //  last extracted.
  540.     void        ischeck_state();
  541.     void        _doget(char* __c);    // Actually does a get.
  542.  
  543. protected:
  544.     int        do_ipfx(int __noskipws);
  545.     void        do_isfx();
  546.     int        eatwhite(void);
  547.             istream();
  548.             
  549. public:
  550.             istream(streambuf *__buffer);
  551.     virtual        ~istream();
  552.     
  553.     int        ipfx(int __noskipws=0) {
  554.                 if ( __noskipws?(ispecial&~skipping):ispecial) {
  555.                     return do_ipfx(__noskipws);
  556.                     }
  557.                 else return 1;
  558.                 }
  559.  
  560.     void        isfx() {
  561.                 if (isfx_special) do_isfx();
  562.                 }
  563.  
  564.     istream&    seekg(streampos __position);
  565.             
  566.     istream&    seekg(streamoff __offset, ios::seek_dir __dir);
  567.  
  568.             // Returns the current offset into the get buffer.
  569.     streampos    tellg();
  570.  
  571.             // For manipulators.
  572.     istream&    operator>> (istream& (*__fcn)(istream&)) {
  573.                 return (*__fcn)(*this);
  574.                 }
  575.  
  576.             // For manipulators.
  577.     istream&    operator>> (ios& (*__fcn)(ios&) );
  578.  
  579.     istream&    operator>>(char *__cp);
  580.     istream&    operator>>(unsigned char *__ucp);
  581.     istream&    operator>>(unsigned char &__ucr);
  582.     istream&    operator>>(char& __cr);
  583.     istream&    operator>>(short& __sr);
  584.     istream&    operator>>(int& __ir);
  585.     istream&    operator>>(long& __lr);
  586.     istream&    operator>>(unsigned short& __usr);
  587.     istream&    operator>>(unsigned int& __uir);
  588.     istream&    operator>>(unsigned long& __ulr);
  589.     istream&    operator>>(float& __fr);
  590.     istream&    operator>>(double& __dr);
  591.     istream&    operator>>(long double& __ldr);
  592.     istream&    operator>>(streambuf* __sp);
  593.  
  594.             // Read and extract characters ending in delim,
  595.             //  up to a maximum of lim characters.
  596.             // delim IS NOT stored in buffer.
  597.     istream&    get(char* __buffer, int __lim, char __delim='\n');
  598.     istream&    get(unsigned char* __buffer, int __lim, char __delim='\n');
  599.     istream&    get(char* __buffer, int __lim, char *__delims);
  600.     istream&    get(unsigned char* __buffer, int __lim, char *__delims);
  601.  
  602.             // Read and extract characters ending in delim,
  603.             //  up to a maximum of lim characters.
  604.             // delim IS stored in buffer if space allows.
  605.     istream&    getline(char* __buffer, int __lim, char __delim='\n');
  606.     istream&    getline(unsigned char* __buffer,int __lim, char __delim='\n'); 
  607.     istream&    getline(char* __buffer, int __lim, char *__delims);
  608.     istream&    getline(unsigned char* __buffer,int __lim, char *__delims); 
  609.             // Read and extract character.
  610.     istream&    get(streambuf& __sb, char __delim ='\n');
  611.     istream&    get(unsigned char& __c);
  612.     istream&    get(char& __c);
  613.     int        get();
  614.  
  615.             // Read next character, but don't extract.
  616.     int        peek() {
  617.                 if ( ipfx(-1) ) return rdbuf()->sgetc();
  618.                 else return EOF;
  619.                 }
  620.  
  621.             // Extract and trash n characters, stopping
  622.             //  if delim is encountered.
  623.     istream&    ignore(int __num=1,int __delim=EOF);
  624.  
  625.     istream&    read(char* __buf,int __num);
  626.     istream&    read(unsigned char* __buf,int __num) {
  627.                 return read((char*)__buf,__num);
  628.                 }
  629.     int        gcount() { return priv_gcount; }
  630.     istream&    putback(char __c);
  631.     int        sync()  { return rdbuf()->sync(); }
  632.     };
  633.  
  634.  
  635.  
  636. class ostream : virtual public ios {
  637.  
  638. protected:
  639.     int        do_opfx();
  640.     void        do_osfx();
  641.             ostream();
  642.  
  643. public:
  644.             ostream(streambuf *__sbp);
  645.     virtual        ~ostream();
  646.  
  647.     int        opfx() {
  648.                 if (!good()) return 0;
  649.                 else if (ospecial) return do_opfx();
  650.                 else return 1;
  651.                 }
  652.  
  653.     void        osfx() {
  654.                 if (osfx_special) do_osfx();
  655.                 }
  656.  
  657.     ostream&    flush();
  658.  
  659.     ostream&    seekp(streampos __pos);
  660.  
  661.     ostream&    seekp(streamoff __off, ios::seek_dir __dir);
  662.  
  663.     streampos    tellp();
  664.  
  665.     ostream&    put(char __c);
  666.  
  667.     ostream&    operator<<(char __c) {
  668.                 return put(__c);
  669.                 }
  670.  
  671.     ostream&    operator<<(unsigned char __uc) {
  672.                 return put(__uc);
  673.                 }
  674.  
  675.     ostream&    operator<<(const char* __ccp);
  676.  
  677.     ostream&    operator<<(int __i);
  678.                 
  679.     ostream&    operator<<(long __l);
  680.  
  681.     ostream&    operator<<(double __d);
  682.  
  683.     ostream&    operator<<(long double __ld);
  684.  
  685.     ostream&    operator<<(float __f);
  686.  
  687.     ostream&    operator<<(unsigned int  __ui);
  688.  
  689.     ostream&    operator<<(unsigned long __ul);
  690.  
  691.     ostream&    operator<<(void* __vp);
  692.  
  693.     ostream&    operator<<(streambuf* __sbp);
  694.  
  695.     ostream&    operator<<(short __s);
  696.  
  697.     ostream&    operator<<(unsigned short __us);
  698.  
  699.             // For manipulators.
  700.     ostream&    operator<<(ostream& (*__fcn)(ostream&)) {
  701.                 return (*__fcn)(*this);
  702.                 }
  703.  
  704.             // For manipulators.
  705.     ostream&    operator<<(ios& (*__fcn)(ios&) );
  706.  
  707.     ostream&    write(const char* __str,int __num);
  708.     ostream&    write(const unsigned char* __str, int __num) {
  709.                 return write((const char*)__str,__num);
  710.                 }
  711.     };
  712.  
  713.  
  714. class iostream : public istream, public ostream {
  715. protected:
  716.             iostream();
  717.  
  718. public:
  719.             iostream(streambuf* __sbp);
  720.     virtual        ~iostream();
  721.     };
  722.  
  723.  
  724. class istream_withassign : public istream {
  725. public:
  726.                 istream_withassign();
  727.     virtual            ~istream_withassign();
  728.     istream_withassign&    operator=(istream&);
  729.     istream_withassign&    operator=(streambuf*);
  730.     };
  731.  
  732.  
  733. class ostream_withassign : public ostream {
  734. public:
  735.                 ostream_withassign();
  736.     virtual            ~ostream_withassign();
  737.     ostream_withassign&    operator=(ostream&);
  738.     ostream_withassign&    operator=(streambuf*);
  739.     };
  740.  
  741.  
  742. class iostream_withassign : public iostream {
  743. public:
  744.                 iostream_withassign();
  745.     virtual            ~iostream_withassign();
  746.     iostream_withassign&    operator=(ios&);
  747.     iostream_withassign&    operator=(streambuf*);
  748.     };
  749. #pragma pop(nodebug)
  750.  
  751.  
  752. extern istream_withassign cin;
  753. extern ostream_withassign cout;
  754. extern ostream_withassign cerr;
  755. extern ostream_withassign clog;
  756. #ifdef _MSDOS
  757. // Additional standard streams provided under DOS
  758. extern ostream_withassign caux;
  759. extern ostream_withassign cprn;
  760. #endif
  761.  
  762. extern ostream&        endl(ostream& os);
  763. extern ostream&        ends(ostream& os);
  764. extern ostream&        flush(ostream& os);
  765. extern ios&        dec(ios& iosr);
  766. extern ios&        oct(ios& iosr);
  767. extern ios&        hex(ios& iosr);
  768. extern istream&        ws(istream& is);
  769.  
  770.  
  771. #pragma Pop(Behaved)
  772.  
  773. #pragma pop_align_members();
  774. #endif
  775.  
  776.  
  777. /**      Copyright (c) 1991-1992, MetaWare Incorporated         **/
  778.