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.

124 lines
2.8 KiB

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