home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / INCLUDE / OSTREAM.H_ / OSTREAM.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  4.2 KB  |  130 lines

  1. /***
  2. *ostream.h - definitions/declarations for the ostream class
  3. *
  4. *   Copyright (c) 1991-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *   This file defines the classes, values, macros, and functions
  8. *   used by the ostream class.
  9. *   [AT&T C++]
  10. *
  11. ****/
  12.  
  13. #ifndef _INC_OSTREAM
  14. #define _INC_OSTREAM
  15.  
  16. #include <ios.h>
  17.  
  18. // Force word packing to avoid possible -Zp override
  19. #pragma pack(2)
  20.  
  21. #pragma warning(disable:4505)       // disable unwanted /W4 warning
  22. // #pragma warning(default:4505)    // use this to reenable, if necessary
  23.  
  24. #ifdef M_I86HM
  25. #define _HFAR_ __far
  26. #else 
  27. #define _HFAR_
  28. #endif 
  29.  
  30. typedef long streamoff, streampos;
  31.  
  32. class ostream : virtual public ios {
  33.  
  34. public:
  35.     ostream(streambuf*);
  36.     virtual ~ostream();
  37.  
  38.     ostream& flush();
  39.     int  opfx();
  40.     void osfx();
  41.  
  42. inline  ostream& operator<<(ostream& (*f)(ostream&));
  43. inline  ostream& operator<<(ios& (*f)(ios&));
  44.     ostream& operator<<(const char _HFAR_ *);
  45. inline  ostream& operator<<(const unsigned char _HFAR_ *);
  46. inline  ostream& operator<<(const signed char _HFAR_ *);
  47. inline  ostream& operator<<(char);
  48.     ostream& operator<<(unsigned char);
  49. inline  ostream& operator<<(signed char);
  50.     ostream& operator<<(short);
  51.     ostream& operator<<(unsigned short);
  52.     ostream& operator<<(int);
  53.     ostream& operator<<(unsigned int);
  54.     ostream& operator<<(long);
  55.     ostream& operator<<(unsigned long);
  56. inline  ostream& operator<<(float);
  57.     ostream& operator<<(double);
  58.     ostream& operator<<(long double);
  59.     ostream& operator<<(const void _HFAR_ *);
  60.     ostream& operator<<(streambuf*);
  61. inline  ostream& put(char);
  62.     ostream& put(unsigned char);
  63. inline  ostream& put(signed char);
  64.     ostream& write(const char _HFAR_ *,int);
  65. inline  ostream& write(const unsigned char _HFAR_ *,int);
  66. inline  ostream& write(const signed char _HFAR_ *,int);
  67.     ostream& seekp(streampos);
  68.     ostream& seekp(streamoff,ios::seek_dir);
  69.     streampos tellp();
  70.  
  71. protected:
  72.     ostream();
  73.     ostream(const ostream&);    // treat as private
  74.     ostream& operator=(streambuf*); // treat as private
  75.     ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); }
  76.     int do_opfx(int);       // not used
  77.     void do_osfx();         // not used
  78.  
  79. private:
  80.     ostream(ios&);
  81.     ostream& writepad(const char _HFAR_ *, const char _HFAR_ *);
  82.     int x_floatused;
  83. };
  84.  
  85. inline ostream& ostream::operator<<(ostream& (*f)(ostream&)) { (*f)(*this); return *this; }
  86. inline ostream& ostream::operator<<(ios& (*f)(ios& )) { (*f)(*this); return *this; }
  87.  
  88. inline  ostream& ostream::operator<<(char c) { return operator<<((unsigned char) c); }
  89. inline  ostream& ostream::operator<<(signed char c) { return operator<<((unsigned char) c); }
  90.  
  91. inline  ostream& ostream::operator<<(const unsigned char _HFAR_ * s) { return operator<<((const char _HFAR_ *) s); }
  92. inline  ostream& ostream::operator<<(const signed char _HFAR_ * s) { return operator<<((const char _HFAR_ *) s); }
  93.  
  94. inline  ostream& ostream::operator<<(float f) { x_floatused = 1; return operator<<((double) f); }
  95.  
  96. inline  ostream& ostream::put(char c) { return put((unsigned char) c); }
  97. inline  ostream& ostream::put(signed char c) { return put((unsigned char) c); }
  98.  
  99. inline  ostream& ostream::write(const unsigned char _HFAR_ * s, int n) { return write((char _HFAR_ *) s, n); }
  100. inline  ostream& ostream::write(const signed char _HFAR_ * s, int n) { return write((char _HFAR_ *) s, n); }
  101.  
  102.  
  103. class ostream_withassign : public ostream {
  104.     public:
  105.         ostream_withassign();
  106.         ostream_withassign(streambuf* _is);
  107.         ~ostream_withassign();
  108.     ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); }
  109.     ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); }
  110. };
  111.  
  112. #ifndef _WINDLL
  113. extern ostream_withassign cout;
  114. extern ostream_withassign cerr;
  115. extern ostream_withassign clog;
  116. #endif 
  117.  
  118. inline ostream& flush(ostream& _outs) { return _outs.flush(); }
  119. inline ostream& endl(ostream& _outs) { return _outs << '\n' << flush; }
  120. inline ostream& ends(ostream& _outs) { return _outs << char('\0'); }
  121.  
  122. ios&        dec(ios&);
  123. ios&        hex(ios&);
  124. ios&        oct(ios&);
  125.  
  126. // Restore default packing
  127. #pragma pack()
  128.  
  129. #endif 
  130.