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

  1. #ifndef __RWVSTREAM_H__
  2. #define __RWVSTREAM_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * rw[io]stream --- abstract base class for I/O
  7.  *
  8.  * $Header:   E:/vcs/rw/vstream.h_v   1.6   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.  * $Log:   E:/vcs/rw/vstream.h_v  $
  23.  * 
  24.  *    Rev 1.6   18 Feb 1992 09:54:52   KEFFER
  25.  * 
  26.  *    Rev 1.5   05 Nov 1991 13:52:52   keffer
  27.  * Can now live in the DLL
  28.  * 
  29.  *    Rev 1.4   17 Oct 1991 09:12:58   keffer
  30.  * Changed include path to <rw/xxx.h>
  31.  * 
  32.  *    Rev 1.2   29 Jul 1991 11:33:30   keffer
  33.  * Macro CHAR_MATCHES_UCHAR checks for overloaded unsigned char
  34.  * 
  35.  *    Rev 1.1   24 Jul 1991 13:06:50   keffer
  36.  * Added pvcs keywords
  37.  *
  38.  */
  39.  
  40. /*
  41.  * The Rogue Wave "virtual streams" facility has been designed to 
  42.  * accomodate both V1.2 style "streams" and V2.X style "iostreams".
  43.  * This was necessary because certain compiler manufacturers (whose 
  44.  * names will go unmentioned) have stuck with V1.2 streams.
  45.  *
  46.  * This has greatly complicated the design, resulting in different 
  47.  * inheritance hierarchies for the two situations.
  48.  */
  49.  
  50. #include "rw/rstream.h"
  51.  
  52. /************************************************
  53.  *                        *
  54.  *        class RWvistream        *
  55.  *                        *
  56.  ************************************************/
  57.  
  58. class RWExport RWvistream : 
  59. #ifdef HAS_IOSTREAMS
  60.             /* Has V2.x style iostreams; use ios as a virtual base class */
  61.             public virtual ios {
  62. public:
  63.   RWvistream(streambuf* s) : ios(s) { }
  64.  
  65. #else
  66.             /* Has V1.2 style streams; use istream as a regular base class. */
  67.             public istream {
  68. public:
  69.   RWvistream(istream& str) : istream(str) { }
  70.   RWvistream(streambuf* s) : istream(s) { }
  71.  
  72. #endif
  73.  
  74.   virtual int        get() = 0;            // Treat as number; EOF on end-of-file
  75.   virtual RWvistream&    get(char&) = 0;            // Treat as number
  76. #ifndef CHAR_MATCHES_UCHAR
  77.   virtual RWvistream&    get(unsigned char&) = 0;    // Treat as number
  78. #endif
  79.   virtual RWvistream&    get(char*, unsigned N) = 0;
  80.   virtual RWvistream&    get(double*, unsigned N) = 0;
  81.   virtual RWvistream&    get(float*, unsigned N) = 0;
  82.   virtual RWvistream&    get(int*, unsigned N) = 0;
  83.   virtual RWvistream&    get(long*, unsigned N) = 0;
  84.   virtual RWvistream&    get(short*, unsigned N) = 0;
  85. #ifndef CHAR_MATCHES_UCHAR
  86.   virtual RWvistream&    get(unsigned char*, unsigned N) = 0;
  87. #endif
  88.   virtual RWvistream&    get(unsigned short*, unsigned N) = 0;
  89.   virtual RWvistream&    get(unsigned int*, unsigned N) = 0;
  90.   virtual RWvistream&    get(unsigned long*, unsigned N) = 0;
  91.   virtual RWvistream&    getString(char* s, unsigned N) = 0;    // Treat as character string
  92.   virtual RWvistream&    operator>>(char&) = 0;            // Treat as character
  93.   virtual RWvistream&    operator>>(double&) = 0;
  94.   virtual RWvistream&    operator>>(float&) = 0;
  95.   virtual RWvistream&    operator>>(int&) = 0;
  96.   virtual RWvistream&    operator>>(long&) = 0;
  97.   virtual RWvistream&    operator>>(short&) = 0;
  98. #ifndef CHAR_MATCHES_UCHAR
  99.   virtual RWvistream&    operator>>(unsigned char&) = 0;
  100. #endif
  101.   virtual RWvistream&    operator>>(unsigned short&) = 0;
  102.   virtual RWvistream&    operator>>(unsigned int&) = 0;
  103.   virtual RWvistream&    operator>>(unsigned long&) = 0;
  104. };
  105.  
  106. /************************************************
  107.  *                        *
  108.  *        class RWvostream        *
  109.  *                        *
  110.  ************************************************/
  111.  
  112. class RWExport RWvostream : 
  113.  
  114. #ifdef HAS_IOSTREAMS
  115.  
  116.             public virtual ios {
  117. public:
  118.   RWvostream(streambuf* s) : ios(s) { }
  119.  
  120. #else
  121.  
  122.             public ostream {
  123. public:
  124.   RWvostream(ostream& str) : ostream(str) { }
  125.   RWvostream(streambuf* s) : ostream(s) { }
  126.  
  127. #endif
  128.  
  129.   virtual RWvostream&    operator<<(const char*) = 0;        // Treat as character string
  130.   virtual RWvostream&    operator<<(char) = 0;            // Treat as character
  131. #ifndef CHAR_MATCHES_UCHAR
  132.   virtual RWvostream&    operator<<(unsigned char) = 0;
  133. #endif
  134.   virtual RWvostream&    operator<<(double) = 0;
  135.   virtual RWvostream&    operator<<(float) = 0;
  136.   virtual RWvostream&    operator<<(int) = 0;
  137.   virtual RWvostream&    operator<<(unsigned int) = 0;
  138.   virtual RWvostream&    operator<<(long) = 0;
  139.   virtual RWvostream&    operator<<(unsigned long) = 0;
  140.   virtual RWvostream&    operator<<(short) = 0;
  141.   virtual RWvostream&    operator<<(unsigned short) = 0;
  142.  
  143.   virtual RWvostream&    put(char) = 0;                    // Treat as number
  144.   virtual RWvostream&    put(const char* p, unsigned N) = 0;        // Treat as vector of numbers
  145. #ifndef CHAR_MATCHES_UCHAR
  146.   virtual RWvostream&    put(unsigned char) = 0;
  147.   virtual RWvostream&    put(const unsigned char* p, unsigned N) = 0;
  148. #endif
  149.   virtual RWvostream&    put(const short* p, unsigned N) = 0;
  150.   virtual RWvostream&    put(const unsigned short* p, unsigned N) = 0;
  151.   virtual RWvostream&    put(const int* p, unsigned N) = 0;
  152.   virtual RWvostream&    put(const unsigned int* p, unsigned N) = 0;
  153.   virtual RWvostream&    put(const long* p, unsigned N) = 0;
  154.   virtual RWvostream&    put(const unsigned long* p, unsigned N) = 0;
  155.   virtual RWvostream&    put(const float* p, unsigned N) = 0;
  156.   virtual RWvostream&    put(const double* p, unsigned N) = 0;
  157. };
  158.  
  159. pragma pop_align_members();
  160. #endif /* __RWVSTREAM_H__ */
  161.