home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / STRSTREA.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  4KB  |  167 lines

  1. /*  strstream.h -- class strstream declarations
  2.  
  3. */
  4.  
  5. /*
  6.  *      C/C++ Run Time Library - Version 1.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. #endif
  35.  
  36. #if !defined(__TINY__)
  37. #pragma option -RT
  38. #endif
  39.  
  40. #pragma option -Vo-
  41.  
  42. #if defined(__STDC__)
  43. #pragma warn -nak
  44. #endif
  45.  
  46. #endif  /* !RC_INVOKED */
  47.  
  48.  
  49. _CLASSDEF(strstreambuf)
  50. _CLASSDEF(strstreambase)
  51. _CLASSDEF(istrstream)
  52. _CLASSDEF(ostrstream)
  53. _CLASSDEF(strstream)
  54.  
  55. class _EXPCLASS strstreambuf : public streambuf {
  56. public:
  57.     _RTLENTRY strstreambuf();
  58.     _RTLENTRY strstreambuf(int n);
  59.     _RTLENTRY strstreambuf(void _FAR * (*a)(long), void (*f)(void _FAR *));
  60.     _RTLENTRY strstreambuf(         char _FAR * _s, int,
  61.                                     char _FAR * _strt=0);
  62.     _RTLENTRY strstreambuf(signed   char _FAR * _s, int,
  63.                            signed   char _FAR * _strt=0);
  64.     _RTLENTRY strstreambuf(unsigned char _FAR * _s, int,
  65.                            unsigned char _FAR * _strt=0);
  66.     _RTLENTRY ~strstreambuf();
  67.  
  68.     void    _RTLENTRY freeze(int = 1);
  69.     char _FAR *  _RTLENTRY str();
  70. virtual int _RTLENTRY doallocate();
  71. virtual int _RTLENTRY overflow(int);
  72. virtual int _RTLENTRY underflow();
  73. virtual int _RTLENTRY sync();
  74. virtual streambuf _FAR * _RTLENTRY setbuf(char _FAR *, int);
  75. virtual streampos   _RTLENTRY seekoff(streamoff, ios::seek_dir, int);
  76.  
  77. private:
  78.     void _FAR *  _RTLENTRY (*allocf)(long);
  79.     void    _RTLENTRY (*freef)(void _FAR *);
  80.     short   ssbflags;
  81.     enum    { dynamic = 1, frozen = 2, unlimited = 4 };
  82.     int next_alloc;
  83.  
  84.     void    _RTLENTRY init(char _FAR *, int, char _FAR *);
  85. };
  86.  
  87.  
  88. class _EXPCLASS strstreambase : public virtual ios {
  89. public:
  90.     strstreambuf _FAR * _RTLENTRY rdbuf();
  91.  
  92. protected:
  93.         _RTLENTRY strstreambase(char _FAR *, int, char _FAR *);
  94.         _RTLENTRY strstreambase();
  95.         _RTLENTRY ~strstreambase();
  96. private:
  97.         strstreambuf buf;
  98. };
  99. inline strstreambuf _FAR * _RTLENTRY strstreambase::rdbuf()
  100.                                     { return &this->buf; }
  101.  
  102.  
  103. class _EXPCLASS istrstream : public strstreambase, public istream {
  104. public:
  105.         _RTLENTRY istrstream(         char _FAR *);
  106.         _RTLENTRY istrstream(signed   char _FAR *);
  107.         _RTLENTRY istrstream(unsigned char _FAR *);
  108.         _RTLENTRY istrstream(         char _FAR *, int);
  109.         _RTLENTRY istrstream(signed   char _FAR *, int);
  110.         _RTLENTRY istrstream(unsigned char _FAR *, int);
  111.         _RTLENTRY ~istrstream();
  112. };
  113.  
  114.  
  115. class _EXPCLASS ostrstream : public strstreambase, public ostream {
  116. public:
  117.         _RTLENTRY ostrstream(         char _FAR *, int, int = ios::out);
  118.         _RTLENTRY ostrstream(signed   char _FAR *, int, int = ios::out);
  119.         _RTLENTRY ostrstream(unsigned char _FAR *, int, int = ios::out);
  120.         _RTLENTRY ostrstream();
  121.         _RTLENTRY ~ostrstream();
  122.  
  123.     char _FAR * _RTLENTRY str();
  124.     int     _RTLENTRY pcount();
  125. };
  126. inline char _FAR * _RTLENTRY ostrstream::str()
  127.                 { return strstreambase::rdbuf()->str(); }
  128. inline int  _RTLENTRY ostrstream::pcount()
  129.                 { return strstreambase::rdbuf()->out_waiting(); }
  130.  
  131.  
  132. class _EXPCLASS strstream : public strstreambase, public iostream {
  133. public:
  134.         _RTLENTRY strstream();
  135.         _RTLENTRY strstream(         char _FAR *, int _sz, int _m);
  136.         _RTLENTRY strstream(signed   char _FAR *, int _sz, int _m);
  137.         _RTLENTRY strstream(unsigned char _FAR *, int _sz, int _m);
  138.         _RTLENTRY ~strstream();
  139.  
  140.     char _FAR * _RTLENTRY str();
  141. };
  142. inline char _FAR * _RTLENTRY strstream::str()
  143.                 { return strstreambase::rdbuf()->str(); }
  144.  
  145.  
  146. #if !defined(RC_INVOKED)
  147.  
  148. #if defined(__STDC__)
  149. #pragma warn .nak
  150. #endif
  151.  
  152. #pragma option -Vo.
  153.  
  154. #if !defined(__TINY__)
  155. #pragma option -RT.
  156. #endif
  157.  
  158. #if defined(__BCOPT__)
  159. #endif
  160.  
  161. #pragma option -a.  /* restore default packing */
  162.  
  163. #endif  /* !RC_INVOKED */
  164.  
  165.  
  166. #endif  /* __STRSTREAM_H */
  167.