home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / STRSTREA.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  3.0 KB  |  118 lines

  1. /*  strstream.h -- class strstream declarations
  2.  
  3.     Copyright (c) 1990,1991 by Borland International    
  4.     All rights reserved
  5. */
  6.  
  7. #ifndef __cplusplus
  8. #error Must use C++ for the type strstream.
  9. #endif
  10.  
  11. #ifndef __STRSTREAM_H
  12. #define __STRSTREAM_H
  13.  
  14. #if !defined( __IOSTREAM_H )
  15. #include <iostream.h>
  16. #endif
  17.  
  18. #ifdef __DLL__
  19. #define _FAR far
  20. #else
  21. #define _FAR
  22. #endif
  23.  
  24. #if __STDC__
  25. #define _Cdecl
  26. #else
  27. #define _Cdecl  cdecl
  28. #endif
  29.  
  30. #if   defined(__SMALL__) || defined(__MEDIUM__)
  31. #define _CLASSTYPE  near
  32. #elif defined(__COMPACT__) || defined(__LARGE__)
  33. #define _CLASSTYPE  far
  34. #else
  35. #define _CLASSTYPE  huge
  36. #endif
  37.  
  38. class _CLASSTYPE strstreambuf : public streambuf {
  39. public:
  40.     _Cdecl strstreambuf();
  41.     _Cdecl strstreambuf(int n);
  42.     _Cdecl strstreambuf(void _FAR * (*a)(long), void (*f)(void _FAR *));
  43.     _Cdecl strstreambuf( signed char _FAR * _s, int,
  44.                          signed char _FAR * _strt=0);
  45.     _Cdecl strstreambuf( unsigned char _FAR * _s, int,
  46.                          unsigned char _FAR * _strt=0);
  47.     _Cdecl ~strstreambuf();
  48.  
  49.     void    _Cdecl freeze(int = 1);
  50.     char _FAR * _Cdecl str();
  51. virtual int _Cdecl doallocate();
  52. virtual int _Cdecl overflow(int);
  53. virtual int _Cdecl underflow();
  54. virtual streambuf _FAR * _Cdecl setbuf(char _FAR *, int);
  55. virtual streampos  _Cdecl seekoff(streamoff, seek_dir, int);
  56.  
  57. private:
  58.     void _FAR * _Cdecl (*allocf)(long);
  59.     void    _Cdecl (*freef)(void _FAR *);
  60.     short   ssbflags;
  61.     enum    { dynamic = 1, frozen = 2, unlimited = 4 };
  62.     int next_alloc;
  63.  
  64.     void    _Cdecl init(signed char _FAR *, int, signed char _FAR *);
  65. };
  66.  
  67.  
  68. class _CLASSTYPE strstreambase : public virtual ios {
  69. public:
  70.     strstreambuf _FAR * _Cdecl rdbuf();
  71.  
  72. protected:
  73.         _Cdecl strstreambase(char _FAR *, int, char _FAR *);
  74.         _Cdecl strstreambase();
  75.         _Cdecl ~strstreambase();
  76. private:
  77.         strstreambuf buf;
  78. };
  79. inline strstreambuf _FAR * _Cdecl strstreambase::rdbuf()
  80.                                     { return &this->buf; }
  81.  
  82.  
  83. class _CLASSTYPE istrstream : public strstreambase, public istream {
  84. public:
  85.         _Cdecl istrstream(char _FAR *);
  86.         _Cdecl istrstream(char _FAR *, int);
  87.         _Cdecl ~istrstream();
  88. };
  89.  
  90.  
  91. class _CLASSTYPE ostrstream : public strstreambase, public ostream {
  92. public:
  93.         _Cdecl ostrstream(char _FAR *, int, int = ios::out);
  94.         _Cdecl ostrstream();
  95.         _Cdecl ~ostrstream();
  96.  
  97.     char _FAR * _Cdecl str();
  98.     int     _Cdecl pcount();
  99. };
  100. inline char _FAR * _Cdecl ostrstream::str()
  101.                 { return strstreambase::rdbuf()->str(); }
  102. inline int  _Cdecl ostrstream::pcount()
  103.                 { return strstreambase::rdbuf()->out_waiting(); }
  104.  
  105.  
  106. class _CLASSTYPE strstream : public strstreambase, public iostream {
  107. public:
  108.         _Cdecl strstream();
  109.         _Cdecl strstream(char _FAR *, int _sz, int _m);
  110.         _Cdecl ~strstream();
  111.  
  112.     char _FAR * _Cdecl str();
  113. };
  114. inline char _FAR * _Cdecl strstream::str()
  115.                 { return strstreambase::rdbuf()->str(); }
  116.  
  117. #endif
  118.