home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / ostream1.cpp < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  65 lines

  1. /***
  2. * ostream1.cpp - definitions for ostream class non-core member functions
  3. *
  4. *       Copyright (c) 1991-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Contains the non-core member function definitions for ostream class.
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <internal.h>
  13. #include <iostream.h>
  14. #pragma hdrstop
  15.  
  16. ostream& ostream::seekp(streampos _strmp)
  17. {
  18.     lockbuf();
  19.  
  20.     if (bp->seekpos(_strmp, ios::out)==EOF)
  21.         clear(state | failbit);
  22.  
  23.     unlockbuf();
  24.     return(*this);
  25. }
  26.  
  27. ostream& ostream::seekp(streamoff _strmf, seek_dir _sd)
  28. {
  29.     lockbuf();
  30.  
  31.     if (bp->seekoff(_strmf, _sd, ios::out)==EOF)
  32.         clear(state | failbit);
  33.  
  34.     unlockbuf();
  35.     return(*this);
  36. }
  37.  
  38. streampos ostream::tellp()
  39. {
  40.     streampos retval;
  41.     lockbuf();
  42.  
  43.     if ((retval=bp->seekoff(streamoff(0), ios::cur, ios::out))==EOF)
  44.         clear(state | failbit);
  45.  
  46.     unlockbuf();
  47.     return(retval);
  48. }
  49.  
  50. ostream& ostream::operator<<(streambuf * instm)
  51. {
  52.     int c;
  53.     if (opfx())
  54.         {
  55.         while ((c=instm->sbumpc())!=EOF)
  56.             if (bp->sputc(c) == EOF)
  57.                 {
  58.                 state |= failbit;
  59.                 break;
  60.                 }
  61.         osfx();
  62.         }
  63.     return *this;
  64. }
  65.