home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 13 < prev    next >
Encoding:
Text File  |  1992-06-07  |  3.7 KB  |  122 lines

  1. #ifndef __RWWINSTREAM_H__
  2. #define __RWWINSTREAM_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWCLIPstreambuf & RWDDEstreambuf: Specialized streambufs, used for MS Windows (TM)
  7.  *
  8.  * $Header:   E:/vcs/rw/winstrea.h_v   1.4   18 Feb 1992 09:54:52   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * Under Windows, note the near similarity of the two constructors
  23.  *
  24.  *    RWCLIPstreambuf(int N);        // Dynamic.  Initial allocation of "N"
  25.  *    RWCLIPstreambuf(HANDLE hMem);    // Static.   Use memory "hMem".
  26.  *
  27.  * This is because "HANDLE" has been typedef'd to "unsigned int", an
  28.  * unfortunate consequence of Window's generally poor type checking.
  29.  * Yet, the two constructors have vastly different semantics.
  30.  * 
  31.  * It is for this reason that an extra dummy argument was added to
  32.  * the first of these constructors:
  33.  *
  34.  *    RWCLIPstreambuf(int N, int);    // 2'nd argument ignored.
  35.  *
  36.  * This dummy argument is ignored.
  37.  *
  38.  * $Log:   E:/vcs/rw/winstrea.h_v  $
  39.  * 
  40.  *    Rev 1.4   18 Feb 1992 09:54:52   KEFFER
  41.  * 
  42.  *    Rev 1.3   12 Nov 1991 13:16:16   keffer
  43.  * seek_dir is now scoped for C++ V2.1 compiliant compilers.
  44.  * 
  45.  *    Rev 1.2   05 Nov 1991 13:53:26   keffer
  46.  * Can now live in the DLL.
  47.  * Scoped seek_dir with ios::.
  48.  * 
  49.  *    Rev 1.1   28 Oct 1991 09:08:36   keffer
  50.  * Changed inclusions to <rw/xxx.h>
  51.  * 
  52.  *    Rev 1.0   28 Jul 1991 08:18:12   keffer
  53.  * Tools.h++ V4.0.5 PVCS baseline version
  54.  *
  55.  */
  56.  
  57. #include "rw/defs.h"
  58. #include <windows.h>
  59. #ifdef __ZTC__
  60. #  include <iostream.hpp>
  61. #else
  62. #  ifdef __GLOCK__
  63. #    include <iostream.hxx>
  64. #  else
  65. #    include <iostream.h>
  66. #  endif
  67. #endif
  68.  
  69. class RWExport RWCLIPstreambuf : public streambuf {
  70. protected:
  71.   int            frozen;
  72.   int            autoAlloc;
  73.   int            locked;
  74.   HANDLE        hMem;
  75. protected:
  76.   // Virtual functions inherted from streambuf:
  77.   virtual int        doallocate();
  78.   virtual int        overflow(int);
  79.   virtual streampos    seekoff(streamoff, RWSCOPE(ios)seek_dir, int);
  80.   virtual streambuf*    setbuf(char* s, int n);
  81.   virtual int        underflow();
  82.  
  83.   // Virtual function introduced here:
  84.   virtual HANDLE    getHandle(DWORD size);    // Type of handle can be overridden
  85.  
  86. public: 
  87.   RWCLIPstreambuf();        // Dynamic mode
  88.   RWCLIPstreambuf(int N, int);    // Dynamic mode w. initial allocation N; see notes above
  89.   RWCLIPstreambuf(HANDLE hMem);    // Static mode, init w. block at hMem
  90.   ~RWCLIPstreambuf();        // Free any unfrozen memory
  91.  
  92.   void            freeze(int n = TRUE);
  93.   HANDLE        str();    // NB: return type
  94. };
  95.  
  96. class RWExport RWDDEstreambuf : public RWCLIPstreambuf {
  97.   WORD            _wFormat;
  98.   BOOL            _fResponse;
  99.   BOOL            _fAckReq;
  100.   BOOL            _fRelease;
  101. protected:
  102.   // Virtual functions overridden from RWCLIPstreambuf:
  103.   virtual HANDLE    getHandle(DWORD size);
  104.   virtual int        doallocate();
  105. public:
  106.   /* This form usually used by server: */
  107.   RWDDEstreambuf(WORD format,        // Format of data
  108.                  BOOL response,        // In response to WM_DDE_REQUEST; otherwise WM_DDE_ADVISE
  109.                  BOOL ackReq,        // Requests an acknowledment
  110.                  BOOL release);        // Client responsible for memory release
  111.  
  112.   RWDDEstreambuf(HANDLE hMem);    /* Usually used by client */
  113.  
  114.   WORD            format() const   {return _wFormat;}
  115.   BOOL            response() const {return _fResponse;}
  116.   BOOL            ackReq() const   {return _fAckReq;}
  117.   BOOL            release() const  {return _fRelease;}
  118. };
  119.  
  120. pragma pop_align_members();
  121. #endif
  122.