home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / streams.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  139 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. #ifndef STREAMS_H
  21. #define STREAMS_H
  22.  
  23. #ifdef EDITOR
  24.  
  25. #include "xp.h"
  26. #include "xp_file.h"
  27. #include "itapefs.h"
  28. #include "libi18n.h"
  29.  
  30. //-----------------------------------------------------------------------------
  31. //  Streams
  32. //-----------------------------------------------------------------------------
  33.  
  34. // IStreamOut is in "itapefs.h"
  35.  
  36. class IStreamIn {
  37. public:
  38.     IStreamIn() {}
  39.     virtual ~IStreamIn() {}
  40.  
  41.     virtual void Read( char *pBuffer, int32 iCount )=0;
  42.     int32 ReadInt(){ int32 i; Read((char*)&i, sizeof(int32)); return i; }
  43.     char *ReadZString();
  44. };
  45.  
  46.  
  47. //
  48. // Output Stream as file.
  49. //
  50. class CStreamOutFile: public IStreamOut {
  51. private:
  52.     EOutStreamStatus m_status;
  53.     XP_File m_outputFile;  
  54.     XP_Bool m_bBinary;
  55. public:
  56.     CStreamOutFile(  XP_File hFile, XP_Bool bBinary  );
  57.     virtual ~CStreamOutFile();
  58.     virtual void Write( char *pBuffer, int32 iCount );
  59.     virtual EOutStreamStatus Status(){ return m_status; }
  60. };
  61.  
  62. //
  63. // Stream out to net.
  64. //
  65. class CStreamOutNet: public IStreamOut {
  66. private:
  67.     NET_StreamClass * m_pStream;
  68.     EOutStreamStatus m_status;
  69. protected:
  70.     CStreamOutNet();
  71.     void SetStream(NET_StreamClass *m_pStream);
  72. public:
  73.     CStreamOutNet( MWContext* pContext );
  74.     virtual ~CStreamOutNet();
  75.     virtual void Write( char *pBuffer, int32 iCount );
  76.     virtual EOutStreamStatus Status(){ return m_status; }
  77. };
  78.  
  79. class CStreamOutAnyNet: public CStreamOutNet {
  80. public:
  81.     CStreamOutAnyNet(MWContext* pContext,URL_Struct *URL_s,FO_Present_Types type);
  82. };
  83.  
  84. class CNetStreamToTapeFS: public CStreamOutNet {
  85. public:
  86.     CNetStreamToTapeFS(MWContext* pContext,ITapeFileSystem *);
  87. };
  88.  
  89. //
  90. // Output Stream as memory
  91. //
  92. class CStreamOutMemory: public IStreamOut {
  93. private:
  94.     int32 m_bufferSize;
  95.     int32 m_bufferEnd;
  96.     XP_HUGE_CHAR_PTR m_pBuffer;
  97. public:
  98.     CStreamOutMemory();
  99.     virtual ~CStreamOutMemory();
  100.     virtual void Write( char *pBuffer, int32 iCount );
  101.     XP_HUGE_CHAR_PTR GetText(){ return m_pBuffer; }
  102.     int32 GetLen(){ return m_bufferEnd; }
  103. };
  104.  
  105. // Convert character set encodings while streaming out.
  106. // Adopts an existing IStreamOut* object.
  107. // Deletes the existing IStreamOut* object when
  108. // it itself is deleted. (Unless ForgetStream() is called.)
  109.  
  110. class CConvertCSIDStreamOut : public IStreamOut {
  111. private:
  112.     IStreamOut* m_pStream;
  113.     CCCDataObject m_Converter;
  114.     XP_Bool m_bNullConversion;
  115.     int16 m_oldCSID;
  116.     int16 m_newCSID;
  117. public:
  118.     CConvertCSIDStreamOut(int16 oldCSID, int16 newCSID, IStreamOut* pStream);
  119.     virtual ~CConvertCSIDStreamOut();
  120.     virtual void Write( char* pBuffer, int32 iCount );
  121.     IStreamOut* ForgetStream();
  122.     int16 GetOldCSID();
  123.     int16 GetNewCSID();
  124. };
  125.  
  126. class CStreamInMemory: public IStreamIn {
  127. private:
  128.     XP_HUGE_CHAR_PTR m_pBuffer;
  129.     int32 m_iCurrentPos;
  130. public:
  131.     virtual void Read( char *pBuffer, int32 iCount );
  132.     CStreamInMemory(char *pMem): m_pBuffer(pMem), m_iCurrentPos(0){}
  133. };
  134.  
  135.  
  136.  
  137. #endif // EDITOR
  138. #endif
  139.