home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / STRSTREA.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  173 lines

  1. /*  strstream.h -- class strstream declarations
  2.  
  3. */
  4.  
  5. /*
  6.  *      C/C++ Run Time Library - Version 6.5
  7.  *
  8.  *      Copyright (c) 1990, 1994 by Borland International
  9.  *      All Rights Reserved.
  10.  *
  11.  */
  12.  
  13. #ifndef __cplusplus
  14. #error Must use C++ for the type strstream.
  15. #endif
  16.  
  17. #ifndef __STRSTREAM_H
  18. #define __STRSTREAM_H
  19.  
  20. #if !defined(___DEFS_H)
  21. #include <_defs.h>
  22. #endif
  23.  
  24. #if !defined(__IOSTREAM_H)
  25. #include <iostream.h>
  26. #endif
  27.  
  28.  
  29. #if !defined(RC_INVOKED)
  30.  
  31. #pragma option -a-
  32.  
  33. #if defined(__BCOPT__)
  34. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  35. #pragma option -po-     // disable Object data calling convention
  36. #endif
  37. #endif
  38.  
  39. #if !defined(__TINY__)
  40. #pragma option -RT
  41. #endif
  42.  
  43. #pragma option -Vo-
  44.  
  45. #if defined(__STDC__)
  46. #pragma warn -nak
  47. #endif
  48.  
  49. #endif  /* !RC_INVOKED */
  50.  
  51.  
  52. _CLASSDEF(strstreambuf)
  53. _CLASSDEF(strstreambase)
  54. _CLASSDEF(istrstream)
  55. _CLASSDEF(ostrstream)
  56. _CLASSDEF(strstream)
  57.  
  58. class _EXPCLASS strstreambuf : public streambuf {
  59. public:
  60.     _RTLENTRY strstreambuf();
  61.     _RTLENTRY strstreambuf(int n);
  62.     _RTLENTRY strstreambuf(void _FAR * (*a)(long), void (*f)(void _FAR *));
  63.     _RTLENTRY strstreambuf(         char _FAR * _s, int,
  64.                                     char _FAR * _strt=0);
  65.     _RTLENTRY strstreambuf(signed   char _FAR * _s, int,
  66.                            signed   char _FAR * _strt=0);
  67.     _RTLENTRY strstreambuf(unsigned char _FAR * _s, int,
  68.                            unsigned char _FAR * _strt=0);
  69.     _RTLENTRY ~strstreambuf();
  70.  
  71.     void    _RTLENTRY freeze(int = 1);
  72.     char _FAR *  _RTLENTRY str();
  73. virtual int _RTLENTRY doallocate();
  74. virtual int _RTLENTRY overflow(int);
  75. virtual int _RTLENTRY underflow();
  76. virtual int _RTLENTRY sync();
  77. virtual streambuf _FAR * _RTLENTRY setbuf(char _FAR *, int);
  78. virtual streampos   _RTLENTRY seekoff(streamoff, ios::seek_dir, int);
  79.  
  80. private:
  81.     void _FAR *  _RTLENTRY (*allocf)(long);
  82.     void    _RTLENTRY (*freef)(void _FAR *);
  83.     short   ssbflags;
  84.     enum    { dynamic = 1, frozen = 2, unlimited = 4 };
  85.     int next_alloc;
  86.  
  87.     void    _RTLENTRY init(char _FAR *, int, char _FAR *);
  88. };
  89.  
  90.  
  91. class _EXPCLASS strstreambase : public virtual ios {
  92. public:
  93.     strstreambuf _FAR * _RTLENTRY rdbuf();
  94.  
  95. protected:
  96.         _RTLENTRY strstreambase(char _FAR *, int, char _FAR *);
  97.         _RTLENTRY strstreambase();
  98.         _RTLENTRY ~strstreambase();
  99. private:
  100.         strstreambuf buf;
  101. };
  102. inline strstreambuf _FAR * _RTLENTRY strstreambase::rdbuf()
  103.                                     { return &this->buf; }
  104.  
  105.  
  106. class _EXPCLASS istrstream : public strstreambase, public istream {
  107. public:
  108.         _RTLENTRY istrstream(         char _FAR *);
  109.         _RTLENTRY istrstream(signed   char _FAR *);
  110.         _RTLENTRY istrstream(unsigned char _FAR *);
  111.         _RTLENTRY istrstream(         char _FAR *, int);
  112.         _RTLENTRY istrstream(signed   char _FAR *, int);
  113.         _RTLENTRY istrstream(unsigned char _FAR *, int);
  114.         _RTLENTRY ~istrstream();
  115. };
  116.  
  117.  
  118. class _EXPCLASS ostrstream : public strstreambase, public ostream {
  119. public:
  120.         _RTLENTRY ostrstream(         char _FAR *, int, int = ios::out);
  121.         _RTLENTRY ostrstream(signed   char _FAR *, int, int = ios::out);
  122.         _RTLENTRY ostrstream(unsigned char _FAR *, int, int = ios::out);
  123.         _RTLENTRY ostrstream();
  124.         _RTLENTRY ~ostrstream();
  125.  
  126.     char _FAR * _RTLENTRY str();
  127.     int     _RTLENTRY pcount();
  128. };
  129. inline char _FAR * _RTLENTRY ostrstream::str()
  130.                 { return strstreambase::rdbuf()->str(); }
  131. inline int  _RTLENTRY ostrstream::pcount()
  132.                 { return strstreambase::rdbuf()->out_waiting(); }
  133.  
  134.  
  135. class _EXPCLASS strstream : public strstreambase, public iostream {
  136. public:
  137.         _RTLENTRY strstream();
  138.         _RTLENTRY strstream(         char _FAR *, int _sz, int _m);
  139.         _RTLENTRY strstream(signed   char _FAR *, int _sz, int _m);
  140.         _RTLENTRY strstream(unsigned char _FAR *, int _sz, int _m);
  141.         _RTLENTRY ~strstream();
  142.  
  143.     char _FAR * _RTLENTRY str();
  144. };
  145. inline char _FAR * _RTLENTRY strstream::str()
  146.                 { return strstreambase::rdbuf()->str(); }
  147.  
  148.  
  149. #if !defined(RC_INVOKED)
  150.  
  151. #if defined(__STDC__)
  152. #pragma warn .nak
  153. #endif
  154.  
  155. #pragma option -Vo.
  156.  
  157. #if !defined(__TINY__)
  158. #pragma option -RT.
  159. #endif
  160.  
  161. #if defined(__BCOPT__)
  162. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  163. #pragma option -po.     // restore Object data calling convention
  164. #endif
  165. #endif
  166.  
  167. #pragma option -a.  /* restore default packing */
  168.  
  169. #endif  /* !RC_INVOKED */
  170.  
  171.  
  172. #endif  /* __STRSTREAM_H */
  173.