home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / LinAlg 3.1 / ANSI #includes addenda / ostream < prev    next >
Encoding:
Text File  |  1995-05-30  |  3.2 KB  |  116 lines  |  [TEXT/MMCC]

  1. // ostream standard header
  2. #ifndef _OSTREAM_
  3. #define _OSTREAM_
  4. #include <streambuf>
  5.  
  6. #if __MWERKS__
  7. #pragma options align=mac68k
  8. #endif
  9.  
  10.         // class ostream
  11. class ostream : virtual public ios {
  12. public:
  13.     ostream(streambuf *_S)
  14.            { init(_S); }
  15.     ostream(_Uninitialized)
  16.         : ios(_Noinit) {}
  17.     virtual ~ostream();
  18.     _Bool opfx();
  19.     void osfx();
  20.     ostream& operator<<(ostream& (*_F)(ostream&))
  21.         {return ((*_F)(*this)); }
  22.     ostream& operator<<(ios& (*_F)(ios&))
  23.         {(*_F)(*(ios *)this); return (*this); }
  24.     ostream& operator<<(const char *);
  25.     ostream& operator<<(char _C)
  26.         {put(_C); return (*this); }
  27.     ostream& operator<<(unsigned char _C)
  28.         {return (*this << (char)_C); }
  29.     ostream& operator<<(short _X)
  30.         {return (_Print(&"B hoB hxB hd"[_If()], _X)); }
  31.     ostream& operator<<(unsigned short _X)
  32.         {return (_Print(&"B hoB hxB hu"[_If()], _X)); }
  33.     ostream& operator<<(int _X)
  34.         {return (_Print(&"B  oB  xB  d"[_If()], _X)); }
  35.     ostream& operator<<(unsigned int _X)
  36.         {return (_Print(&"B  oB  xB  u"[_If()], _X)); }
  37.     ostream& operator<<(long _X)
  38.         {return (_Print(&"B loB lxB ld"[_If()], _X)); }
  39.     ostream& operator<<(unsigned long _X)
  40.         {return (_Print(&"B loB lxB lu"[_If()], _X)); }
  41.     ostream& operator<<(float _X)
  42.         {return (_Print(&"P. eP. fP. g"[_Ff()], _Pr(), _X)); }
  43.     ostream& operator<<(double _X)
  44.         {return (_Print(&"P.leP.lfP.lg"[_Ff()], _Pr(), _X)); }
  45.     ostream& operator<<(long double _X)
  46.         {return (_Print(&"P.LeP.LfP.Lg"[_Ff()], _Pr(), _X)); }
  47.     ostream& operator<<(void *);
  48.     ostream& operator<<(streambuf&);
  49.     ostream& put(char);
  50.     ostream& write(const char *, int);
  51.     ostream& write(const unsigned char *_S, int _N)
  52.         {return (write((const char *)_S, _N)); }
  53.     ostream& flush();
  54. streampos tellp()
  55. {
  56.     streampos pos = rdbuf()->pubseekoff(0, ios::cur, ios::out);
  57.     if (pos == streampos(EOF))
  58.         setstate(ios::badbit);
  59.     return pos;
  60. }
  61. ostream& seekp(streampos pos)
  62. {
  63.     pos = rdbuf()->pubseekpos(pos, ios::out);
  64.     if (pos == streampos(EOF))
  65.         setstate(ios::badbit);
  66.     return *this;
  67. }
  68.  
  69. ostream& seekp(streamoff off, ios::seek_dir dir)
  70. {
  71.   streampos pos = rdbuf()->pubseekoff(off,dir,ios::out);
  72.   if (pos == streampos(EOF))
  73.     setstate(ios::badbit);
  74.   return *this;
  75. }
  76. #if _HAS_SIGNED_CHAR
  77.     ostream& operator<<(signed char _C)
  78.         {return (*this << (char)_C); }
  79.     ostream& write(const signed char *_S, int _N)
  80.         {return (write((const char *)_S, _N)); }
  81. #endif /* _HAS_SIGNED_CHAR */
  82. protected:
  83.     int _Ff()
  84.         {return ((flags() & floatfield) == scientific ? 0
  85.             : (flags() & floatfield) == fixed ? 4 : 8); }
  86.     int _If()
  87.         {return ((flags() & basefield) == oct ? 0
  88.             : (flags() & basefield) == hex ? 4 : 8); }
  89.     void _Pad(const char *, char *, int);
  90.     int _Pr();
  91.     ostream& _Print(const char *, ...);
  92.     };
  93.         // manipulators
  94. ostream& endl(ostream&);
  95. ostream& ends(ostream&);
  96. ostream& flush(ostream&);
  97.  
  98. #if __MWERKS__
  99. #pragma options align=reset
  100. #endif
  101.  
  102. #endif
  103.  
  104. /*
  105.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  106.  * Consult your license regarding permissions and restrictions.
  107.  */
  108.  
  109. /* Change log:
  110.  * 1994-06-04: PlumHall baseline
  111.  * 1994-09-30: Applied diffs for Fri Aug 26 00:51:20 1994
  112.  * 1994-10-07: Inserted MW changes.
  113.  * 1994-10-14: XL04 change istream(streambuf *_S) to init derived 
  114.  *//* Change log:
  115.  */
  116.