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.

165 lines
4.9 KiB

  1. /***
  2. *strstrea.h - definitions/declarations for strstreambuf, strstream
  3. *
  4. * Copyright (c) 1991-2001, 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. *Revision History:
  14. * 01-23-92 KRS Ported from 16-bit version.
  15. * 02-23-93 SKS Update copyright to 1993
  16. * 10-12-93 GJF Support NT and Cuda versions. Enclose #pragma-s in
  17. * #ifdef _MSC_VER
  18. * 08-12-94 GJF Disable warning 4514 instead of 4505.
  19. * 11-03-94 GJF Changed pack pragma to 8 byte alignment.
  20. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  21. * 02-14-95 CFW Clean up Mac merge.
  22. * 05-11-95 CFW Only for use by C++ programs.
  23. * 12-14-95 JWM Add "#pragma once".
  24. * 04-09-96 SKS Change _CRTIMP to _CRTIMP1 for special iostream build
  25. * 04-15-96 JWM Remove _OLD_IOSTREAMS, add '#pragma comment(lib,"cirt")'.
  26. * 04-16-96 JWM '#include useoldio.h' replaces '#pragma comment(...)'.
  27. * 02-24-97 GJF Cleaned out obsolete support for _NTSDK. Also,
  28. * detab-ed.
  29. * 05-17-99 PML Remove all Macintosh support.
  30. *
  31. ****/
  32. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  33. #pragma once
  34. #endif
  35. #ifdef __cplusplus
  36. #ifndef _INC_STRSTREAM
  37. #define _INC_STRSTREAM
  38. #if !defined(_WIN32)
  39. #error ERROR: Only Win32 target supported!
  40. #endif
  41. #ifndef _CRTBLD
  42. /* This version of the header files is NOT for user programs.
  43. * It is intended for use when building the C runtimes ONLY.
  44. * The version intended for public use will not have this message.
  45. */
  46. #error ERROR: Use of C runtime library internal header file.
  47. #endif /* _CRTBLD */
  48. #ifdef _MSC_VER
  49. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  50. // alignment.
  51. #pragma pack(push,8)
  52. #endif // _MSC_VER
  53. /* Define _CRTIMP */
  54. #ifndef _CRTIMP
  55. #ifdef CRTDLL
  56. #define _CRTIMP __declspec(dllexport)
  57. #else /* ndef CRTDLL */
  58. #ifdef _DLL
  59. #define _CRTIMP __declspec(dllimport)
  60. #else /* ndef _DLL */
  61. #define _CRTIMP
  62. #endif /* _DLL */
  63. #endif /* CRTDLL */
  64. #endif /* _CRTIMP */
  65. #ifndef _INTERNAL_IFSTRIP_
  66. /* Define _CRTIMP1 */
  67. #ifndef _CRTIMP1
  68. #ifdef CRTDLL1
  69. #define _CRTIMP1 __declspec(dllexport)
  70. #else /* ndef CRTDLL1 */
  71. #define _CRTIMP1 _CRTIMP
  72. #endif /* CRTDLL1 */
  73. #endif /* _CRTIMP1 */
  74. #endif /* _INTERNAL_IFSTRIP_ */
  75. #include <useoldio.h>
  76. #include <iostream.h>
  77. #ifdef _MSC_VER
  78. #pragma warning(disable:4514) // disable unwanted /W4 warning
  79. // #pragma warning(default:4514) // use this to reenable, if necessary
  80. #endif // _MSC_VER
  81. class _CRTIMP1 strstreambuf : public streambuf {
  82. public:
  83. strstreambuf();
  84. strstreambuf(int);
  85. strstreambuf(char *, int, char * = 0);
  86. strstreambuf(unsigned char *, int, unsigned char * = 0);
  87. strstreambuf(signed char *, int, signed char * = 0);
  88. strstreambuf(void * (*a)(long), void (*f) (void *));
  89. ~strstreambuf();
  90. void freeze(int =1);
  91. char * str();
  92. virtual int overflow(int);
  93. virtual int underflow();
  94. virtual streambuf* setbuf(char *, int);
  95. virtual streampos seekoff(streamoff, ios::seek_dir, int);
  96. virtual int sync(); // not in spec.
  97. protected:
  98. virtual int doallocate();
  99. private:
  100. int x_dynamic;
  101. int x_bufmin;
  102. int _fAlloc;
  103. int x_static;
  104. void * (* x_alloc)(long);
  105. void (* x_free)(void *);
  106. };
  107. class _CRTIMP1 istrstream : public istream {
  108. public:
  109. istrstream(char *);
  110. istrstream(char *, int);
  111. ~istrstream();
  112. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  113. inline char * str() { return rdbuf()->str(); }
  114. };
  115. class _CRTIMP1 ostrstream : public ostream {
  116. public:
  117. ostrstream();
  118. ostrstream(char *, int, int = ios::out);
  119. ~ostrstream();
  120. inline int pcount() const { return rdbuf()->out_waiting(); }
  121. inline strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  122. inline char * str() { return rdbuf()->str(); }
  123. };
  124. class _CRTIMP1 strstream : public iostream { // strstreambase ???
  125. public:
  126. strstream();
  127. strstream(char *, int, int);
  128. ~strstream();
  129. inline int pcount() const { return rdbuf()->out_waiting(); } // not in spec.
  130. inline strstreambuf* rdbuf() const { return (strstreambuf*) ostream::rdbuf(); }
  131. inline char * str() { return rdbuf()->str(); }
  132. };
  133. #ifdef _MSC_VER
  134. // Restore previous packing
  135. #pragma pack(pop)
  136. #endif // _MSC_VER
  137. #endif // _INC_STRSTREAM
  138. #endif /* __cplusplus */