Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.6 KiB

  1. /***
  2. *strstream.h - definitions/declarations for strstreambuf, strstream
  3. *
  4. * Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the classes, values, macros, and functions
  8. * used by the strstream and strstreambuf classes.
  9. * [AT&T C++]
  10. *
  11. ****/
  12. #ifndef _INC_STRSTREAM
  13. #define _INC_STRSTREAM
  14. #include <iostream.h>
  15. // Force word packing to avoid possible -Zp override
  16. #pragma pack(2)
  17. #pragma warning(disable:4505) // disable unwanted /W4 warning
  18. // #pragma warning(default:4505) // use this to reenable, if necessary
  19. #ifdef M_I86HM
  20. #define _HFAR_ __far
  21. #else
  22. #define _HFAR_
  23. #endif
  24. class strstreambuf : public streambuf {
  25. public:
  26. strstreambuf();
  27. strstreambuf(int);
  28. strstreambuf(char _HFAR_ *, int, char _HFAR_ * = 0);
  29. strstreambuf(unsigned char _HFAR_ *, int, unsigned char _HFAR_ * = 0);
  30. strstreambuf(signed char _HFAR_ _HFAR_ *, int, signed char _HFAR_ * = 0);
  31. strstreambuf(void _HFAR_ * (*a)(long), void (*f) (void _HFAR_ *));
  32. ~strstreambuf();
  33. void freeze(int =1);
  34. char _HFAR_ * str();
  35. virtual int overflow(int);
  36. virtual int underflow();
  37. virtual streambuf* setbuf(char _HFAR_ *, int);
  38. virtual streampos seekoff(streamoff, ios::seek_dir, int);
  39. virtual int sync(); // not in spec.
  40. protected:
  41. virtual int doallocate();
  42. private:
  43. int x_dynamic;
  44. int x_bufmin;
  45. int _fAlloc;
  46. int x_static;
  47. void _HFAR_ * (* x_alloc)(long);
  48. void (* x_free)(void _HFAR_ *);
  49. };
  50. class istrstream : public istream {
  51. public:
  52. istrstream(char _HFAR_ *);
  53. istrstream(char _HFAR_ *, int);
  54. ~istrstream();
  55. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  56. inline char _HFAR_ * str() { return rdbuf()->str(); }
  57. };
  58. class ostrstream : public ostream {
  59. public:
  60. ostrstream();
  61. ostrstream(char _HFAR_ *, int, int = ios::out);
  62. ~ostrstream();
  63. inline int pcount() const { return rdbuf()->out_waiting(); }
  64. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  65. inline char _HFAR_ * str() { return rdbuf()->str(); }
  66. };
  67. class strstream : public iostream { // strstreambase ???
  68. public:
  69. strstream();
  70. strstream(char _HFAR_ *, int, int);
  71. ~strstream();
  72. inline int pcount() const { return rdbuf()->out_waiting(); } // not in spec.
  73. inline strstreambuf* rdbuf() const { return (strstreambuf*) ostream::rdbuf(); }
  74. inline char _HFAR_ * str() { return rdbuf()->str(); }
  75. };
  76. // Restore default packing
  77. #pragma pack()
  78. #endif