home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modhead1.zip / STDIOSTR.H < prev    next >
C/C++ Source or Header  |  1995-09-17  |  2KB  |  91 lines

  1. /*
  2.  *   stdiostr.h
  3.  *
  4.  *   C++ IOStreams specialized for use in conjunction with
  5.  *   stdio FILEs.
  6.  *
  7.  *           Copyright (c) 1991-1992, MetaWare Incorporated
  8.  */
  9.  
  10. #ifndef __STDIOSTREAM_H
  11. #define __STDIOSTREAM_H
  12. #pragma push_align_members(64);
  13.  
  14. #if _MSDOS && !__EXCEPTIONS__
  15.     #pragma off(exception_aware_class);
  16. #elif _MSDOS || _MSNT || _OS2
  17.     #pragma on(exception_aware_class);
  18. #endif
  19.  
  20. #if _MSNT && _DLL && !_DLLBUILD
  21.     #pragma on(dllimport);
  22. #endif
  23.  
  24. #c_include <iostream.h>
  25. #c_include <stdio.h>
  26.  
  27. #pragma on(nodebug)
  28.  
  29. /*
  30.  *  Class stdiobuf is provided to support concurrent use of the C stdio
  31.  *  and C++ iostreams standard input and output streams.  Using stdiobufs
  32.  *  can cause a severe degradation in performance.  It should not be
  33.  *  necessary to use stdiobufs if the standard output streams are set for
  34.  *  unit buffering (ios::unitbuf) and all input operations on cin are
  35.  *  line-oriented on a cooked input stream.
  36.  *
  37.  *  Use of class stdiobuf should be avoided whenever possible.
  38.  */
  39.  
  40. class stdiobuf : public streambuf {
  41.  
  42. private:
  43.     FILE*        _fp;            
  44.     char        _tmp_buf[2];
  45.  
  46. public:
  47.     virtual int    _UNSAFE(overflow)(int=EOF);
  48.     virtual int    _UNSAFE(underflow)();
  49.     virtual int    _UNSAFE(sync)();
  50.     virtual streampos
  51.             _UNSAFE(seekoff)(streamoff,ios::seek_dir,long);
  52.     virtual int    pbackfail(int __c);
  53.  
  54.             stdiobuf(FILE* __fp);
  55.     FILE*        stdiofile() { return _fp; }
  56.     virtual        ~stdiobuf();
  57. #if _MT
  58.     virtual int    overflow(int=EOF);
  59.     virtual int    underflow();
  60.     virtual int    sync();
  61.     virtual streampos
  62.             seekoff(streamoff,ios::seek_dir,long);
  63. #endif
  64.     };
  65.  
  66. class stdiostream : public ios {
  67. private:
  68.     stdiobuf    _buf;
  69.  
  70. public:
  71.             stdiostream(FILE* __fp);
  72.             ~stdiostream();
  73.     stdiobuf*    rdbuf() { return &_buf; }
  74.     };
  75.  
  76. #pragma pop(nodebug)
  77.  
  78.  
  79. #if _MSNT && _DLL && !_DLLBUILD
  80.     #pragma pop(dllimport);
  81. #endif
  82.  
  83. #if _MSDOS || _MSNT || _OS2
  84.     #pragma pop(exception_aware_class);
  85. #endif
  86.  
  87. #pragma pop_align_members();
  88. #endif __STDIOSTREAM_H
  89.  
  90. /**          Copyright (c) 1991-1993, MetaWare Incorporated             **/
  91.