home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / P < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.3 KB  |  99 lines

  1. /*
  2.  *   strstream.h
  3.  *
  4.  *   C++ IOStreams specialized for use with strings.
  5.  *
  6.  *           Copyright (c) 1991-1992, MetaWare Incorporated
  7.  */
  8.  
  9. /*   $Id: strstrea.h,v 1.3 1991/12/18 21:49:03 jeff Exp $ */
  10.  
  11.  
  12. #ifndef __STRSTREAM_H
  13. #define __STRSTREAM_H
  14. #pragma push_align_members(64);
  15.  
  16. #c_include <iostream.h>
  17.  
  18.  
  19. class strstreambuf : public streambuf {
  20. private:
  21.     void        init(char* __base, int __len,char* __put_origin);
  22.     void*        (*alloc_fcn)(long);    // fcn used to allocate space
  23.     void        (*free_fcn)(void*);    // fcn used to free space
  24.     enum strflags    {
  25.               ignore_oflow =  0x01,    // Ignore overflow condition
  26.               auto_extend  =  0x02,    // Reallocate buffer when full
  27.               frozen       =  0x04    // Buffer frozen--inserts fail
  28.             };
  29.     long        _strflags;        // status flags
  30.     int        next_min_alloc;
  31.  
  32. public: 
  33.             strstreambuf();
  34.             strstreambuf(int __min_size);
  35.             strstreambuf(void* (*__alloc)(long),
  36.                     void (*__free)(void*));
  37.             strstreambuf(char* __base, int __len,
  38.                     char* __put_origin = 0 );
  39.             strstreambuf(unsigned char* __base, int __len,
  40.                     unsigned char* __put_origin = 0 );
  41.             ~strstreambuf();
  42.  
  43.     void        freeze(int __frozen=1);
  44.     char*        str();
  45.     virtual int    doallocate();
  46.     virtual int    overflow(int __c);
  47.     virtual int    underflow();
  48.     virtual streambuf*
  49.             setbuf(char*, int __len);
  50.     virtual streampos
  51.             seekoff(streamoff __offset, ios::seek_dir __dir,
  52.                     long __mode);
  53.  
  54.     };
  55.  
  56. class strstreambase : public virtual ios {
  57. private:
  58.     strstreambuf    buf; 
  59. protected:    
  60.             strstreambase(char* __base, int __len,
  61.                     char* __put_origin);
  62.             strstreambase();
  63.             ~strstreambase();
  64. public:
  65.     strstreambuf*    rdbuf();
  66.     };
  67.  
  68. class istrstream : public strstreambase, public istream {
  69. public:
  70.             istrstream(char* __base);
  71.             istrstream(char* __base, int __len);
  72.             ~istrstream();
  73.     };
  74.  
  75. class ostrstream : public strstreambase, public ostream {
  76. public:
  77.             ostrstream(char* __base, int __len,
  78.                     int __mode=ios::out);
  79.             ostrstream();
  80.             ~ostrstream();
  81.     char*        str();
  82.     int        pcount();
  83.     };
  84.  
  85.  
  86. class strstream : public strstreambase, public iostream {
  87. public:
  88.             strstream();
  89.             strstream(char* __base, int __len, int __mode);
  90.             ~strstream();
  91.     char*        str();
  92.     };
  93.  
  94.  
  95. #pragma pop_align_members();
  96. #endif __STRSTREAM_H
  97.  
  98. /**          Copyright (c) 1991-1992, MetaWare Incorporated             **/
  99.