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

  1. /***
  2. *iostrini.cpp - definition and initialization for predefined stream cout.
  3. *
  4. *       Copyright (c) 1991-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Definition and initialization of and predefined iostream cout.
  8. *
  9. *******************************************************************************/
  10. #include <cruntime.h>
  11. #include <internal.h>
  12. #include <iostream.h>
  13. #include <fstream.h>
  14. #include <dbgint.h>
  15. #pragma hdrstop
  16.  
  17. // put contructors in special MS-specific XIFM segment
  18. #pragma warning(disable:4074)   // disable init_seg warning
  19. #pragma init_seg(compiler)
  20.  
  21. ostream_withassign cout(_new_crt filebuf(1));
  22.  
  23. static Iostream_init  __InitCout(cout,-1);
  24.  
  25.  
  26. /***
  27. *Iostream_init::Iostream_init() - initialize predefined streams
  28. *
  29. *Purpose:
  30. *        For compatibility only.  Not used.
  31. *Entry:
  32. *
  33. *Exit:
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38.         Iostream_init::Iostream_init() { }      // do nothing
  39.  
  40. /***
  41. *Iostream_init::Iostream_init() - initialize predefined streams
  42. *
  43. *Purpose:
  44. *        Initializes predefined streams: cin, cout, cerr, clog;
  45. *Entry:
  46. *       pstrm = cin, cout, cerr, or clog
  47. *       sflg =  1 if cerr (unit buffered)
  48. *       sflg = -1 if cout
  49. *
  50. *Exit:
  51. *
  52. *Exceptions:
  53. *
  54. *******************************************************************************/
  55.         Iostream_init::Iostream_init(ios& pstrm, int sflg)
  56. {
  57.         pstrm.delbuf(1);
  58.         if (sflg>=0)    // make sure not cout
  59.                 pstrm.tie(&cout);
  60.         if (sflg>0)
  61.                 pstrm.setf(ios::unitbuf);
  62. }
  63.  
  64. /***
  65. *Iostream_init::~Iostream_init() - destroy predefined streams on exit
  66. *
  67. *Purpose:
  68. *        Destroy predefined streams: cin, cout, cerr, clog;
  69. *Entry:
  70. *
  71. *Exit:
  72. *
  73. *Exceptions:
  74. *
  75. *******************************************************************************/
  76.         Iostream_init::~Iostream_init() { }     // do nothing
  77.  
  78.