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.

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