Source code of Windows XP (NT5)
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.

111 lines
2.6 KiB

  1. /***
  2. *strstream.h - definitions/declarations for strstreambuf, strstream
  3. *
  4. * Copyright (c) 1991-1994, 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. /* Define _CRTIMP */
  15. #ifndef _CRTIMP
  16. #ifdef _NTSDK
  17. /* definition compatible with NT SDK */
  18. #define _CRTIMP
  19. #else /* ndef _NTSDK */
  20. /* current definition */
  21. #ifdef _DLL
  22. #define _CRTIMP __declspec(dllimport)
  23. #else /* ndef _DLL */
  24. #define _CRTIMP
  25. #endif /* _DLL */
  26. #endif /* _NTSDK */
  27. #endif /* _CRTIMP */
  28. #include <iostream.h>
  29. #ifdef _MSC_VER
  30. // Force word packing to avoid possible -Zp override
  31. #pragma pack(push,4)
  32. #pragma warning(disable:4505) // disable unwanted /W4 warning
  33. // #pragma warning(default:4505) // use this to reenable, if necessary
  34. #endif // _MSC_VER
  35. class _CRTIMP strstreambuf : public streambuf {
  36. public:
  37. strstreambuf();
  38. strstreambuf(int);
  39. strstreambuf(char *, int, char * = 0);
  40. strstreambuf(unsigned char *, int, unsigned char * = 0);
  41. strstreambuf(signed char *, int, signed char * = 0);
  42. strstreambuf(void * (*a)(long), void (*f) (void *));
  43. ~strstreambuf();
  44. void freeze(int =1);
  45. char * str();
  46. virtual int overflow(int);
  47. virtual int underflow();
  48. virtual streambuf* setbuf(char *, int);
  49. virtual streampos seekoff(streamoff, ios::seek_dir, int);
  50. virtual int sync(); // not in spec.
  51. protected:
  52. virtual int doallocate();
  53. private:
  54. int x_dynamic;
  55. int x_bufmin;
  56. int _fAlloc;
  57. int x_static;
  58. void * (* x_alloc)(long);
  59. void (* x_free)(void *);
  60. };
  61. class _CRTIMP istrstream : public istream {
  62. public:
  63. istrstream(char *);
  64. istrstream(char *, int);
  65. ~istrstream();
  66. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  67. inline char * str() { return rdbuf()->str(); }
  68. };
  69. class _CRTIMP ostrstream : public ostream {
  70. public:
  71. ostrstream();
  72. ostrstream(char *, int, int = ios::out);
  73. ~ostrstream();
  74. inline int pcount() const { return rdbuf()->out_waiting(); }
  75. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  76. inline char * str() { return rdbuf()->str(); }
  77. };
  78. class _CRTIMP strstream : public iostream { // strstreambase ???
  79. public:
  80. strstream();
  81. strstream(char *, int, int);
  82. ~strstream();
  83. inline int pcount() const { return rdbuf()->out_waiting(); } // not in spec.
  84. inline strstreambuf* rdbuf() const { return (strstreambuf*) ostream::rdbuf(); }
  85. inline char * str() { return rdbuf()->str(); }
  86. };
  87. #ifdef _MSC_VER
  88. // Restore previous packing
  89. #pragma pack(pop)
  90. #endif // _MSC_VER
  91. #endif // !_INC_STRSTREAM