home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ibasstrm.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  8.7 KB  |  224 lines

  1. #ifndef _IBASSTRM_
  2. #define _IBASSTRM_
  3. /*******************************************************************************
  4. * FILE NAME: ibasstrm.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IBaseStream                                                              *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *   Portions or this component are based on work originating from Taligent.    *
  18. *   (C) Copyright Taligent, Inc. 1996 - All rights reserved.                   *
  19. *                                                                              *
  20. *******************************************************************************/
  21. #include <ivbase.hpp>
  22. #include <istring.hpp>
  23. #include <iseq.h>
  24. #include <iptr.h>
  25. #include <iacllct.h>
  26.  
  27. class IContext;
  28.  
  29. #pragma pack(4)
  30.  
  31.  
  32. class IBaseStream : public IVBase {
  33. typedef IBase
  34.   Inherited;
  35. public:
  36. /*------------------------------- Type Definitions ---------------------------*/
  37. typedef unsigned short  VersionNumber;
  38. typedef unsigned long   Position;
  39. typedef long            PositionDelta;
  40.  
  41. /*------------------------------- Constructors -------------------------------*/
  42. virtual
  43.  ~IBaseStream();
  44.  
  45.  
  46. /*------------------------ Reading and Writing Primitives --------------------*/
  47. virtual IBaseStream
  48.  &read    ( void*           target,
  49.             size_t          byteCount ),
  50.  &read    ( char*           target ),
  51.  &read    ( signed char&    target ),
  52.  &read    ( unsigned char&  target ),
  53.  &read    ( short&          target ),
  54.  &read    ( unsigned short& target ),
  55.  &read    ( long&           target ),
  56.  &read    ( unsigned long&  target ),
  57.  &read    ( float&          target ),
  58.  &read    ( double&         target);
  59.  
  60. virtual IBaseStream
  61.  &write   ( const void*     source,
  62.             size_t          byteCount ),
  63.  &write   ( const char*     source ),
  64.  &write   ( signed char     source ),
  65.  &write   ( unsigned char   source ),
  66.  &write   ( short           source ),
  67.  &write   ( unsigned short  source ),
  68.  &write   ( long            source ),
  69.  &write   ( unsigned long   source ),
  70.  &write   ( float           source ),
  71.  &write   ( double          source );
  72.  
  73. /*------------------------ Reading and Writing Arrays ------------------------*/
  74. virtual IBaseStream
  75.  &write   ( const signed char source[],    unsigned long count ),
  76.  &write   ( const unsigned char source[],  unsigned long count ),
  77.  &write   ( const short source[],          unsigned long count ),
  78.  &write   ( const unsigned short source[], unsigned long count ),
  79.  &write   ( const long source[],           unsigned long count ),
  80.  &write   ( const unsigned long source[],  unsigned long count ),
  81.  &write   ( const float source[],          unsigned long count ),
  82.  &write   ( const double source[],         unsigned long count );
  83.  
  84. virtual IBaseStream
  85.  &read    ( signed char target[],    unsigned long count ),
  86.  &read    ( unsigned char target[],  unsigned long count ),
  87.  &read    ( short target[],          unsigned long count ),
  88.  &read    ( unsigned short target[], unsigned long count ),
  89.  &read    ( long target[],           unsigned long count ),
  90.  &read    ( unsigned long target[],  unsigned long count ),
  91.  &read    ( float target[],          unsigned long count ),
  92.  &read    ( double target[],         unsigned long count );
  93.  
  94.  
  95. /*------------- Stream Positioning, Flushing, and Write Access ---------------*/
  96. virtual Position
  97.   position              ( ) const = 0,
  98.   logicalEndOfStream    ( ) const,
  99.   physicalEndOfStream   ( ) const = 0;
  100.  
  101. virtual IBaseStream
  102.  &seek                  ( Position      position) = 0,
  103.  &seekRelative          ( PositionDelta offset),
  104.  &setLogicalEndOfStream ( Position      position),
  105.  &setPhysicalEndOfStream ( Position position) = 0,
  106.  &flush   ( );
  107.  
  108. virtual Boolean
  109.   isWriteable    ( ) const;
  110.  
  111. /*------------------------------- Stream Context------------------------------*/
  112. virtual IBaseStream
  113.  &setContext     ( IContext* context );
  114. IContext
  115.  *context        ( ) const,
  116.  *defaultContext ( ) const;
  117.  
  118. protected:
  119. /*------------------------ Buffer Management Overrides -----------------------*/
  120. virtual void
  121.   handleReadBufferEmpty   ( void*       target,
  122.                             size_t      byteCount ) = 0;
  123.  
  124. virtual void
  125.   handleWriteBufferFull   ( const void* source,
  126.                             size_t      byteCount ) = 0;
  127.  
  128.  
  129. /*------------------------------- Constructors -------------------------------*/
  130.   IBaseStream  ( );
  131.  
  132.  
  133. /*---------------------------- Primitive Type Lengths ------------------------*/
  134. enum TypeLength {
  135.   kCharBytes = 1,
  136.   kSignedCharBytes = 1,
  137.   kUnsignedCharBytes = 1,
  138.   kShortBytes = 2,
  139.   kUnsignedShortBytes = 2,
  140.   kUnsignedLongBytes = 4,
  141.   kLongBytes = 4,
  142.   kFloatBytes = 4,
  143.   kDoubleBytes = 8};
  144.  
  145. private:
  146. /*------------------------------ Hidden Members ------------------------------*/
  147.   IBaseStream  ( const IBaseStream& baseStream);
  148. const IBaseStream
  149.  &operator=    ( const IBaseStream& baseStream);
  150.  
  151. /*----------------------------- Private --------------------------------------*/
  152. IContext
  153.  *fContext,
  154.  *fDefaultContext;
  155.  
  156. };  // IBaseStream
  157.  
  158. /*------------------------- Builtin Types Streaming Operators-----------------*/
  159. IBaseStream& operator<<=(char*           target, IBaseStream& baseStream);
  160. IBaseStream& operator<<=(long&           target, IBaseStream& baseStream);
  161. IBaseStream& operator<<=(short&          target, IBaseStream& baseStream);
  162. IBaseStream& operator<<=(char&           target, IBaseStream& baseStream);
  163. IBaseStream& operator<<=(signed char&    target, IBaseStream& baseStream);
  164. IBaseStream& operator<<=(unsigned long&  target, IBaseStream& baseStream);
  165. IBaseStream& operator<<=(unsigned short& target, IBaseStream& baseStream);
  166. IBaseStream& operator<<=(unsigned char&  target, IBaseStream& baseStream);
  167. IBaseStream& operator<<=(float&          target, IBaseStream& baseStream);
  168. IBaseStream& operator<<=(double&         target, IBaseStream& baseStream);
  169.  
  170. IBaseStream& operator>>=(const char*     source, IBaseStream& baseStream);
  171. IBaseStream& operator>>=(long            source, IBaseStream& baseStream);
  172. IBaseStream& operator>>=(short           source, IBaseStream& baseStream);
  173. IBaseStream& operator>>=(char            source, IBaseStream& baseStream);
  174. IBaseStream& operator>>=(signed char     source, IBaseStream& baseStream);
  175. IBaseStream& operator>>=(unsigned long   source, IBaseStream& baseStream);
  176. IBaseStream& operator>>=(unsigned short  source, IBaseStream& baseStream);
  177. IBaseStream& operator>>=(unsigned char   source, IBaseStream& baseStream);
  178. IBaseStream& operator>>=(float           source, IBaseStream& baseStream);
  179. IBaseStream& operator>>=(double          source, IBaseStream& baseStream);
  180.  
  181.  
  182. /*------------------------- IString Streaming Operators-----------------------*/
  183. // These will be converted to IString members in the future.
  184. IBaseStream& operator<<=(IString&        target, IBaseStream& baseStream);
  185. IBaseStream& operator>>=(const IString&  source, IBaseStream& baseStream);
  186.  
  187.  
  188. /*------------------------- Collection Streaming Operators--------------------*/
  189. // These will be converted to Collection members in the future.
  190. template<class AType>
  191. IBaseStream& operator<<=(IACollection<AType>&, IBaseStream& s);
  192.  
  193. template<class AType>
  194. IBaseStream& operator>>=(const IACollection<AType>&, IBaseStream& s);
  195.  
  196.  
  197.  
  198. template<class AType>
  199. IBaseStream& operator<<=( IElemPointer<AType>&, IBaseStream& baseStream );
  200.  
  201. template<class AType>
  202. IBaseStream& operator>>=( const IElemPointer<AType>&, IBaseStream& baseStream );
  203.  
  204.  
  205.  
  206. /*------------------------- Version Writing and Reading ----------------------*/
  207. void
  208.   writeVersion( IBaseStream& toWhere, const IBaseStream::VersionNumber version = 0 );
  209.  
  210. IBaseStream::VersionNumber
  211.   readVersion(IBaseStream& fromWhere);
  212.  
  213. #ifndef __TEMPINC__
  214.   #include <ibasstrm.c>
  215. #endif
  216.  
  217.   #include <ibasstrm.inl>
  218.  
  219.  
  220. #pragma pack()
  221.  
  222. #endif /* _IBASSTRM_ */
  223.  
  224.