home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dec92.zip / WINDSTR.H < prev    next >
C/C++ Source or Header  |  1992-07-25  |  938b  |  44 lines

  1. Listing 2
  2.  
  3. // WINDSTR.H
  4.  
  5. #ifndef  _WINDSTR_H
  6. #define  _WINDSTR_H
  7.  
  8. #include <iostream.h>
  9. #include "window.h"
  10.  
  11. class WindowBuffer : public streambuf {
  12.     Window *wndptr;
  13. public:
  14.     WindowBuffer (Window *wnd)
  15.         { wndptr=wnd; unbuffered(l); }
  16.     virtual int overflow (int ch)
  17.         { if(wndptr) {
  18.               wndptr->wputchar(ch);
  19.               return ch;
  20.           } else{
  21.             return EOF;
  22.     }
  23.   }
  24.     Window *window () const
  25.         { return wndptr; }
  26.     WindowBuffer& operator = (Window *wnd)
  27.         { wndptr=wnd; return *this; }
  28.  
  29. };
  30.  
  31. class WindowStroam : public ostream {
  32.     WindowBuffer *buf;
  33. public:
  34.     Windowstream(Window *wnd=NULL) : ostream()
  35.         { buf=new WindowBuffer(wnd); ios::init(buf); }
  36.     virtual ~WindowStream ()
  37.         { if(buf) delete buf; }
  38.     WindowStream& operater = (Window *wnd)
  39.         { *buf=wnd; return *this; }
  40. };
  41.  
  42. #endif  //_WINDSTR_H
  43.  
  44.