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.

204 lines
6.8 KiB

  1. /***
  2. *ostream.h - definitions/declarations for the ostream class
  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 ostream class.
  9. * [AT&T C++]
  10. *
  11. * [Public]
  12. *
  13. *Revision History:
  14. * 01-23-92 KRS Ported from 16-bit version.
  15. * 06-03-92 KRS CAV #1183: Add 'const' to ptr output function.
  16. * 02-23-93 SKS Update copyright to 1993
  17. * 03-23-93 CFW Modified #pragma warnings.
  18. * 05-10-93 CFW Enable operator<<(long double)
  19. * 10-13-93 GJF Support NT and Cuda builds. Enclose #pragma-s in
  20. * #ifdef _MSC_VER
  21. * 04-12-94 SKS Add __cdecl keyword to dec/hex/oct functions and
  22. * operator <<. Add underscores to some parameter names.
  23. * 08-12-94 GJF Disable warning 4514 instead of 4505.
  24. * 11-03-94 GJF Changed pack pragma to 8 byte alignment.
  25. * 01-26-95 CFW Removed QWIN ifdef.
  26. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  27. * 02-14-95 CFW Clean up Mac merge.
  28. * 05-11-95 CFW Only for use by C++ programs.
  29. * 12-14-95 JWM Add "#pragma once".
  30. * 04-09-96 SKS Change _CRTIMP to _CRTIMP1 for special iostream build
  31. * 04-15-96 JWM Remove _OLD_IOSTREAMS, add '#pragma comment(lib,"cirt")'.
  32. * 04-16-96 JWM '#include useoldio.h' replaces '#pragma comment(...)'.
  33. * 02-24-97 GJF Cleaned out obsolete support for _NTSDK. Also,
  34. * detab-ed.
  35. * 05-17-99 PML Remove all Macintosh support.
  36. *
  37. ****/
  38. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  39. #pragma once
  40. #endif
  41. #ifdef __cplusplus
  42. #ifndef _INC_OSTREAM
  43. #define _INC_OSTREAM
  44. #if !defined(_WIN32)
  45. #error ERROR: Only Win32 target supported!
  46. #endif
  47. #ifndef _CRTBLD
  48. /* This version of the header files is NOT for user programs.
  49. * It is intended for use when building the C runtimes ONLY.
  50. * The version intended for public use will not have this message.
  51. */
  52. #error ERROR: Use of C runtime library internal header file.
  53. #endif /* _CRTBLD */
  54. #ifdef _MSC_VER
  55. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  56. // alignment.
  57. #pragma pack(push,8)
  58. #include <useoldio.h>
  59. #endif // _MSC_VER
  60. /* Define _CRTIMP */
  61. #ifndef _CRTIMP
  62. #ifdef CRTDLL
  63. #define _CRTIMP __declspec(dllexport)
  64. #else /* ndef CRTDLL */
  65. #ifdef _DLL
  66. #define _CRTIMP __declspec(dllimport)
  67. #else /* ndef _DLL */
  68. #define _CRTIMP
  69. #endif /* _DLL */
  70. #endif /* CRTDLL */
  71. #endif /* _CRTIMP */
  72. #ifndef _INTERNAL_IFSTRIP_
  73. /* Define _CRTIMP1 */
  74. #ifndef _CRTIMP1
  75. #ifdef CRTDLL1
  76. #define _CRTIMP1 __declspec(dllexport)
  77. #else /* ndef CRTDLL1 */
  78. #define _CRTIMP1 _CRTIMP
  79. #endif /* CRTDLL1 */
  80. #endif /* _CRTIMP1 */
  81. #endif /* _INTERNAL_IFSTRIP_ */
  82. #include <ios.h>
  83. #ifdef _MSC_VER
  84. // C4514: "unreferenced inline function has been removed"
  85. #pragma warning(disable:4514) // disable C4514 warning
  86. // #pragma warning(default:4514) // use this to reenable, if desired
  87. #endif // _MSC_VER
  88. typedef long streamoff, streampos;
  89. class _CRTIMP1 ostream : virtual public ios {
  90. public:
  91. ostream(streambuf*);
  92. virtual ~ostream();
  93. ostream& flush();
  94. int opfx();
  95. void osfx();
  96. inline ostream& operator<<(ostream& (__cdecl * _f)(ostream&));
  97. inline ostream& operator<<(ios& (__cdecl * _f)(ios&));
  98. ostream& operator<<(const char *);
  99. inline ostream& operator<<(const unsigned char *);
  100. inline ostream& operator<<(const signed char *);
  101. inline ostream& operator<<(char);
  102. ostream& operator<<(unsigned char);
  103. inline ostream& operator<<(signed char);
  104. ostream& operator<<(short);
  105. ostream& operator<<(unsigned short);
  106. ostream& operator<<(int);
  107. ostream& operator<<(unsigned int);
  108. ostream& operator<<(long);
  109. ostream& operator<<(unsigned long);
  110. inline ostream& operator<<(float);
  111. ostream& operator<<(double);
  112. ostream& operator<<(long double);
  113. ostream& operator<<(const void *);
  114. ostream& operator<<(streambuf*);
  115. inline ostream& put(char);
  116. ostream& put(unsigned char);
  117. inline ostream& put(signed char);
  118. ostream& write(const char *,int);
  119. inline ostream& write(const unsigned char *,int);
  120. inline ostream& write(const signed char *,int);
  121. ostream& seekp(streampos);
  122. ostream& seekp(streamoff,ios::seek_dir);
  123. streampos tellp();
  124. protected:
  125. ostream();
  126. ostream(const ostream&); // treat as private
  127. ostream& operator=(streambuf*); // treat as private
  128. ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); }
  129. int do_opfx(int); // not used
  130. void do_osfx(); // not used
  131. private:
  132. ostream(ios&);
  133. ostream& writepad(const char *, const char *);
  134. int x_floatused;
  135. };
  136. inline ostream& ostream::operator<<(ostream& (__cdecl * _f)(ostream&)) { (*_f)(*this); return *this; }
  137. inline ostream& ostream::operator<<(ios& (__cdecl * _f)(ios& )) { (*_f)(*this); return *this; }
  138. inline ostream& ostream::operator<<(char _c) { return operator<<((unsigned char) _c); }
  139. inline ostream& ostream::operator<<(signed char _c) { return operator<<((unsigned char) _c); }
  140. inline ostream& ostream::operator<<(const unsigned char * _s) { return operator<<((const char *) _s); }
  141. inline ostream& ostream::operator<<(const signed char * _s) { return operator<<((const char *) _s); }
  142. inline ostream& ostream::operator<<(float _f) { x_floatused = 1; return operator<<((double) _f); }
  143. inline ostream& ostream::put(char _c) { return put((unsigned char) _c); }
  144. inline ostream& ostream::put(signed char _c) { return put((unsigned char) _c); }
  145. inline ostream& ostream::write(const unsigned char * _s, int _n) { return write((char *) _s, _n); }
  146. inline ostream& ostream::write(const signed char * _s, int _n) { return write((char *) _s, _n); }
  147. class _CRTIMP1 ostream_withassign : public ostream {
  148. public:
  149. ostream_withassign();
  150. ostream_withassign(streambuf* _is);
  151. ~ostream_withassign();
  152. ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); }
  153. ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); }
  154. };
  155. extern ostream_withassign _CRTIMP1 cout;
  156. extern ostream_withassign _CRTIMP1 cerr;
  157. extern ostream_withassign _CRTIMP1 clog;
  158. inline _CRTIMP1 ostream& __cdecl flush(ostream& _outs) { return _outs.flush(); }
  159. inline _CRTIMP1 ostream& __cdecl endl(ostream& _outs) { return _outs << '\n' << flush; }
  160. inline _CRTIMP1 ostream& __cdecl ends(ostream& _outs) { return _outs << char('\0'); }
  161. _CRTIMP1 ios& __cdecl dec(ios&);
  162. _CRTIMP1 ios& __cdecl hex(ios&);
  163. _CRTIMP1 ios& __cdecl oct(ios&);
  164. #ifdef _MSC_VER
  165. // Restore default packing
  166. #pragma pack(pop)
  167. #endif // _MSC_VER
  168. #endif // _INC_OSTREAM
  169. #endif /* __cplusplus */